ReactOS  0.4.14-dev-554-g2f8d847
jsval.h File Reference
#include "jsstr.h"
Include dependency graph for jsval.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _jsval_t
 

Macros

#define JSV_VAL(x)   x
 
#define __JSVAL_TYPE(x)   ((x).type)
 
#define __JSVAL_BOOL(x)   ((x).u.b)
 
#define __JSVAL_STR(x)   ((x).u.str)
 
#define __JSVAL_OBJ(x)   ((x).u.obj)
 
#define __JSVAL_VAR(x)   ((x).u.v)
 

Enumerations

enum  jsval_type_t {
  JSV_UNDEFINED = JSV_VAL(1), JSV_NULL = JSV_VAL(2), JSV_OBJECT = JSV_VAL(3), JSV_STRING = JSV_VAL(4),
  JSV_NUMBER = JSV_VAL(5), JSV_BOOL = JSV_VAL(6), JSV_VARIANT = JSV_VAL(7)
}
 

Functions

static jsval_t jsval_bool (BOOL b)
 
static jsval_t jsval_string (jsstr_t *str)
 
static jsval_t jsval_disp (IDispatch *obj)
 
static jsval_t jsval_obj (jsdisp_t *obj)
 
static jsval_t jsval_null (void)
 
static jsval_t jsval_undefined (void)
 
static jsval_t jsval_number (double n)
 
static BOOL is_object_instance (jsval_t v)
 
static BOOL is_undefined (jsval_t v)
 
static BOOL is_null (jsval_t v)
 
static BOOL is_null_instance (jsval_t v)
 
static BOOL is_string (jsval_t v)
 
static BOOL is_number (jsval_t v)
 
static BOOL is_variant (jsval_t v)
 
static BOOL is_bool (jsval_t v)
 
static jsval_type_t jsval_type (jsval_t v)
 
static IDispatchget_object (jsval_t v)
 
static double get_number (jsval_t v)
 
static jsstr_tget_string (jsval_t v)
 
static VARIANTget_variant (jsval_t v)
 
static BOOL get_bool (jsval_t v)
 
HRESULT variant_to_jsval (VARIANT *, jsval_t *) DECLSPEC_HIDDEN
 
HRESULT jsval_to_variant (jsval_t, VARIANT *) DECLSPEC_HIDDEN
 
void jsval_release (jsval_t) DECLSPEC_HIDDEN
 
HRESULT jsval_copy (jsval_t, jsval_t *) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ __JSVAL_BOOL

#define __JSVAL_BOOL (   x)    ((x).u.b)

Definition at line 94 of file jsval.h.

◆ __JSVAL_OBJ

#define __JSVAL_OBJ (   x)    ((x).u.obj)

Definition at line 96 of file jsval.h.

◆ __JSVAL_STR

#define __JSVAL_STR (   x)    ((x).u.str)

Definition at line 95 of file jsval.h.

◆ __JSVAL_TYPE

#define __JSVAL_TYPE (   x)    ((x).type)

Definition at line 93 of file jsval.h.

◆ __JSVAL_VAR

#define __JSVAL_VAR (   x)    ((x).u.v)

Definition at line 97 of file jsval.h.

◆ JSV_VAL

#define JSV_VAL (   x)    x

Definition at line 41 of file jsval.h.

Enumeration Type Documentation

◆ jsval_type_t

Enumerator
JSV_UNDEFINED 
JSV_NULL 
JSV_OBJECT 
JSV_STRING 
JSV_NUMBER 
JSV_BOOL 
JSV_VARIANT 

Definition at line 44 of file jsval.h.

44  {
46  JSV_NULL = JSV_VAL(2),
47  JSV_OBJECT = JSV_VAL(3),
48  JSV_STRING = JSV_VAL(4),
49  JSV_NUMBER = JSV_VAL(5),
50  JSV_BOOL = JSV_VAL(6),
51  JSV_VARIANT = JSV_VAL(7)
52 } jsval_type_t;
#define JSV_VAL(x)
Definition: jsval.h:41
Definition: jsval.h:46
jsval_type_t
Definition: jsval.h:44
Definition: jsval.h:50

Function Documentation

◆ get_bool()

static BOOL get_bool ( jsval_t  v)
inlinestatic

Definition at line 239 of file jsval.h.

240 {
241  return __JSVAL_BOOL(v);
242 }
#define __JSVAL_BOOL(x)
Definition: jsval.h:94
const GLdouble * v
Definition: gl.h:2040

◆ get_number()

static double get_number ( jsval_t  v)
inlinestatic

◆ get_object()

◆ get_string()

static jsstr_t* get_string ( jsval_t  v)
inlinestatic

Definition at line 229 of file jsval.h.

230 {
231  return __JSVAL_STR(v);
232 }
#define __JSVAL_STR(x)
Definition: jsval.h:95
const GLdouble * v
Definition: gl.h:2040

◆ get_variant()

static VARIANT* get_variant ( jsval_t  v)
inlinestatic

Definition at line 234 of file jsval.h.

235 {
236  return __JSVAL_VAR(v);
237 }
#define __JSVAL_VAR(x)
Definition: jsval.h:97
const GLdouble * v
Definition: gl.h:2040

Referenced by debugstr_jsval(), jsval_copy(), jsval_release(), jsval_to_variant(), to_boolean(), to_number(), to_object(), typeof_string(), and VBArrayConstr_value().

◆ is_bool()

static BOOL is_bool ( jsval_t  v)
inlinestatic

Definition at line 205 of file jsval.h.

206 {
207  return __JSVAL_TYPE(v) == JSV_BOOL;
208 }
const GLdouble * v
Definition: gl.h:2040
Definition: jsval.h:50
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

Referenced by equal_values(), and interp_end_finally().

◆ is_null()

static BOOL is_null ( jsval_t  v)
inlinestatic

Definition at line 176 of file jsval.h.

177 {
178  return __JSVAL_TYPE(v) == JSV_NULL;
179 }
Definition: jsval.h:46
const GLdouble * v
Definition: gl.h:2040
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

Referenced by array_join(), equal_values(), Function_apply(), Function_call(), interp_new(), is_null_instance(), Object_create(), and ObjectConstr_value().

◆ is_null_instance()

static BOOL is_null_instance ( jsval_t  v)
inlinestatic

Definition at line 181 of file jsval.h.

182 {
183  return is_null(v) || (is_object_instance(v) && !__JSVAL_OBJ(v));
184 }
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
const GLdouble * v
Definition: gl.h:2040
#define __JSVAL_OBJ(x)
Definition: jsval.h:96

Referenced by jsval_strict_equal().

◆ is_number()

static BOOL is_number ( jsval_t  v)
inlinestatic

Definition at line 191 of file jsval.h.

192 {
193 #ifdef JSVAL_DOUBLE_LAYOUT_PTR32
194  return (v.u.s.tag & 0x7ff80000) != 0x7ff80000;
195 #else
196  return v.type == JSV_NUMBER;
197 #endif
198 }
const GLdouble * v
Definition: gl.h:2040

Referenced by ArrayConstr_value(), equal_values(), interp_end_finally(), interp_forin(), JSON_stringify(), jsval_type(), sort_cmp(), and stack_topn_exprval().

◆ is_object_instance()

◆ is_string()

static BOOL is_string ( jsval_t  v)
inlinestatic

Definition at line 186 of file jsval.h.

187 {
188  return __JSVAL_TYPE(v) == JSV_STRING;
189 }
const GLdouble * v
Definition: gl.h:2040
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

◆ is_undefined()

static BOOL is_undefined ( jsval_t  v)
inlinestatic

◆ is_variant()

static BOOL is_variant ( jsval_t  v)
inlinestatic

Definition at line 200 of file jsval.h.

201 {
202  return __JSVAL_TYPE(v) == JSV_VARIANT;
203 }
const GLdouble * v
Definition: gl.h:2040
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

Referenced by VBArrayConstr_value().

◆ jsval_bool()

◆ jsval_copy()

HRESULT jsval_copy ( jsval_t  ,
jsval_t  
)

Definition at line 231 of file jsutils.c.

232 {
233  switch(jsval_type(v)) {
234  case JSV_UNDEFINED:
235  case JSV_NULL:
236  case JSV_NUMBER:
237  case JSV_BOOL:
238  *r = v;
239  return S_OK;
240  case JSV_OBJECT:
241  if(get_object(v))
242  IDispatch_AddRef(get_object(v));
243  *r = v;
244  return S_OK;
245  case JSV_STRING: {
247  *r = v;
248  return S_OK;
249  }
250  case JSV_VARIANT:
251  return jsval_variant(r, get_variant(v));
252  }
253 
254  assert(0);
255  return E_FAIL;
256 }
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static jsstr_t * jsstr_addref(jsstr_t *str)
Definition: jsstr.h:116
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define E_FAIL
Definition: ddrawi.h:102
static char * get_string(void)
Definition: ppl.yy.c:4402
Definition: jsval.h:46
static VARIANT * get_variant(jsval_t v)
Definition: jsval.h:234
static HRESULT jsval_variant(jsval_t *val, VARIANT *var)
Definition: jsutils.c:210
static jsval_type_t jsval_type(jsval_t v)
Definition: jsval.h:210
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
Definition: jsval.h:50

Referenced by Arguments_idx_get(), Arguments_idx_put(), create_bind_function(), detach_arguments_object(), Enumerator_item(), exprval_propget(), exprval_propput(), interp_local(), jsdisp_define_property(), JSGlobal_eval(), maybe_to_primitive(), prop_get(), prop_put(), RegExp_get_lastIndex(), RegExp_set_lastIndex(), setup_scope(), to_primitive(), and VBArrayConstr_value().

◆ jsval_disp()

static jsval_t jsval_disp ( IDispatch obj)
inlinestatic

Definition at line 117 of file jsval.h.

118 {
119  jsval_t ret;
121  __JSVAL_OBJ(ret) = obj;
122  return ret;
123 }
Definition: jsval.h:54
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
int ret
#define __JSVAL_OBJ(x)
Definition: jsval.h:96
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

Referenced by ActiveXObject_value(), concat_obj(), FunctionConstr_value(), get_string_val(), identifier_eval(), interp_ret(), interp_this(), jsval_obj(), Object_valueOf(), ObjectConstr_value(), RegExp_exec(), regexp_string_match(), stack_push_exprval(), String_trim(), and variant_to_jsval().

◆ jsval_null()

static jsval_t jsval_null ( void  )
inlinestatic

◆ jsval_number()

static jsval_t jsval_number ( double  n)
inlinestatic

Definition at line 144 of file jsval.h.

145 {
146  jsval_t ret;
147 #ifdef JSVAL_DOUBLE_LAYOUT_PTR32
148  ret.u.n = n;
149  /* normalize NaN value */
150  if((ret.u.s.tag & 0x7ff00000) == 0x7ff00000) {
151  /* isinf */
152  if(ret.u.s.tag & 0xfffff) {
153  ret.u.s.tag = 0x7ff00000;
154  ret.u.s.u.as_uintptr = ~0;
155  }else if(ret.u.s.u.as_uintptr) {
156  ret.u.s.tag = 0x7ff00000;
157  }
158  }
159 #else
160  ret.type = JSV_NUMBER;
161  ret.u.n = n;
162 #endif
163  return ret;
164 }
Definition: jsval.h:54
GLdouble n
Definition: glext.h:7729
int ret

Referenced by add_eval(), Array_forEach(), Array_get_length(), Array_indexOf(), Array_map(), Array_push(), Array_splice(), Array_unshift(), create_builtin_function(), create_error(), create_match_array(), create_math(), create_regexp(), Date_getDate(), Date_getDay(), Date_getFullYear(), Date_getHours(), Date_getMilliseconds(), Date_getMinutes(), Date_getMonth(), Date_getSeconds(), Date_getTime(), Date_getTimezoneOffset(), Date_getUTCDate(), Date_getUTCDay(), Date_getUTCFullYear(), Date_getUTCHours(), Date_getUTCMilliseconds(), Date_getUTCMinutes(), Date_getUTCMonth(), Date_getUTCSeconds(), Date_getYear(), Date_setDate(), Date_setFullYear(), Date_setHours(), Date_setMilliseconds(), Date_setMinutes(), Date_setMonth(), Date_setSeconds(), Date_setTime(), Date_setUTCDate(), Date_setUTCFullYear(), Date_setUTCHours(), Date_setUTCMilliseconds(), Date_setUTCMinutes(), Date_setUTCMonth(), Date_setUTCSeconds(), Date_setYear(), Date_valueOf(), DateConstr_now(), DateConstr_parse(), DateConstr_UTC(), equal_values(), Function_get_length(), init_global(), interp_and(), interp_bneg(), interp_div(), interp_double(), interp_forin(), interp_int(), interp_lshift(), interp_minus(), interp_mod(), interp_mul(), interp_or(), interp_pop_except(), interp_postinc(), interp_preinc(), interp_rshift(), interp_rshift2(), interp_sub(), interp_tonum(), interp_xor(), JSGlobal_parseFloat(), JSGlobal_parseInt(), JSGlobal_ScriptEngineBuildVersion(), JSGlobal_ScriptEngineMajorVersion(), JSGlobal_ScriptEngineMinorVersion(), Math_abs(), Math_acos(), Math_asin(), Math_atan(), Math_atan2(), Math_ceil(), Math_cos(), Math_exp(), Math_floor(), Math_log(), Math_max(), Math_min(), Math_pow(), Math_random(), Math_round(), Math_sin(), Math_sqrt(), Math_tan(), maybe_to_primitive(), Number_get_value(), Number_toExponential(), Number_toFixed(), Number_toPrecision(), Number_toString(), Number_valueOf(), NumberConstr_value(), parse_json_value(), regexp_string_match(), rep_call(), set_last_index(), set_length(), setup_arguments_object(), stack_push_exprval(), stack_topn_exprval(), String_charCodeAt(), String_get_length(), String_indexOf(), String_lastIndexOf(), String_search(), variant_to_jsval(), VBArray_dimensions(), VBArray_lbound(), and VBArray_ubound().

