Commit c4df88b7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use helper to access jsval_t type.

parent c5183bb5
...@@ -396,9 +396,11 @@ static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret) ...@@ -396,9 +396,11 @@ static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
/* ECMA-262 3rd Edition 11.9.6 */ /* ECMA-262 3rd Edition 11.9.6 */
static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret) static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret)
{ {
jsval_type_t type = jsval_type(lval);
TRACE("\n"); TRACE("\n");
if(lval.type != rval.type) { if(type != jsval_type(rval)) {
if(is_null_instance(lval)) if(is_null_instance(lval))
*ret = is_null_instance(rval); *ret = is_null_instance(rval);
else else
...@@ -406,7 +408,7 @@ static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret) ...@@ -406,7 +408,7 @@ static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret)
return S_OK; return S_OK;
} }
switch(lval.type) { switch(type) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
case JSV_NULL: case JSV_NULL:
*ret = TRUE; *ret = TRUE;
...@@ -1657,7 +1659,7 @@ static HRESULT interp_void(exec_ctx_t *ctx) ...@@ -1657,7 +1659,7 @@ static HRESULT interp_void(exec_ctx_t *ctx)
/* ECMA-262 3rd Edition 11.4.3 */ /* ECMA-262 3rd Edition 11.4.3 */
static HRESULT typeof_string(jsval_t v, const WCHAR **ret) static HRESULT typeof_string(jsval_t v, const WCHAR **ret)
{ {
switch(v.type) { switch(jsval_type(v)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
*ret = undefinedW; *ret = undefinedW;
break; break;
...@@ -1876,7 +1878,7 @@ static HRESULT interp_preinc(exec_ctx_t *ctx) ...@@ -1876,7 +1878,7 @@ static HRESULT interp_preinc(exec_ctx_t *ctx)
/* ECMA-262 3rd Edition 11.9.3 */ /* 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) 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); return equal2_values(lval, rval, ret);
/* FIXME: NULL disps should be handled in more general way */ /* FIXME: NULL disps should be handled in more general way */
......
...@@ -61,7 +61,7 @@ const char *debugstr_variant(const VARIANT *v) ...@@ -61,7 +61,7 @@ const char *debugstr_variant(const VARIANT *v)
const char *debugstr_jsval(const jsval_t v) const char *debugstr_jsval(const jsval_t v)
{ {
switch(v.type) { switch(jsval_type(v)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
return "undefined"; return "undefined";
case JSV_NULL: case JSV_NULL:
...@@ -217,7 +217,7 @@ static BSTR clone_bstr(BSTR str) ...@@ -217,7 +217,7 @@ static BSTR clone_bstr(BSTR str)
void jsval_release(jsval_t val) void jsval_release(jsval_t val)
{ {
switch(val.type) { switch(jsval_type(val)) {
case JSV_OBJECT: case JSV_OBJECT:
if(val.u.obj) if(val.u.obj)
IDispatch_Release(val.u.obj); IDispatch_Release(val.u.obj);
...@@ -252,7 +252,7 @@ HRESULT jsval_variant(jsval_t *val, VARIANT *var) ...@@ -252,7 +252,7 @@ HRESULT jsval_variant(jsval_t *val, VARIANT *var)
HRESULT jsval_copy(jsval_t v, jsval_t *r) HRESULT jsval_copy(jsval_t v, jsval_t *r)
{ {
switch(v.type) { switch(jsval_type(v)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
case JSV_NULL: case JSV_NULL:
case JSV_NUMBER: case JSV_NUMBER:
...@@ -329,7 +329,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r) ...@@ -329,7 +329,7 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
HRESULT jsval_to_variant(jsval_t val, VARIANT *retv) HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
{ {
switch(val.type) { switch(jsval_type(val)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
return S_OK; return S_OK;
...@@ -449,7 +449,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re ...@@ -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 */ /* ECMA-262 3rd Edition 9.2 */
HRESULT to_boolean(jsval_t val, BOOL *ret) HRESULT to_boolean(jsval_t val, BOOL *ret)
{ {
switch(val.type) { switch(jsval_type(val)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
case JSV_NULL: case JSV_NULL:
*ret = FALSE; *ret = FALSE;
...@@ -587,7 +587,7 @@ static HRESULT str_to_number(BSTR str, double *ret) ...@@ -587,7 +587,7 @@ static HRESULT str_to_number(BSTR str, double *ret)
/* ECMA-262 3rd Edition 9.3 */ /* ECMA-262 3rd Edition 9.3 */
HRESULT to_number(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, double *ret) 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: case JSV_UNDEFINED:
*ret = NAN; *ret = NAN;
return S_OK; return S_OK;
...@@ -734,7 +734,7 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, BSTR *str) ...@@ -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 trueW[] = {'t','r','u','e',0};
const WCHAR falseW[] = {'f','a','l','s','e',0}; const WCHAR falseW[] = {'f','a','l','s','e',0};
switch(val.type) { switch(jsval_type(val)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
*str = SysAllocString(undefinedW); *str = SysAllocString(undefinedW);
break; break;
...@@ -775,7 +775,7 @@ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp) ...@@ -775,7 +775,7 @@ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp)
jsdisp_t *dispex; jsdisp_t *dispex;
HRESULT hres; HRESULT hres;
switch(val.type) { switch(jsval_type(val)) {
case JSV_STRING: case JSV_STRING:
hres = create_string(ctx, get_string(val), SysStringLen(get_string(val)), &dispex); hres = create_string(ctx, get_string(val), SysStringLen(get_string(val)), &dispex);
if(FAILED(hres)) if(FAILED(hres))
......
...@@ -89,6 +89,11 @@ static inline jsval_t jsval_number(double n) ...@@ -89,6 +89,11 @@ static inline jsval_t jsval_number(double n)
return ret; return ret;
} }
static inline jsval_type_t jsval_type(jsval_t v)
{
return v.type;
}
static inline BOOL is_object_instance(jsval_t v) static inline BOOL is_object_instance(jsval_t v)
{ {
return v.type == JSV_OBJECT; return v.type == JSV_OBJECT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment