Jacek Caban : jscript: Use helper to access jsval_t type.

Alexandre Julliard julliard at winehq.org
Mon Sep 17 14:06:35 CDT 2012


Module: wine
Branch: master
Commit: c4df88b7fa61251cbeed185688d425303425841e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c4df88b7fa61251cbeed185688d425303425841e

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep 17 15:20:57 2012 +0200

jscript: Use helper to access jsval_t type.

---

 dlls/jscript/engine.c  |   10 ++++++----
 dlls/jscript/jsutils.c |   16 ++++++++--------
 dlls/jscript/jsval.h   |    5 +++++
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 1a06b19..341c9bf 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -396,9 +396,11 @@ static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
 /* ECMA-262 3rd Edition    11.9.6 */
 static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret)
 {
+    jsval_type_t type = jsval_type(lval);
+
     TRACE("\n");
 
-    if(lval.type != rval.type) {
+    if(type != jsval_type(rval)) {
         if(is_null_instance(lval))
             *ret = is_null_instance(rval);
         else
@@ -406,7 +408,7 @@ static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret)
         return S_OK;
     }
 
-    switch(lval.type) {
+    switch(type) {
     case JSV_UNDEFINED:
     case JSV_NULL:
         *ret = TRUE;
@@ -1657,7 +1659,7 @@ static HRESULT interp_void(exec_ctx_t *ctx)
 /* ECMA-262 3rd Edition    11.4.3 */
 static HRESULT typeof_string(jsval_t v, const WCHAR **ret)
 {
-    switch(v.type) {
+    switch(jsval_type(v)) {
     case JSV_UNDEFINED:
         *ret = undefinedW;
         break;
@@ -1876,7 +1878,7 @@ static HRESULT interp_preinc(exec_ctx_t *ctx)
 /* ECMA-262 3rd Edition    11.9.3 */
 static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexcept_t *ei, BOOL *ret)
 {
-    if(lval.type == rval.type || (is_number(lval) && is_number(rval)))
+    if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval)))
        return equal2_values(lval, rval, ret);
 
     /* FIXME: NULL disps should be handled in more general way */
diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 0b22a14..a33cb7e 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -61,7 +61,7 @@ const char *debugstr_variant(const VARIANT *v)
 
 const char *debugstr_jsval(const jsval_t v)
 {
-    switch(v.type) {
+    switch(jsval_type(v)) {
     case JSV_UNDEFINED:
         return "undefined";
     case JSV_NULL:
@@ -217,7 +217,7 @@ static BSTR clone_bstr(BSTR str)
 
 void jsval_release(jsval_t val)
 {
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_OBJECT:
         if(val.u.obj)
             IDispatch_Release(val.u.obj);
@@ -252,7 +252,7 @@ HRESULT jsval_variant(jsval_t *val, VARIANT *var)
 
 HRESULT jsval_copy(jsval_t v, jsval_t *r)
 {
-    switch(v.type) {
+    switch(jsval_type(v)) {
     case JSV_UNDEFINED:
     case JSV_NULL:
     case JSV_NUMBER:
@@ -329,7 +329,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
 
 HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
 {
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_UNDEFINED:
         V_VT(retv) = VT_EMPTY;
         return S_OK;
@@ -449,7 +449,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re
 /* ECMA-262 3rd Edition    9.2 */
 HRESULT to_boolean(jsval_t val, BOOL *ret)
 {
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_UNDEFINED:
     case JSV_NULL:
         *ret = FALSE;
@@ -587,7 +587,7 @@ static HRESULT str_to_number(BSTR str, double *ret)
 /* ECMA-262 3rd Edition    9.3 */
 HRESULT to_number(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, double *ret)
 {
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_UNDEFINED:
         *ret = NAN;
         return S_OK;
@@ -734,7 +734,7 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, BSTR *str)
     const WCHAR trueW[] = {'t','r','u','e',0};
     const WCHAR falseW[] = {'f','a','l','s','e',0};
 
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_UNDEFINED:
         *str = SysAllocString(undefinedW);
         break;
@@ -775,7 +775,7 @@ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp)
     jsdisp_t *dispex;
     HRESULT hres;
 
-    switch(val.type) {
+    switch(jsval_type(val)) {
     case JSV_STRING:
         hres = create_string(ctx, get_string(val), SysStringLen(get_string(val)), &dispex);
         if(FAILED(hres))
diff --git a/dlls/jscript/jsval.h b/dlls/jscript/jsval.h
index e55db92..a678e05 100644
--- a/dlls/jscript/jsval.h
+++ b/dlls/jscript/jsval.h
@@ -89,6 +89,11 @@ static inline jsval_t jsval_number(double n)
     return ret;
 }
 
+static inline jsval_type_t jsval_type(jsval_t v)
+{
+    return v.type;
+}
+
 static inline BOOL is_object_instance(jsval_t v)
 {
     return v.type == JSV_OBJECT;




More information about the wine-cvs mailing list