◆ jsval_obj()

◆ jsval_release()

void jsval_release ( jsval_t  )

Definition at line 191 of file jsutils.c.

192 {
193  switch(jsval_type(val)) {
194  case JSV_OBJECT:
195  if(get_object(val))
196  IDispatch_Release(get_object(val));
197  break;
198  case JSV_STRING:
200  break;
201  case JSV_VARIANT:
204  break;
205  default:
206  break;
207  }
208 }
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static char * get_string(void)
Definition: ppl.yy.c:4402
GLuint GLfloat * val
Definition: glext.h:7180
static VARIANT * get_variant(jsval_t v)
Definition: jsval.h:234
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
static jsval_type_t jsval_type(jsval_t v)
Definition: jsval.h:210
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_eval(), Arguments_destructor(), Arguments_idx_put(), Array_forEach(), Array_indexOf(), array_join(), Array_map(), Array_pop(), Array_reverse(), Array_shift(), Array_slice(), Array_sort(), Array_splice(), array_to_args(), Array_unshift(), bind_event_target(), BindFunction_destructor(), clear_acc(), clear_ei(), concat_array(), convert_params(), DateConstr_value(), delete_prop(), DispatchEx_InvokeEx(), enter_bytecode(), Enumerator_destructor(), enumvar_get_next_item(), equal_values(), Error_toString(), exprval_propput(), exprval_release(), Function_apply(), get_length(), init_dispex_from_constr(), interp_add(), interp_array(), interp_assign(), interp_bneg(), interp_carray_set(), interp_case(), interp_delete(), interp_enter_catch(), interp_eq(), interp_eq2(), interp_gt(), interp_gteq(), interp_in(), interp_instanceof(), interp_jmp_z(), interp_lt(), interp_lteq(), interp_memberid(), interp_neg(), interp_neq(), interp_neq2(), interp_obj_prop(), interp_postinc(), interp_preinc(), interp_push_scope(), interp_ret(), interp_setret(), interp_throw(), interp_tonum(), interp_typeof(), interp_typeofid(), interp_typeofident(), JScriptParse_ParseScriptText(), jsdisp_define_properties(), jsdisp_define_property(), jsdisp_free(), JSON_parse(), JSON_stringify(), less_eval(), parse_json_value(), pop_call_frame(), prop_put(), RegExp_destructor(), RegExp_set_lastIndex(), release_property_descriptor(), rep_call(), script_release(), set_last_index(), setup_scope(), sort_cmp(), stack_pop_number(), stack_pop_object(), stack_popn(), stack_push(), stringify(), stringify_object(), throw_error(), to_number(), to_property_descriptor(), to_string(), unwind_exception(), variant_change_type(), and VBArray_toArray().

◆ jsval_string()

static jsval_t jsval_string ( jsstr_t str)
inlinestatic

Definition at line 109 of file jsval.h.

110 {
111  jsval_t ret;
113  __JSVAL_STR(ret) = str;
114  return ret;
115 }
Definition: jsval.h:54
const WCHAR * str
int ret
#define __JSVAL_STR(x)
Definition: jsval.h:95
#define __JSVAL_TYPE(x)
Definition: jsval.h:93

