ReactOS  0.4.14-dev-57-g333b8f1
bool.c File Reference
#include <assert.h>
#include "jscript.h"
#include "wine/debug.h"
Include dependency graph for bool.c:

Go to the source code of this file.

Classes

struct  BoolInstance
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static BoolInstancebool_from_jsdisp (jsdisp_t *jsdisp)
 
static BoolInstancebool_from_vdisp (vdisp_t *vdisp)
 
static BoolInstancebool_this (vdisp_t *jsthis)
 
BOOL bool_obj_value (jsdisp_t *obj)
 
static HRESULT Bool_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Bool_valueOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Bool_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT BoolConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT alloc_bool (script_ctx_t *ctx, jsdisp_t *object_prototype, BoolInstance **ret)
 
HRESULT create_bool_constr (script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
 
HRESULT create_bool (script_ctx_t *ctx, BOOL b, jsdisp_t **ret)
 

Variables

static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const WCHAR valueOfW [] = {'v','a','l','u','e','O','f',0}
 
static const builtin_prop_t Bool_props []
 
static const builtin_info_t Bool_info
 
static const builtin_info_t BoolInst_info
 

Function Documentation

◆ alloc_bool()

static HRESULT alloc_bool ( script_ctx_t ctx,
jsdisp_t object_prototype,
BoolInstance **  ret 
)
static

Definition at line 175 of file bool.c.

176 {
178  HRESULT hres;
179 
180  bool = heap_alloc_zero(sizeof(BoolInstance));
181  if(!bool)
182  return E_OUTOFMEMORY;
183 
184  if(object_prototype)
185  hres = init_dispex(&bool->dispex, ctx, &Bool_info, object_prototype);
186  else
187  hres = init_dispex_from_constr(&bool->dispex, ctx, &BoolInst_info, ctx->bool_constr);
188 
189  if(FAILED(hres)) {
190  heap_free(bool);
191  return hres;
192  }
193 
194  *ret = bool;
195  return S_OK;
196 }
jsdisp_t * bool_constr
Definition: jscript.h:440
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const builtin_info_t Bool_info
Definition: bool.c:121
int ret
#define S_OK
Definition: intsafe.h:59
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
static const builtin_info_t BoolInst_info
Definition: bool.c:130
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1051
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_bool(), and create_bool_constr().

◆ bool_from_jsdisp()

static BoolInstance* bool_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 37 of file bool.c.

38 {
39  return CONTAINING_RECORD(jsdisp, BoolInstance, dispex);
40 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by bool_from_vdisp(), and bool_obj_value().

◆ bool_from_vdisp()

static BoolInstance* bool_from_vdisp ( vdisp_t vdisp)
inlinestatic

Definition at line 42 of file bool.c.

43 {
44  return bool_from_jsdisp(vdisp->u.jsdisp);
45 }
jsdisp_t * jsdisp
Definition: jscript.h:141
static BoolInstance * bool_from_jsdisp(jsdisp_t *jsdisp)
Definition: bool.c:37
union vdisp_t::@420 u

Referenced by bool_this().

◆ bool_obj_value()

BOOL bool_obj_value ( jsdisp_t obj)

Definition at line 52 of file bool.c.

53 {
55  return bool_from_jsdisp(obj)->val;
56 }
#define assert(x)
Definition: debug.h:53
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:500
BOOL val
Definition: bool.c:31
static BoolInstance * bool_from_jsdisp(jsdisp_t *jsdisp)
Definition: bool.c:37

Referenced by maybe_to_primitive().

◆ bool_this()

static BoolInstance* bool_this ( vdisp_t jsthis)
inlinestatic

Definition at line 47 of file bool.c.

48 {
49  return is_vclass(jsthis, JSCLASS_BOOLEAN) ? bool_from_vdisp(jsthis) : NULL;
50 }
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:505
static BoolInstance * bool_from_vdisp(vdisp_t *vdisp)
Definition: bool.c:42

Referenced by Bool_toString(), and Bool_valueOf().

◆ Bool_toString()

static HRESULT Bool_toString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 59 of file bool.c.

60 {
62 
63  static const WCHAR trueW[] = {'t','r','u','e',0};
64  static const WCHAR falseW[] = {'f','a','l','s','e',0};
65 
66  TRACE("\n");
67 
68  if(!(bool = bool_this(jsthis)))
70 
71  if(r) {
72  jsstr_t *val;
73 
74  val = jsstr_alloc(bool->val ? trueW : falseW);
75  if(!val)
76  return E_OUTOFMEMORY;
77 
78  *r = jsval_string(val);
79  }
80 
81  return S_OK;
82 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define JS_E_BOOLEAN_EXPECTED
Definition: jscript.h:562
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
GLuint GLfloat * val
Definition: glext.h:7180
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
static BoolInstance * bool_this(vdisp_t *jsthis)
Definition: bool.c:47
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR falseW[]
Definition: json.c:35
#define S_OK
Definition: intsafe.h:59
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
static const WCHAR trueW[]
Definition: json.c:34

◆ Bool_value()

static HRESULT Bool_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 99 of file bool.c.

101 {
102  TRACE("\n");
103 
104  switch(flags) {
105  case INVOKE_FUNC:
107  default:
108  FIXME("unimplemented flags %x\n", flags);
109  return E_NOTIMPL;
110  }
111 
112  return S_OK;
113 
114 }
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:556
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438

◆ Bool_valueOf()

static HRESULT Bool_valueOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 85 of file bool.c.

86 {
88 
89  TRACE("\n");
90 
91  if(!(bool = bool_this(jsthis)))
93 
94  if(r)
95  *r = jsval_bool(bool->val);
96  return S_OK;
97 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define JS_E_BOOLEAN_EXPECTED
Definition: jscript.h:562
smooth NULL
Definition: ftsmooth.c:416
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
static BoolInstance * bool_this(vdisp_t *jsthis)
Definition: bool.c:47
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

◆ BoolConstr_value()

static HRESULT BoolConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 138 of file bool.c.

140 {
141  BOOL value = FALSE;
142  HRESULT hres;
143 
144  if(argc) {
145  hres = to_boolean(argv[0], &value);
146  if(FAILED(hres))
147  return hres;
148  }
149 
150  switch(flags) {
151  case DISPATCH_CONSTRUCT: {
152  jsdisp_t *bool;
153 
154  hres = create_bool(ctx, value, &bool);
155  if(FAILED(hres))
156  return hres;
157 
158  *r = jsval_obj(bool);
159  return S_OK;
160  }
161 
162  case INVOKE_FUNC:
163  if(r)
164  *r = jsval_bool(value);
165  return S_OK;
166 
167  default:
168  FIXME("unimplemented flags %x\n", flags);
169  return E_NOTIMPL;
170  }
171 
172  return S_OK;
173 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
HRESULT hres
Definition: protocol.c:465
HRESULT create_bool(script_ctx_t *ctx, BOOL b, jsdisp_t **ret)
Definition: bool.c:216
LONG HRESULT
Definition: typedefs.h:77
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:464
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

Referenced by create_bool_constr().

◆ create_bool()

HRESULT create_bool ( script_ctx_t ctx,
BOOL  b,
jsdisp_t **  ret 
)

Definition at line 216 of file bool.c.

217 {
219  HRESULT hres;
220 
221  hres = alloc_bool(ctx, NULL, &bool);
222  if(FAILED(hres))
223  return hres;
224 
225  bool->val = b;
226 
227  *ret = &bool->dispex;
228  return S_OK;
229 }
static HRESULT alloc_bool(script_ctx_t *ctx, jsdisp_t *object_prototype, BoolInstance **ret)
Definition: bool.c:175
smooth NULL
Definition: ftsmooth.c:416
#define b
Definition: ke_i.h:79
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59

Referenced by BoolConstr_value(), and to_object().

◆ create_bool_constr()

HRESULT create_bool_constr ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsdisp_t **  ret 
)

Definition at line 198 of file bool.c.

199 {
201  HRESULT hres;
202 
203  static const WCHAR BooleanW[] = {'B','o','o','l','e','a','n',0};
204 
205  hres = alloc_bool(ctx, object_prototype, &bool);
206  if(FAILED(hres))
207  return hres;
208 
210  PROPF_CONSTR|1, &bool->dispex, ret);
211 
212  jsdisp_release(&bool->dispex);
213  return hres;
214 }
#define PROPF_CONSTR
Definition: jscript.h:95
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:679
static const WCHAR BooleanW[]
Definition: global.c:35
static HRESULT alloc_bool(script_ctx_t *ctx, jsdisp_t *object_prototype, BoolInstance **ret)
Definition: bool.c:175
smooth NULL
Definition: ftsmooth.c:416
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: bool.c:138
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:265

Referenced by init_constructors().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ Bool_info

const builtin_info_t Bool_info
static
Initial value:
= {
}
static const builtin_prop_t Bool_props[]
Definition: bool.c:116
smooth NULL
Definition: ftsmooth.c:416
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: bool.c:99
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 121 of file bool.c.

Referenced by alloc_bool().

◆ Bool_props

const builtin_prop_t Bool_props[]
static
Initial value:
= {
}
static const WCHAR valueOfW[]
Definition: bool.c:35
static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: bool.c:59
static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: bool.c:85
static const WCHAR toStringW[]
Definition: bool.c:34
#define PROPF_METHOD
Definition: jscript.h:94

Definition at line 116 of file bool.c.

◆ BoolInst_info

const builtin_info_t BoolInst_info
static
Initial value:
= {
0, NULL,
}
smooth NULL
Definition: ftsmooth.c:416
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: bool.c:99

Definition at line 130 of file bool.c.

Referenced by alloc_bool().

◆ toStringW

const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}
static

Definition at line 34 of file bool.c.

◆ valueOfW

const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0}
static

Definition at line 35 of file bool.c.

Referenced by to_primitive().