ReactOS  0.4.14-dev-608-gd495a4f
function.c File Reference
#include <assert.h>
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
Include dependency graph for function.c:

Go to the source code of this file.

Classes

struct  FunctionInstance
 
struct  _function_vtbl_t
 
struct  InterpretedFunction
 
struct  NativeFunction
 
struct  BindFunction
 
struct  ArgumentsInstance
 

Typedefs

typedef struct _function_vtbl_t function_vtbl_t
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static HRESULT create_bind_function (script_ctx_t *, FunctionInstance *, IDispatch *, unsigned, jsval_t *, jsdisp_t **r)
 
static FunctionInstancefunction_from_jsdisp (jsdisp_t *jsdisp)
 
static FunctionInstancefunction_from_vdisp (vdisp_t *vdisp)
 
static FunctionInstancefunction_this (vdisp_t *jsthis)
 
static ArgumentsInstancearguments_from_jsdisp (jsdisp_t *jsdisp)
 
static HRESULT Arguments_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static void Arguments_destructor (jsdisp_t *jsdisp)
 
static unsigned Arguments_idx_length (jsdisp_t *jsdisp)
 
static jsval_tget_argument_ref (ArgumentsInstance *arguments, unsigned idx)
 
static HRESULT Arguments_idx_get (jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
 
static HRESULT Arguments_idx_put (jsdisp_t *jsdisp, unsigned idx, jsval_t val)
 
HRESULT setup_arguments_object (script_ctx_t *ctx, call_frame_t *frame)
 
void detach_arguments_object (jsdisp_t *args_disp)
 
HRESULT Function_invoke (jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Function_get_length (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static HRESULT Function_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT array_to_args (script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *argc, jsval_t **ret)
 
static HRESULT Function_apply (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Function_call (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Function_bind (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT Function_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT Function_get_value (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static HRESULT Function_get_arguments (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static void Function_destructor (jsdisp_t *dispex)
 
static HRESULT create_function (script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
 
static HRESULT NativeFunction_call (script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_disp, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT NativeFunction_toString (FunctionInstance *func, jsstr_t **ret)
 
static void NativeFunction_destructor (FunctionInstance *function)
 
HRESULT create_builtin_function (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)
 
static HRESULT set_constructor_prop (script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot)
 
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)
 
static HRESULT InterpretedFunction_call (script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT InterpretedFunction_toString (FunctionInstance *func, jsstr_t **ret)
 
static void InterpretedFunction_destructor (FunctionInstance *func)
 
HRESULT create_source_function (script_ctx_t *ctx, bytecode_t *code, function_code_t *func_code, scope_chain_t *scope_chain, jsdisp_t **ret)
 
static HRESULT BindFunction_call (script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT BindFunction_toString (FunctionInstance *function, jsstr_t **ret)
 
static void BindFunction_destructor (FunctionInstance *func)
 
static HRESULT construct_function (script_ctx_t *ctx, unsigned argc, jsval_t *argv, IDispatch **ret)
 
static HRESULT FunctionConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT FunctionProt_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT init_function_constr (script_ctx_t *ctx, jsdisp_t *object_prototype)
 

Variables

static const WCHAR prototypeW [] = {'p','r','o','t','o','t', 'y', 'p','e',0}
 
static const WCHAR lengthW [] = {'l','e','n','g','t','h',0}
 
static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const WCHAR applyW [] = {'a','p','p','l','y',0}
 
static const WCHAR bindW [] = {'b','i','n','d',0}
 
static const WCHAR callW [] = {'c','a','l','l',0}
 
static const WCHAR argumentsW [] = {'a','r','g','u','m','e','n','t','s',0}
 
static const builtin_info_t Arguments_info
 
static const builtin_prop_t Function_props []
 
static const builtin_info_t Function_info
 
static const builtin_prop_t FunctionInst_props []
 
static const builtin_info_t FunctionInst_info
 
static const function_vtbl_t NativeFunctionVtbl
 
static const function_vtbl_t InterpretedFunctionVtbl
 
static const function_vtbl_t BindFunctionVtbl
 

Typedef Documentation

◆ function_vtbl_t

Definition at line 28 of file function.c.

Function Documentation

◆ Arguments_destructor()

static void Arguments_destructor ( jsdisp_t jsdisp)
static

Definition at line 110 of file function.c.

111 {
112  ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
113 
114  TRACE("(%p)\n", arguments);
115 
116  if(arguments->buf) {
117  unsigned i;
118  for(i = 0; i < arguments->argc; i++)
119  jsval_release(arguments->buf[i]);
120  heap_free(arguments->buf);
121  }
122 
123  jsdisp_release(&arguments->function->function.dispex);
124  heap_free(arguments);
125 }
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
jsdisp_t dispex
Definition: function.c:31
InterpretedFunction * function
Definition: function.c:66
unsigned argc
Definition: function.c:69
jsval_t * buf
Definition: function.c:67
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89
FunctionInstance function
Definition: function.c:44
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ arguments_from_jsdisp()

static ArgumentsInstance* arguments_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 89 of file function.c.

90 {
91  return CONTAINING_RECORD(jsdisp, ArgumentsInstance, jsdisp);
92 }
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 Arguments_destructor(), Arguments_idx_get(), Arguments_idx_length(), Arguments_idx_put(), and detach_arguments_object().

◆ Arguments_idx_get()

static HRESULT Arguments_idx_get ( jsdisp_t jsdisp,
unsigned  idx,
jsval_t r 
)
static

Definition at line 142 of file function.c.

143 {
144  ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
145  jsval_t *ref;
146 
147  TRACE("%p[%u]\n", arguments, idx);
148 
149  if((ref = get_argument_ref(arguments, idx)))
150  return jsval_copy(*ref, r);
151 
152  /* FIXME: Accessing by name won't work for duplicated argument names */
153  return jsdisp_propget_name(arguments->frame->base_scope->jsobj,
154  arguments->function->func_code->params[idx], r);
155 }
Definition: jsval.h:54
jsdisp_t * jsobj
Definition: engine.h:204
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: send.c:47
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
GLenum GLint ref
Definition: glext.h:6028
unsigned int idx
Definition: utils.c:41
function_code_t * func_code
Definition: function.c:47
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1408
call_frame_t * frame
Definition: function.c:68
InterpretedFunction * function
Definition: function.c:66
scope_chain_t * base_scope
Definition: engine.h:226
static jsval_t * get_argument_ref(ArgumentsInstance *arguments, unsigned idx)
Definition: function.c:133
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89
BSTR * params
Definition: engine.h:164

◆ Arguments_idx_length()

static unsigned Arguments_idx_length ( jsdisp_t jsdisp)
static

Definition at line 127 of file function.c.

128 {
129  ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
130  return arguments->argc;
131 }
unsigned argc
Definition: function.c:69
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89

◆ Arguments_idx_put()

static HRESULT Arguments_idx_put ( jsdisp_t jsdisp,
unsigned  idx,
jsval_t  val 
)
static

Definition at line 157 of file function.c.

158 {
159  ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
160  jsval_t *ref;
161  HRESULT hres;
162 
163  TRACE("%p[%u] = %s\n", arguments, idx, debugstr_jsval(val));
164 
165  if((ref = get_argument_ref(arguments, idx))) {
166  jsval_t copy;
167  hres = jsval_copy(val, &copy);
168  if(FAILED(hres))
169  return hres;
170 
171  jsval_release(*ref);
172  *ref = copy;
173  return S_OK;
174  }
175 
176  /* FIXME: Accessing by name won't work for duplicated argument names */
177  return jsdisp_propput_name(arguments->frame->base_scope->jsobj,
178  arguments->function->func_code->params[idx], val);
179 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
jsdisp_t * jsobj
Definition: engine.h:204
Definition: send.c:47
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
GLenum GLint ref
Definition: glext.h:6028
unsigned int idx
Definition: utils.c:41
GLuint GLfloat * val
Definition: glext.h:7180
function_code_t * func_code
Definition: function.c:47
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
call_frame_t * frame
Definition: function.c:68
InterpretedFunction * function
Definition: function.c:66
scope_chain_t * base_scope
Definition: engine.h:226
#define S_OK
Definition: intsafe.h:59
static jsval_t * get_argument_ref(ArgumentsInstance *arguments, unsigned idx)
Definition: function.c:133
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
BSTR * params
Definition: engine.h:164
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

◆ Arguments_value()

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

Definition at line 103 of file function.c.

105 {
106  FIXME("\n");
107  return E_NOTIMPL;
108 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ array_to_args()

static HRESULT array_to_args ( script_ctx_t ctx,
jsdisp_t arg_array,
unsigned argc,
jsval_t **  ret 
)
static

Definition at line 307 of file function.c.

308 {
309  jsval_t *argv, val;
310  DWORD length, i;
311  HRESULT hres;
312 
313  hres = jsdisp_propget_name(arg_array, lengthW, &val);
314  if(FAILED(hres))
315  return hres;
316 
317  hres = to_uint32(ctx, val, &length);
319  if(FAILED(hres))
320  return hres;
321 
322  argv = heap_alloc(length * sizeof(*argv));
323  if(!argv)
324  return E_OUTOFMEMORY;
325 
326  for(i=0; i<length; i++) {
327  hres = jsdisp_get_idx(arg_array, i, argv+i);
328  if(hres == DISP_E_UNKNOWNNAME) {
329  argv[i] = jsval_undefined();
330  }else if(FAILED(hres)) {
331  while(i--)
332  jsval_release(argv[i]);
333  heap_free(argv);
334  return hres;
335  }
336  }
337 
338  *argc = length;
339  *ret = argv;
340  return S_OK;
341 }
HRESULT to_uint32(script_ctx_t *, jsval_t, UINT32 *) DECLSPEC_HIDDEN
Definition: jsutils.c:686
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static const WCHAR lengthW[]
Definition: function.c:96
#define argv
Definition: mplay32.c:18
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT hres
Definition: protocol.c:465
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1408
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1425
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by Function_apply().

◆ BindFunction_call()

static HRESULT BindFunction_call ( script_ctx_t ctx,
FunctionInstance func,
IDispatch this_obj,
unsigned  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 806 of file function.c.

808 {
809  BindFunction *function = (BindFunction*)func;
810  jsval_t *call_args = NULL;
811  unsigned call_argc;
812  HRESULT hres;
813 
814  TRACE("%p\n", function);
815 
816  call_argc = function->argc + argc;
817  if(call_argc) {
818  call_args = heap_alloc(function->argc * sizeof(*function->args));
819  if(!call_args)
820  return E_OUTOFMEMORY;
821 
822  if(function->argc)
823  memcpy(call_args, function->args, function->argc * sizeof(*call_args));
824  if(argc)
825  memcpy(call_args + function->argc, argv, argc * sizeof(*call_args));
826  }
827 
828  hres = function->target->vtbl->call(ctx, function->target, function->this, flags, call_argc, call_args, r);
829 
830  heap_free(call_args);
831  return hres;
832 }
Definition: jsval.h:54
GLenum func
Definition: glext.h:6028
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ BindFunction_destructor()

static void BindFunction_destructor ( FunctionInstance func)
static

Definition at line 845 of file function.c.

846 {
847  BindFunction *function = (BindFunction*)func;
848  unsigned i;
849 
850  TRACE("%p\n", function);
851 
852  for(i = 0; i < function->argc; i++)
853  jsval_release(function->args[i]);
854  jsdisp_release(&function->target->dispex);
855  IDispatch_Release(function->this);
856 }
GLenum func
Definition: glext.h:6028
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268

◆ BindFunction_toString()

static HRESULT BindFunction_toString ( FunctionInstance function,
jsstr_t **  ret 
)
static

Definition at line 834 of file function.c.

835 {
836  static const WCHAR native_functionW[] =
837  {'\n','f','u','n','c','t','i','o','n','(',')',' ','{','\n',
838  ' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n',
839  '}','\n',0};
840 
841  *ret = jsstr_alloc(native_functionW);
842  return *ret ? S_OK : E_OUTOFMEMORY;
843 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define S_OK
Definition: intsafe.h:59

◆ construct_function()

static HRESULT construct_function ( script_ctx_t ctx,
unsigned  argc,
jsval_t argv,
IDispatch **  ret 
)
static

Definition at line 894 of file function.c.

895 {
896  WCHAR *str = NULL, *ptr;
897  unsigned len = 0, i = 0;
898  bytecode_t *code;
899  jsdisp_t *function;
900  jsstr_t **params = NULL;
901  int j = 0;
902  HRESULT hres = S_OK;
903 
904  static const WCHAR function_anonymousW[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('};
905  static const WCHAR function_beginW[] = {')',' ','{','\n'};
906  static const WCHAR function_endW[] = {'\n','}',0};
907 
908  if(argc) {
909  params = heap_alloc(argc*sizeof(*params));
910  if(!params)
911  return E_OUTOFMEMORY;
912 
913  if(argc > 2)
914  len = (argc-2)*2; /* separating commas */
915  for(i=0; i < argc; i++) {
916  hres = to_string(ctx, argv[i], params+i);
917  if(FAILED(hres))
918  break;
919  len += jsstr_length(params[i]);
920  }
921  }
922 
923  if(SUCCEEDED(hres)) {
924  len += ARRAY_SIZE(function_anonymousW) + ARRAY_SIZE(function_beginW) + ARRAY_SIZE(function_endW);
925  str = heap_alloc(len*sizeof(WCHAR));
926  if(str) {
927  memcpy(str, function_anonymousW, sizeof(function_anonymousW));
928  ptr = str + ARRAY_SIZE(function_anonymousW);
929  if(argc > 1) {
930  while(1) {
931  ptr += jsstr_flush(params[j], ptr);
932  if(++j == argc-1)
933  break;
934  *ptr++ = ',';
935  *ptr++ = ' ';
936  }
937  }
938  memcpy(ptr, function_beginW, sizeof(function_beginW));
939  ptr += ARRAY_SIZE(function_beginW);
940  if(argc)
941  ptr += jsstr_flush(params[argc-1], ptr);
942  memcpy(ptr, function_endW, sizeof(function_endW));
943 
944  TRACE("%s\n", debugstr_w(str));
945  }else {
947  }
948  }
949 
950  while(i)
951  jsstr_release(params[--i]);
952  heap_free(params);
953  if(FAILED(hres))
954  return hres;
955 
956  hres = compile_script(ctx, str, NULL, NULL, FALSE, FALSE, &code);
957  heap_free(str);
958  if(FAILED(hres))
959  return hres;
960 
961  if(code->global_code.func_cnt != 1 || code->global_code.var_cnt != 1) {
962  ERR("Invalid parser result!\n");
964  return E_UNEXPECTED;
965  }
966 
967  hres = create_source_function(ctx, code, code->global_code.funcs, NULL, &function);
969  if(FAILED(hres))
970  return hres;
971 
972  *ret = to_disp(function);
973  return S_OK;
974 }
static int argc
Definition: ServiceArgs.c:12
Definition: jsstr.h:39
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_code_t *func_code, scope_chain_t *scope_chain, jsdisp_t **ret)
Definition: function.c:767
#define argv
Definition: mplay32.c:18
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLenum const GLfloat * params
Definition: glext.h:5645
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, bytecode_t **ret)
Definition: compile.c:2461
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
int code
Definition: i386-dis.c:3591
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_UNEXPECTED
Definition: winerror.h:2456
void release_bytecode(bytecode_t *code)
Definition: compile.c:2226
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FunctionConstr_value().

◆ create_bind_function()

static HRESULT create_bind_function ( script_ctx_t ctx,
FunctionInstance target,
IDispatch bound_this,
unsigned  argc,
jsval_t argv,
jsdisp_t **  r 
)
static

Definition at line 864 of file function.c.

866 {
867  BindFunction *function;
868  HRESULT hres;
869 
871  FALSE, NULL, (void**)&function);
872  if(FAILED(hres))
873  return hres;
874 
875  jsdisp_addref(&target->dispex);
876  function->target = target;
877 
878  IDispatch_AddRef(function->this = bound_this);
879 
880  for(function->argc = 0; function->argc < argc; function->argc++) {
881  hres = jsval_copy(argv[function->argc], function->args + function->argc);
882  if(FAILED(hres)) {
883  jsdisp_release(&function->function.dispex);
884  return hres;
885  }
886  }
887 
888  function->function.length = target->length > argc ? target->length - argc : 0;
889 
890  *ret = &function->function.dispex;
891  return S_OK;
892 }
static int argc
Definition: ServiceArgs.c:12
static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
Definition: function.c:566
#define argv
Definition: mplay32.c:18
Definition: match.c:390
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262
int ret
#define S_OK
Definition: intsafe.h:59
#define PROPF_METHOD
Definition: jscript.h:97
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
GLenum target
Definition: glext.h:7315
static const function_vtbl_t BindFunctionVtbl
Definition: function.c:858

Referenced by Function_bind().

◆ create_builtin_constructor()

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 at line 686 of file function.c.

688 {
689  jsdisp_t *constr;
690  HRESULT hres;
691 
692  hres = create_builtin_function(ctx, value_proc, name, builtin_info, flags, prototype, &constr);
693  if(FAILED(hres))
694  return hres;
695 
696  hres = set_constructor_prop(ctx, constr, prototype);
697  if(FAILED(hres)) {
698  jsdisp_release(constr);
699  return hres;
700  }
701 
702  *ret = constr;
703  return S_OK;
704 }
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot)
Definition: function.c:678
int ret
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
Definition: name.c:38
HRESULT create_builtin_function(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:651

Referenced by create_array_constr(), create_bool_constr(), create_date_constr(), create_enumerator_constr(), create_number_constr(), create_object_constr(), create_regexp_constr(), create_string_constr(), create_vbarray_constr(), and init_error_constr().

◆ create_builtin_function()

HRESULT create_builtin_function ( 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 at line 651 of file function.c.

653 {
654  NativeFunction *function;
655  HRESULT hres;
656 
657  hres = create_function(ctx, builtin_info, &NativeFunctionVtbl, sizeof(NativeFunction), flags, FALSE, NULL, (void**)&function);
658  if(FAILED(hres))
659  return hres;
660 
661  if(builtin_info)
662  hres = jsdisp_define_data_property(&function->function.dispex, lengthW, 0,
663  jsval_number(function->function.length));
664  if(SUCCEEDED(hres))
665  hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, 0, jsval_obj(prototype));
666  if(FAILED(hres)) {
667  jsdisp_release(&function->function.dispex);
668  return hres;
669  }
670 
671  function->proc = value_proc;
672  function->name = name;
673 
674  *ret = &function->function.dispex;
675  return S_OK;
676 }
static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
Definition: function.c:566
static const WCHAR lengthW[]
Definition: function.c:96
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
static const WCHAR prototypeW[]
Definition: function.c:94
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const function_vtbl_t NativeFunctionVtbl
Definition: function.c:645
GLbitfield flags
Definition: glext.h:7161
int ret
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by create_activex_constr(), create_builtin_constructor(), and prop_get().

◆ create_function()

static HRESULT create_function ( script_ctx_t ctx,
const builtin_info_t builtin_info,
const function_vtbl_t vtbl,
size_t  size,
DWORD  flags,
BOOL  funcprot,
jsdisp_t prototype,
void **  ret 
)
static

Definition at line 566 of file function.c.

568 {
569  FunctionInstance *function;
570  HRESULT hres;
571 
572  function = heap_alloc_zero(size);
573  if(!function)
574  return E_OUTOFMEMORY;
575 
576  if(funcprot)
577  hres = init_dispex(&function->dispex, ctx, builtin_info, prototype);
578  else if(builtin_info)
579  hres = init_dispex_from_constr(&function->dispex, ctx, builtin_info, ctx->function_constr);
580  else
581  hres = init_dispex_from_constr(&function->dispex, ctx, &FunctionInst_info, ctx->function_constr);
582  if(FAILED(hres)) {
583  heap_free(function);
584  return hres;
585  }
586 
587  function->vtbl = vtbl;
588  function->flags = flags;
589  function->length = flags & PROPF_ARGMASK;
590 
591  *ret = function;
592  return S_OK;
593 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define PROPF_ARGMASK
Definition: jscript.h:96
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
int ret
#define S_OK
Definition: intsafe.h:59
jsdisp_t * function_constr
Definition: jscript.h:442
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1030
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static const builtin_info_t FunctionInst_info
Definition: function.c:557

Referenced by create_bind_function(), create_builtin_function(), create_source_function(), and init_function_constr().

◆ create_source_function()

HRESULT create_source_function ( script_ctx_t ctx,
bytecode_t code,
function_code_t func_code,
scope_chain_t scope_chain,
jsdisp_t **  ret 
)

Definition at line 767 of file function.c.

769 {
770  InterpretedFunction *function;
771  jsdisp_t *prototype;
772  HRESULT hres;
773 
774  hres = create_object(ctx, NULL, &prototype);
775  if(FAILED(hres))
776  return hres;
777 
779  FALSE, NULL, (void**)&function);
780  if(SUCCEEDED(hres)) {
781  hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, PROPF_WRITABLE,
782  jsval_obj(prototype));
783  if(SUCCEEDED(hres))
784  hres = set_constructor_prop(ctx, &function->function.dispex, prototype);
785  if(FAILED(hres))
786  jsdisp_release(&function->function.dispex);
787  }
788  jsdisp_release(prototype);
789  if(FAILED(hres))
790  return hres;
791 
792  if(scope_chain) {
793  scope_addref(scope_chain);
794  function->scope_chain = scope_chain;
795  }
796 
798  function->code = code;
799  function->func_code = func_code;
800  function->function.length = function->func_code->param_cnt;
801 
802  *ret = &function->function.dispex;
803  return S_OK;
804 }
#define PROPF_WRITABLE
Definition: jscript.h:101
static const function_vtbl_t InterpretedFunctionVtbl
Definition: function.c:761
static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
Definition: function.c:566
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
#define PROPF_CONSTR
Definition: jscript.h:98
static const WCHAR prototypeW[]
Definition: function.c:94
static scope_chain_t * scope_addref(scope_chain_t *scope)
Definition: engine.h:212
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot)
Definition: function.c:678
unsigned param_cnt
Definition: engine.h:163
int ret
int code
Definition: i386-dis.c:3591
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT create_object(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:731
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static bytecode_t * bytecode_addref(bytecode_t *code)
Definition: engine.h:196

Referenced by construct_function(), exec_source(), interp_func(), JScriptParseProcedure_ParseProcedureText(), and setup_scope().

◆ detach_arguments_object()

void detach_arguments_object ( jsdisp_t args_disp)

Definition at line 229 of file function.c.

230 {
231  ArgumentsInstance *arguments = arguments_from_jsdisp(args_disp);
232  call_frame_t *frame = arguments->frame;
233  const BOOL on_stack = frame->base_scope->frame == frame;
234  HRESULT hres;
235 
236  /* Reset arguments value to cut the reference cycle. Note that since all activation contexts have
237  * their own arguments property, it's impossible to use prototype's one during name lookup */
239  arguments->frame = NULL;
240 
241  /* Don't bother coppying arguments if call frame holds the last reference. */
242  if(arguments->jsdisp.ref > 1) {
243  arguments->buf = heap_alloc(arguments->argc * sizeof(*arguments->buf));
244  if(arguments->buf) {
245  int i;
246 
247  for(i = 0; i < arguments->argc ; i++) {
248  if(on_stack || i >= frame->function->param_cnt)
249  hres = jsval_copy(arguments->jsdisp.ctx->stack[frame->arguments_off + i], arguments->buf+i);
250  else
251  hres = jsdisp_propget_name(frame->base_scope->jsobj, frame->function->params[i], arguments->buf+i);
252  if(FAILED(hres))
253  arguments->buf[i] = jsval_undefined();
254  }
255  }else {
256  ERR("out of memory\n");
257  arguments->argc = 0;
258  }
259  }
260 
262 }
jsdisp_t * arguments_obj
Definition: engine.h:233
unsigned arguments_off
Definition: engine.h:238
script_ctx_t * ctx
Definition: jscript.h:238
jsdisp_t * jsobj
Definition: engine.h:204
function_code_t * function
Definition: engine.h:243
LONG ref
Definition: jscript.h:233
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1408
LONG HRESULT
Definition: typedefs.h:77
call_frame_t * frame
Definition: function.c:68
struct _call_frame_t * frame
Definition: engine.h:206
unsigned param_cnt
Definition: engine.h:163
jsval_t * stack
Definition: jscript.h:431
unsigned argc
Definition: function.c:69
#define ERR(fmt,...)
Definition: debug.h:109
scope_chain_t * base_scope
Definition: engine.h:226
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
static const WCHAR argumentsW[]
Definition: function.c:101
jsval_t * buf
Definition: function.c:67
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89
jsdisp_t jsdisp
Definition: function.c:65
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
BSTR * params
Definition: engine.h:164

Referenced by pop_call_frame().

◆ Function_apply()

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

Definition at line 343 of file function.c.

344 {
345  FunctionInstance *function;
346  jsval_t *args = NULL;
347  unsigned i, cnt = 0;
348  IDispatch *this_obj = NULL;
349  HRESULT hres = S_OK;
350 
351  TRACE("\n");
352 
353  if(!(function = function_this(jsthis)) && (jsthis->flags & VDISP_JSDISP))
355 
356  if(argc) {
357  if(!is_undefined(argv[0]) && !is_null(argv[0])) {
358  hres = to_object(ctx, argv[0], &this_obj);
359  if(FAILED(hres))
360  return hres;
361  }
362  }
363 
364  if(argc >= 2) {
365  jsdisp_t *arg_array = NULL;
366 
367  if(is_object_instance(argv[1])) {
368  arg_array = iface_to_jsdisp(get_object(argv[1]));
369  if(arg_array &&
370  (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
371  jsdisp_release(arg_array);
372  arg_array = NULL;
373  }
374  }
375 
376  if(arg_array) {
377  hres = array_to_args(ctx, arg_array, &cnt, &args);
378  jsdisp_release(arg_array);
379  }else {
380  FIXME("throw TypeError\n");
381  hres = E_FAIL;
382  }
383  }
384 
385  if(SUCCEEDED(hres)) {
386  if(function) {
387  hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, args, r);
388  }else {
389  jsval_t res;
390  hres = disp_call_value(ctx, jsthis->u.disp, this_obj, DISPATCH_METHOD, cnt, args, &res);
391  if(SUCCEEDED(hres)) {
392  if(r)
393  *r = res;
394  else
396  }
397  }
398  }
399 
400  if(this_obj)
401  IDispatch_Release(this_obj);
402  for(i=0; i < cnt; i++)
403  jsval_release(args[i]);
404  heap_free(args);
405  return hres;
406 }
Definition: jsval.h:54
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:552
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD flags
Definition: jscript.h:146
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
#define argv
Definition: mplay32.c:18
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:504
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
union vdisp_t::@425 u
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
IDispatch * disp
Definition: jscript.h:142
LONG HRESULT
Definition: typedefs.h:77
static FunctionInstance * function_this(vdisp_t *jsthis)
Definition: function.c:84
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *argc, jsval_t **ret)
Definition: function.c:307
GLbitfield flags
Definition: glext.h:7161
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1060
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1228
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:816
GLuint res
Definition: glext.h:9613
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
#define VDISP_JSDISP
Definition: jscript.h:150
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ Function_bind()

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

Definition at line 438 of file function.c.

440 {
441  FunctionInstance *function;
442  jsdisp_t *new_function;
443  HRESULT hres;
444 
445  TRACE("\n");
446 
447  if(!(function = function_this(jsthis)))
449 
450  if(argc < 1) {
451  FIXME("no this argument\n");
452  return E_NOTIMPL;
453  }
454 
455  if(!is_object_instance(argv[0]) || !get_object(argv[0])) {
456  FIXME("%s is not an object instance\n", debugstr_jsval(argv[0]));
457  return E_NOTIMPL;
458  }
459 
460  hres = create_bind_function(ctx, function, get_object(argv[0]), argc - 1, argv + 1, &new_function);
461  if(FAILED(hres))
462  return hres;
463 
464  if(r)
465  *r = jsval_obj(new_function);
466  else
467  jsdisp_release(new_function);
468  return S_OK;
469 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:552
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FunctionInstance * function_this(vdisp_t *jsthis)
Definition: function.c:84
static HRESULT create_bind_function(script_ctx_t *, FunctionInstance *, IDispatch *, unsigned, jsval_t *, jsdisp_t **r)
Definition: function.c:864
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

◆ Function_call()

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

Definition at line 408 of file function.c.

410 {
411  FunctionInstance *function;
412  IDispatch *this_obj = NULL;
413  unsigned cnt = 0;
414  HRESULT hres;
415 
416  TRACE("\n");
417 
418  if(!(function = function_this(jsthis)))
420 
421  if(argc) {
422  if(!is_undefined(argv[0]) && !is_null(argv[0])) {
423  hres = to_object(ctx, argv[0], &this_obj);
424  if(FAILED(hres))
425  return hres;
426  }
427 
428  cnt = argc-1;
429  }
430 
431  hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, argv + 1, r);
432 
433  if(this_obj)
434  IDispatch_Release(this_obj);
435  return hres;
436 }
static int argc
Definition: ServiceArgs.c:12
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:552
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
#define argv
Definition: mplay32.c:18
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FunctionInstance * function_this(vdisp_t *jsthis)
Definition: function.c:84
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
GLbitfield flags
Definition: glext.h:7161
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:816
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440

◆ Function_destructor()

static void Function_destructor ( jsdisp_t dispex)
static

Definition at line 527 of file function.c.

528 {
529  FunctionInstance *function = function_from_jsdisp(dispex);
530  function->vtbl->destructor(function);
531  heap_free(function);
532 }
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ function_from_jsdisp()

static FunctionInstance* function_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 74 of file function.c.

75 {
76  return CONTAINING_RECORD(jsdisp, FunctionInstance, dispex);
77 }
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 Function_destructor(), function_from_vdisp(), Function_get_arguments(), Function_get_length(), Function_get_value(), Function_invoke(), Function_value(), and setup_arguments_object().

◆ function_from_vdisp()

static FunctionInstance* function_from_vdisp ( vdisp_t vdisp)
inlinestatic

Definition at line 79 of file function.c.

80 {
81  return function_from_jsdisp(vdisp->u.jsdisp);
82 }
jsdisp_t * jsdisp
Definition: jscript.h:144
union vdisp_t::@425 u
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74

Referenced by function_this().

◆ Function_get_arguments()

static HRESULT Function_get_arguments ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 503 of file function.c.

504 {
505  FunctionInstance *function = function_from_jsdisp(jsthis);
506  call_frame_t *frame;
507  HRESULT hres;
508 
509  TRACE("\n");
510 
511  for(frame = ctx->call_ctx; frame; frame = frame->prev_frame) {
512  if(frame->function_instance == &function->dispex) {
513  if(!frame->arguments_obj) {
514  hres = setup_arguments_object(ctx, frame);
515  if(FAILED(hres))
516  return hres;
517  }
519  return S_OK;
520  }
521  }
522 
523  *r = jsval_null();
524  return S_OK;
525 }
jsdisp_t * arguments_obj
Definition: engine.h:233
HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame)
Definition: function.c:192
static jsval_t jsval_null(void)
Definition: jsval.h:130
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct _call_frame_t * call_ctx
Definition: jscript.h:415
jsdisp_t * function_instance
Definition: engine.h:231
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262
struct _call_frame_t * prev_frame
Definition: engine.h:245
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125

◆ Function_get_length()

static HRESULT Function_get_length ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 276 of file function.c.

277 {
278  TRACE("%p\n", jsthis);
279 
281  return S_OK;
282 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Function_get_value()

HRESULT Function_get_value ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)

Definition at line 487 of file function.c.

488 {
489  FunctionInstance *function = function_from_jsdisp(jsthis);
490  jsstr_t *str;
491  HRESULT hres;
492 
493  TRACE("\n");
494 
495  hres = function->vtbl->toString(function, &str);
496  if(FAILED(hres))
497  return hres;
498 
499  *r = jsval_string(str);
500  return S_OK;
501 }
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
#define S_OK
Definition: intsafe.h:59

◆ Function_invoke()

HRESULT Function_invoke ( jsdisp_t func_this,
IDispatch jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)

Definition at line 264 of file function.c.

265 {
266  FunctionInstance *function;
267 
268  TRACE("func %p this %p\n", func_this, jsthis);
269 
270  assert(is_class(func_this, JSCLASS_FUNCTION));
271  function = function_from_jsdisp(func_this);
272 
273  return function->vtbl->call(function->dispex.ctx, function, jsthis, flags, argc, argv, r);
274 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define argv
Definition: mplay32.c:18
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:504
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74

Referenced by invoke_prop_func(), and jsdisp_call_value().

◆ function_this()

static FunctionInstance* function_this ( vdisp_t jsthis)
inlinestatic

Definition at line 84 of file function.c.

85 {
86  return is_vclass(jsthis, JSCLASS_FUNCTION) ? function_from_vdisp(jsthis) : NULL;
87 }
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:509
static FunctionInstance * function_from_vdisp(vdisp_t *vdisp)
Definition: function.c:79

Referenced by Function_apply(), Function_bind(), Function_call(), and Function_toString().

◆ Function_toString()

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

Definition at line 284 of file function.c.

286 {
287  FunctionInstance *function;
288  jsstr_t *str;
289  HRESULT hres;
290 
291  TRACE("\n");
292 
293  if(!(function = function_this(jsthis)))
295 
296  hres = function->vtbl->toString(function, &str);
297  if(FAILED(hres))
298  return hres;
299 
300  if(r)
301  *r = jsval_string(str);
302  else
304  return S_OK;
305 }
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:552
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FunctionInstance * function_this(vdisp_t *jsthis)
Definition: function.c:84
#define S_OK
Definition: intsafe.h:59
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440

◆ Function_value()

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

Definition at line 471 of file function.c.

473 {
474  FunctionInstance *function;
475 
476  TRACE("\n");
477 
478  if(!is_vclass(jsthis, JSCLASS_FUNCTION)) {
479  ERR("dispex is not a function\n");
480  return E_FAIL;
481  }
482 
483  function = function_from_jsdisp(jsthis->u.jsdisp);
484  return function->vtbl->call(ctx, function, NULL, flags, argc, argv, r);
485 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
jsdisp_t * jsdisp
Definition: jscript.h:144
union vdisp_t::@425 u
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:509
GLbitfield flags
Definition: glext.h:7161
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
#define ERR(fmt,...)
Definition: debug.h:109

◆ FunctionConstr_value()

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

Definition at line 976 of file function.c.

978 {
979  HRESULT hres;
980 
981  TRACE("\n");
982 
983  switch(flags) {
984  case DISPATCH_METHOD:
985  case DISPATCH_CONSTRUCT: {
986  IDispatch *ret;
987 
988  hres = construct_function(ctx, argc, argv, &ret);
989  if(FAILED(hres))
990  return hres;
991 
992  *r = jsval_disp(ret);
993  break;
994  }
995  default:
996  FIXME("unimplemented flags %x\n", flags);
997  return E_NOTIMPL;
998  }
999 
1000  return S_OK;
1001 }
static int argc
Definition: ServiceArgs.c:12
static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *argv, IDispatch **ret)
Definition: function.c:894
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
int ret
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by init_function_constr().

◆ FunctionProt_value()

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

Definition at line 1003 of file function.c.

1005 {
1006  FIXME("\n");
1007  return E_NOTIMPL;
1008 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by init_function_constr().

◆ get_argument_ref()

static jsval_t* get_argument_ref ( ArgumentsInstance arguments,
unsigned  idx 
)
static

Definition at line 133 of file function.c.

134 {
135  if(arguments->buf)
136  return arguments->buf + idx;
137  if(arguments->frame->base_scope->frame || idx >= arguments->frame->function->param_cnt)
138  return arguments->jsdisp.ctx->stack + arguments->frame->arguments_off + idx;
139  return NULL;
140 }
unsigned arguments_off
Definition: engine.h:238
script_ctx_t * ctx
Definition: jscript.h:238
function_code_t * function
Definition: engine.h:243
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
call_frame_t * frame
Definition: function.c:68
struct _call_frame_t * frame
Definition: engine.h:206
unsigned param_cnt
Definition: engine.h:163
jsval_t * stack
Definition: jscript.h:431
scope_chain_t * base_scope
Definition: engine.h:226
jsval_t * buf
Definition: function.c:67
jsdisp_t jsdisp
Definition: function.c:65

Referenced by Arguments_idx_get(), and Arguments_idx_put().

◆ init_function_constr()

HRESULT init_function_constr ( script_ctx_t ctx,
jsdisp_t object_prototype 
)

Definition at line 1010 of file function.c.

1011 {
1012  NativeFunction *prot, *constr;
1013  HRESULT hres;
1014 
1015  static const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0};
1016 
1018  TRUE, object_prototype, (void**)&prot);
1019  if(FAILED(hres))
1020  return hres;
1021 
1022  prot->proc = FunctionProt_value;
1023  prot->name = prototypeW;
1024 
1026  TRUE, &prot->function.dispex, (void**)&constr);
1027  if(SUCCEEDED(hres)) {
1028  constr->proc = FunctionConstr_value;
1029  constr->name = FunctionW;
1031  if(SUCCEEDED(hres))
1032  hres = set_constructor_prop(ctx, &constr->function.dispex, &prot->function.dispex);
1033  if(FAILED(hres))
1034  jsdisp_release(&constr->function.dispex);
1035  }
1036  jsdisp_release(&prot->function.dispex);
1037  if(FAILED(hres))
1038  return hres;
1039 
1040  ctx->function_constr = &constr->function.dispex;
1041  return S_OK;
1042 }
#define TRUE
Definition: types.h:120
static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
Definition: function.c:566
FunctionInstance function
Definition: function.c:51
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
#define PROPF_CONSTR
Definition: jscript.h:98
builtin_invoke_t proc
Definition: function.c:52
static const WCHAR prototypeW[]
Definition: function.c:94
static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:976
static const builtin_info_t Function_info
Definition: function.c:543
HRESULT hres
Definition: protocol.c:465
const WCHAR * name
Definition: function.c:53
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static const function_vtbl_t NativeFunctionVtbl
Definition: function.c:645
jsdisp_t dispex
Definition: function.c:31
static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot)
Definition: function.c:678
#define S_OK
Definition: intsafe.h:59
jsdisp_t * function_constr
Definition: jscript.h:442
static const WCHAR FunctionW[]
Definition: global.c:46
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static const builtin_info_t FunctionInst_info
Definition: function.c:557
static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:1003

Referenced by init_constructors().

◆ InterpretedFunction_call()

static HRESULT InterpretedFunction_call ( script_ctx_t ctx,
FunctionInstance func,
IDispatch this_obj,
unsigned  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 706 of file function.c.

708 {
710  jsdisp_t *var_disp, *new_obj = NULL;
711  DWORD exec_flags = 0;
712  HRESULT hres;
713 
714  TRACE("%p\n", function);
715 
717  WARN("Script engine state does not allow running code.\n");
718  return E_UNEXPECTED;
719  }
720 
721  if(flags & DISPATCH_CONSTRUCT) {
722  hres = create_object(ctx, &function->function.dispex, &new_obj);
723  if(FAILED(hres))
724  return hres;
725  this_obj = to_disp(new_obj);
726  }
727 
729  exec_flags |= EXEC_RETURN_TO_INTERP;
730  if(flags & DISPATCH_CONSTRUCT)
731  exec_flags |= EXEC_CONSTRUCTOR;
732 
733  hres = create_dispex(ctx, NULL, NULL, &var_disp);
734  if(SUCCEEDED(hres))
735  hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj,
736  &function->function.dispex, var_disp, argc, argv, r);
737  if(new_obj)
738  jsdisp_release(new_obj);
739 
740  jsdisp_release(var_disp);
741  return hres;
742 }
GLenum func
Definition: glext.h:6028
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define argv
Definition: mplay32.c:18
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:250
#define EXEC_CONSTRUCTOR
Definition: engine.h:249
smooth NULL
Definition: ftsmooth.c:416
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope, IDispatch *this_obj, jsdisp_t *function_instance, jsdisp_t *variable_obj, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:2958
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
SCRIPTSTATE state
Definition: jscript.h:412
GLbitfield flags
Definition: glext.h:7161
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:115
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:957
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
#define E_UNEXPECTED
Definition: winerror.h:2456
HRESULT create_object(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:731
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ InterpretedFunction_destructor()

static void InterpretedFunction_destructor ( FunctionInstance func)
static

Definition at line 752 of file function.c.

753 {
755 
756  release_bytecode(function->code);
757  if(function->scope_chain)
758  scope_release(function->scope_chain);
759 }
GLenum func
Definition: glext.h:6028
void release_bytecode(bytecode_t *code)
Definition: compile.c:2226
void scope_release(scope_chain_t *scope)
Definition: engine.c:437

◆ InterpretedFunction_toString()

static HRESULT InterpretedFunction_toString ( FunctionInstance func,
jsstr_t **  ret 
)
static

Definition at line 744 of file function.c.

745 {
747 
748  *ret = jsstr_alloc_len(function->func_code->source, function->func_code->source_len);
749  return *ret ? S_OK : E_OUTOFMEMORY;
750 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
GLenum func
Definition: glext.h:6028
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
int ret
#define S_OK
Definition: intsafe.h:59

◆ NativeFunction_call()

static HRESULT NativeFunction_call ( script_ctx_t ctx,
FunctionInstance func,
IDispatch this_disp,
unsigned  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 595 of file function.c.

597 {
598  NativeFunction *function = (NativeFunction*)func;
599  vdisp_t vthis;
600  HRESULT hres;
601 
602  if(this_disp)
603  set_disp(&vthis, this_disp);
604  else if(ctx->host_global)
605  set_disp(&vthis, ctx->host_global);
606  else
607  set_jsdisp(&vthis, ctx->global);
608 
609  hres = function->proc(ctx, &vthis, flags & ~DISPATCH_JSCRIPT_INTERNAL_MASK, argc, argv, r);
610 
611  vdisp_release(&vthis);
612  return hres;
613 }
GLenum func
Definition: glext.h:6028
static int argc
Definition: ServiceArgs.c:12
static void set_disp(vdisp_t *vdisp, IDispatch *disp)
Definition: jscript.h:174
static void vdisp_release(vdisp_t *vdisp)
Definition: jscript.h:152
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
IDispatch * host_global
Definition: jscript.h:429
#define DISPATCH_JSCRIPT_INTERNAL_MASK
Definition: jscript.h:116
static void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
Definition: jscript.h:167
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
jsdisp_t * global
Definition: jscript.h:441

◆ NativeFunction_destructor()

static void NativeFunction_destructor ( FunctionInstance function)
static

Definition at line 641 of file function.c.

642 {
643 }

◆ NativeFunction_toString()

static HRESULT NativeFunction_toString ( FunctionInstance func,
jsstr_t **  ret 
)
static

Definition at line 615 of file function.c.

616 {
617  NativeFunction *function = (NativeFunction*)func;
618  DWORD name_len;
619  jsstr_t *str;
620  WCHAR *ptr;
621 
622  static const WCHAR native_prefixW[] = {'\n','f','u','n','c','t','i','o','n',' '};
623  static const WCHAR native_suffixW[] =
624  {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'};
625 
626  name_len = function->name ? lstrlenW(function->name) : 0;
627  str = jsstr_alloc_buf(ARRAY_SIZE(native_prefixW) + ARRAY_SIZE(native_suffixW) + name_len, &ptr);
628  if(!str)
629  return E_OUTOFMEMORY;
630 
631  memcpy(ptr, native_prefixW, sizeof(native_prefixW));
632  ptr += ARRAY_SIZE(native_prefixW);
633  memcpy(ptr, function->name, name_len*sizeof(WCHAR));
634  ptr += name_len;
635  memcpy(ptr, native_suffixW, sizeof(native_suffixW));
636 
637  *ret = str;
638  return S_OK;
639 }
GLenum func
Definition: glext.h:6028
Definition: jsstr.h:39
#define lstrlenW
Definition: compat.h:415
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69

◆ set_constructor_prop()

static HRESULT set_constructor_prop ( script_ctx_t ctx,
jsdisp_t constr,
jsdisp_t prot 
)
static

Definition at line 678 of file function.c.

679 {
680  static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r',0};
681 
683  jsval_obj(constr));
684 }
#define PROPF_WRITABLE
Definition: jscript.h:101
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
__wchar_t WCHAR
Definition: xmlstorage.h:180
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define PROPF_CONFIGURABLE
Definition: jscript.h:102

Referenced by create_builtin_constructor(), create_source_function(), and init_function_constr().

◆ setup_arguments_object()

HRESULT setup_arguments_object ( script_ctx_t ctx,
call_frame_t frame 
)

Definition at line 192 of file function.c.

193 {
195  HRESULT hres;
196 
197  static const WCHAR caleeW[] = {'c','a','l','l','e','e',0};
198 
199  args = heap_alloc_zero(sizeof(*args));
200  if(!args)
201  return E_OUTOFMEMORY;
202 
204  if(FAILED(hres)) {
205  heap_free(args);
206  return hres;
207  }
208 
210  args->argc = frame->argc;
211  args->frame = frame;
212 
214  jsval_number(args->argc));
215  if(SUCCEEDED(hres))
217  jsval_obj(&args->function->function.dispex));
218  if(SUCCEEDED(hres))
220  if(FAILED(hres)) {
221  jsdisp_release(&args->jsdisp);
222  return hres;
223  }
224 
225  frame->arguments_obj = &args->jsdisp;
226  return S_OK;
227 }
#define PROPF_WRITABLE
Definition: jscript.h:101
jsdisp_t * arguments_obj
Definition: engine.h:233
jsdisp_t * jsobj
Definition: engine.h:204
static const WCHAR lengthW[]
Definition: function.c:96
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
jsdisp_t * function_instance
Definition: engine.h:231
Definition: match.c:390
static const builtin_info_t Arguments_info
Definition: function.c:181
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262
jsdisp_t * object_constr
Definition: jscript.h:456
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
scope_chain_t * base_scope
Definition: engine.h:226
#define S_OK
Definition: intsafe.h:59
static const WCHAR argumentsW[]
Definition: function.c:101
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT jsdisp_propput(jsdisp_t *obj, const WCHAR *name, DWORD flags, jsval_t val)
Definition: dispex.c:1332
unsigned argc
Definition: engine.h:236
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1030
#define args
Definition: format.c:66
#define PROPF_CONFIGURABLE
Definition: jscript.h:102
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by detach_variable_object(), and Function_get_arguments().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ applyW

const WCHAR applyW[] = {'a','p','p','l','y',0}
static

Definition at line 98 of file function.c.

◆ Arguments_info

const builtin_info_t Arguments_info
static
Initial value:
= {
0, NULL,
}
static void Arguments_destructor(jsdisp_t *jsdisp)
Definition: function.c:110
static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:103
smooth NULL
Definition: ftsmooth.c:416
static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
Definition: function.c:157
static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
Definition: function.c:142
static unsigned Arguments_idx_length(jsdisp_t *jsdisp)
Definition: function.c:127

Definition at line 181 of file function.c.

Referenced by setup_arguments_object().

◆ argumentsW

const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}
static

Definition at line 101 of file function.c.

Referenced by detach_arguments_object(), identifier_eval(), and setup_arguments_object().

◆ BindFunctionVtbl

const function_vtbl_t BindFunctionVtbl
static
Initial value:
= {
}
static HRESULT BindFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:806
static HRESULT BindFunction_toString(FunctionInstance *function, jsstr_t **ret)
Definition: function.c:834
static void BindFunction_destructor(FunctionInstance *func)
Definition: function.c:845

Definition at line 858 of file function.c.

Referenced by create_bind_function().

◆ bindW

const WCHAR bindW[] = {'b','i','n','d',0}
static

Definition at line 99 of file function.c.

◆ callW

const WCHAR callW[] = {'c','a','l','l',0}
static

Definition at line 100 of file function.c.

◆ Function_info

const builtin_info_t Function_info
static
Initial value:
= {
}
static void Function_destructor(jsdisp_t *dispex)
Definition: function.c:527
static const builtin_prop_t Function_props[]
Definition: function.c:534
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:315
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 543 of file function.c.

Referenced by init_function_constr().

◆ Function_props

const builtin_prop_t Function_props[]
static
Initial value:
= {
}
#define PROPF_ES5
Definition: jscript.h:108
static const WCHAR bindW[]
Definition: function.c:99
static const WCHAR lengthW[]
Definition: function.c:96
static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: function.c:503
static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:284
static const WCHAR callW[]
Definition: function.c:100
static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:408
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR applyW[]
Definition: function.c:98
static const WCHAR argumentsW[]
Definition: function.c:101
static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:438
#define PROPF_METHOD
Definition: jscript.h:97
static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: function.c:276
static const WCHAR toStringW[]
Definition: function.c:97
static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:343

Definition at line 534 of file function.c.

◆ FunctionInst_info

const builtin_info_t FunctionInst_info
static
Initial value:
= {
}
static void Function_destructor(jsdisp_t *dispex)
Definition: function.c:527
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:315
static const builtin_prop_t FunctionInst_props[]
Definition: function.c:552
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 557 of file function.c.

Referenced by create_function(), and init_function_constr().

◆ FunctionInst_props

const builtin_prop_t FunctionInst_props[]
static
Initial value:
= {
}
static const WCHAR lengthW[]
Definition: function.c:96
static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: function.c:503
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR argumentsW[]
Definition: function.c:101
static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: function.c:276

Definition at line 552 of file function.c.

◆ InterpretedFunctionVtbl

const function_vtbl_t InterpretedFunctionVtbl
static
Initial value:
= {
}
static HRESULT InterpretedFunction_toString(FunctionInstance *func, jsstr_t **ret)
Definition: function.c:744
static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:706
static void InterpretedFunction_destructor(FunctionInstance *func)
Definition: function.c:752

Definition at line 761 of file function.c.

Referenced by create_source_function().

◆ lengthW

const WCHAR lengthW[] = {'l','e','n','g','t','h',0}
static

Definition at line 96 of file function.c.

Referenced by array_to_args(), create_builtin_function(), and setup_arguments_object().

◆ NativeFunctionVtbl

const function_vtbl_t NativeFunctionVtbl
static
Initial value:
= {
}
static void NativeFunction_destructor(FunctionInstance *function)
Definition: function.c:641
static HRESULT NativeFunction_toString(FunctionInstance *func, jsstr_t **ret)
Definition: function.c:615
static HRESULT NativeFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_disp, unsigned flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: function.c:595

Definition at line 645 of file function.c.

Referenced by create_builtin_function(), and init_function_constr().

◆ prototypeW

const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0}
static

◆ toStringW

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

Definition at line 97 of file function.c.