Referenced by add_eval(), array_join(), Bool_toString(), create_error(), create_match_array(), create_utc_string(), date_to_string(), Date_toISOString(), Date_toLocaleDateString(), Date_toLocaleString(), Date_toLocaleTimeString(), Date_toTimeString(), dateobj_to_date_string(), do_attribute_tag_format(), do_attributeless_tag_format(), Error_toString(), Function_get_value(), Function_toString(), global_idx(), init_error_constr(), interp_forin(), interp_str(), interp_typeofid(), interp_typeofident(), JSGlobal_decodeURI(), JSGlobal_decodeURIComponent(), JSGlobal_encodeURI(), JSGlobal_encodeURIComponent(), JSGlobal_escape(), JSGlobal_ScriptEngine(), JSGlobal_unescape(), JSON_stringify(), maybe_to_primitive(), Number_toExponential(), Number_toFixed(), Number_toPrecision(), Number_toString(), Object_get_value(), Object_toString(), parse_json_value(), RegExp_exec(), RegExp_get_source(), regexp_string_match(), RegExp_test(), RegExp_toString(), RegExpConstr_get_leftContext(), RegExpConstr_get_rightContext(), rep_call(), stack_push_string(), String_charAt(), String_concat(), String_get_value(), String_idx_get(), String_replace(), String_slice(), String_split(), String_substr(), String_substring(), String_toLowerCase(), String_toUpperCase(), String_trim(), StringConstr_fromCharCode(), StringConstr_value(), stringobj_to_string(), and variant_to_jsval().

◆ jsval_to_variant()

HRESULT jsval_to_variant ( jsval_t  ,
VARIANT  
)

Definition at line 347 of file jsutils.c.

348 {
349  switch(jsval_type(val)) {
350  case JSV_UNDEFINED:
351  V_VT(retv) = VT_EMPTY;
352  return S_OK;
353  case JSV_NULL:
354  V_VT(retv) = VT_NULL;
355  return S_OK;
356  case JSV_OBJECT:
357  V_VT(retv) = VT_DISPATCH;
358  if(get_object(val))
359  IDispatch_AddRef(get_object(val));
360  V_DISPATCH(retv) = get_object(val);
361  return S_OK;
362  case JSV_STRING: {
364 
365  V_VT(retv) = VT_BSTR;
366  if(is_null_bstr(str)) {
367  V_BSTR(retv) = NULL;
368  }else {
370  if(V_BSTR(retv))
371  jsstr_flush(str, V_BSTR(retv));
372  else
373  return E_OUTOFMEMORY;
374  }
375  return S_OK;
376  }
377  case JSV_NUMBER: {
378  double n = get_number(val);
379 
380  if(is_int32(n)) {
381  V_VT(retv) = VT_I4;
382  V_I4(retv) = n;
383  }else {
384  V_VT(retv) = VT_R8;
385  V_R8(retv) = n;
386  }
387 
388  return S_OK;
389  }
390  case JSV_BOOL:
391  V_VT(retv) = VT_BOOL;
392  V_BOOL(retv) = get_bool(val) ? VARIANT_TRUE : VARIANT_FALSE;
393  return S_OK;
394  case JSV_VARIANT:
395  V_VT(retv) = VT_EMPTY;
396  return VariantCopy(retv, get_variant(val));
397  }
398 
399  assert(0);
400  return E_FAIL;
401 }
Definition: compat.h:1947
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
Definition: jsstr.h:39
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
#define V_R8(A)
Definition: oleauto.h:262
GLdouble n
Definition: glext.h:7729
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
#define assert(x)
Definition: debug.h:53
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
#define E_FAIL
Definition: ddrawi.h:102
static char * get_string(void)
Definition: ppl.yy.c:4402
#define V_I4(A)
Definition: oleauto.h:247
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
Definition: jsval.h:46
#define V_BOOL(A)
Definition: oleauto.h:224
static VARIANT * get_variant(jsval_t v)
Definition: jsval.h:234
static double get_number(jsval_t v)
Definition: jsval.h:224
static jsval_type_t jsval_type(jsval_t v)
Definition: jsval.h:210
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:59
BOOL is_null_bstr(jsstr_t *str)
Definition: jsstr.c:303
Definition: jsval.h:50
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748
static BOOL is_int32(double d)
Definition: jscript.h:514
Definition: compat.h:1949

Referenced by disp_call(), disp_call_value(), disp_propput(), DispatchEx_InvokeEx(), and JScriptParse_ParseScriptText().

◆ jsval_type()

static jsval_type_t jsval_type ( jsval_t  v)
inlinestatic

Definition at line 210 of file jsval.h.

211 {
212 #ifdef JSVAL_DOUBLE_LAYOUT_PTR32
213  return is_number(v) ? JSV_NUMBER : v.u.s.tag;
214 #else
215  return v.type;
216 #endif
217 }
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
const GLdouble * v
Definition: gl.h:2040

Referenced by debugstr_jsval(), equal_values(), jsval_copy(), jsval_release(), jsval_strict_equal(), jsval_to_variant(), stack_topn_exprval(), stringify(), to_boolean(), to_number(), to_object(), to_string(), typeof_string(), and unwind_exception().

◆ jsval_undefined()

◆ variant_to_jsval()

HRESULT variant_to_jsval ( VARIANT ,
jsval_t  
)

Definition at line 258 of file jsutils.c.

259 {
260  if(V_VT(var) == (VT_VARIANT|VT_BYREF))
261  var = V_VARIANTREF(var);
262 
263  switch(V_VT(var)) {
264  case VT_EMPTY:
265  *r = jsval_undefined();
266  return S_OK;
267  case VT_NULL:
268  *r = jsval_null();
269  return S_OK;
270  case VT_BOOL:
271  *r = jsval_bool(V_BOOL(var));
272  return S_OK;
273  case VT_I4:
274  *r = jsval_number(V_I4(var));
275  return S_OK;
276  case VT_R8:
277  *r = jsval_number(V_R8(var));
278  return S_OK;
279  case VT_BSTR: {
280  jsstr_t *str;
281 
282  if(V_BSTR(var)) {
284  if(!str)
285  return E_OUTOFMEMORY;
286  }else {
287  str = jsstr_null_bstr();
288  }
289 
290  *r = jsval_string(str);
291  return S_OK;
292  }
293  case VT_DISPATCH: {
294  if(V_DISPATCH(var))
295  IDispatch_AddRef(V_DISPATCH(var));
296  *r = jsval_disp(V_DISPATCH(var));
297  return S_OK;
298  }
299  case VT_I1:
300  *r = jsval_number(V_I1(var));
301  return S_OK;
302  case VT_UI1:
303  *r = jsval_number(V_UI1(var));
304  return S_OK;
305  case VT_I2:
306  *r = jsval_number(V_I2(var));
307  return S_OK;
308  case VT_UI2:
309  *r = jsval_number(V_UI2(var));
310  return S_OK;
311  case VT_INT:
312  *r = jsval_number(V_INT(var));
313  return S_OK;
314  case VT_UI4:
315  *r = jsval_number(V_UI4(var));
316  return S_OK;
317  case VT_UI8:
318  /*
319  * Native doesn't support VT_UI8 here, but it's needed for IE9+ APIs
320  * (native IE9 doesn't use jscript.dll for JavaScript).
321  */
322  *r = jsval_number(V_UI8(var));
323  return S_OK;
324  case VT_R4:
325  *r = jsval_number(V_R4(var));
326  return S_OK;
327  case VT_UNKNOWN:
328  if(V_UNKNOWN(var)) {
329  IDispatch *disp;
330  HRESULT hres;
331 
332  hres = IUnknown_QueryInterface(V_UNKNOWN(var), &IID_IDispatch, (void**)&disp);
333  if(SUCCEEDED(hres)) {
334  *r = jsval_disp(disp);
335  return S_OK;
336  }
337  }else {
338  *r = jsval_disp(NULL);
339  return S_OK;
340  }
341  /* fall through */
342  default:
343  return jsval_variant(r, var);
344  }
345 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
disp
Definition: i386-dis.c:3181
Definition: compat.h:1947
jsstr_t * jsstr_null_bstr(void)
Definition: jsstr.c:298
Definition: compat.h:1959
Definition: jsstr.h:39
static jsval_t jsval_null(void)
Definition: jsval.h:130
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2(A)
Definition: oleauto.h:245
#define V_UI8(A)
Definition: oleauto.h:272
#define V_I4(A)
Definition: oleauto.h:247
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define V_R4(A)
Definition: oleauto.h:260
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define V_UI1(A)
Definition: oleauto.h:266
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_UI4(A)
Definition: oleauto.h:270
const GUID IID_IDispatch
static HRESULT jsval_variant(jsval_t *val, VARIANT *var)
Definition: jsutils.c:210
Definition: compat.h:1948
#define V_VT(A)
Definition: oleauto.h:211
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_BSTR(A)
Definition: oleauto.h:226
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
#define V_INT(x)
Definition: webchild.h:78
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
#define V_VARIANTREF(A)
Definition: oleauto.h:283
Definition: compat.h:1949
Definition: compat.h:1946
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144

Referenced by convert_params(), disp_call(), disp_call_value(), disp_propget(), DispatchEx_InvokeEx(), enumvar_get_next_item(), variant_change_type(), VBArray_getItem(), and VBArray_toArray().