vbscript: Create class description for procedure object in compiler.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be253c1dc9
commit
581a8adf1f
|
@ -1926,3 +1926,29 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
|||
*ret = code;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD flags, class_desc_t **ret)
|
||||
{
|
||||
class_desc_t *desc;
|
||||
vbscode_t *code;
|
||||
HRESULT hres;
|
||||
|
||||
hres = compile_script(script, src, delimiter, flags, &code);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(!(desc = compiler_alloc_zero(code, sizeof(*desc))))
|
||||
return E_OUTOFMEMORY;
|
||||
if(!(desc->funcs = compiler_alloc_zero(code, sizeof(*desc->funcs))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
desc->ctx = script;
|
||||
desc->func_cnt = 1;
|
||||
desc->funcs->entries[VBDISP_CALLGET] = &code->main_code;
|
||||
|
||||
desc->next = script->procs;
|
||||
script->procs = desc;
|
||||
|
||||
*ret = desc;
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -627,45 +627,6 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT Procedure_invoke(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
||||
{
|
||||
script_ctx_t *ctx = This->desc->ctx;
|
||||
TRACE("\n");
|
||||
return exec_script(ctx, TRUE, This->desc->value_func, NULL, NULL, res);
|
||||
}
|
||||
|
||||
static const builtin_prop_t procedure_props[] = {
|
||||
{DISPID_VALUE, Procedure_invoke, 0}
|
||||
};
|
||||
|
||||
HRESULT create_procedure_disp(script_ctx_t *ctx, vbscode_t *code, IDispatch **ret)
|
||||
{
|
||||
class_desc_t *desc;
|
||||
vbdisp_t *vbdisp;
|
||||
HRESULT hres;
|
||||
|
||||
desc = heap_alloc_zero(sizeof(*desc));
|
||||
if(!desc)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
desc->ctx = ctx;
|
||||
desc->builtin_prop_cnt = ARRAY_SIZE(procedure_props);
|
||||
desc->builtin_props = procedure_props;
|
||||
desc->value_func = &code->main_code;
|
||||
|
||||
hres = create_vbdisp(desc, &vbdisp);
|
||||
if(FAILED(hres)) {
|
||||
heap_free(desc);
|
||||
return hres;
|
||||
}
|
||||
|
||||
desc->next = ctx->procs;
|
||||
ctx->procs = desc;
|
||||
|
||||
*ret = (IDispatch*)&vbdisp->IDispatchEx_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct _ident_map_t {
|
||||
const WCHAR *name;
|
||||
BOOL is_var;
|
||||
|
|
|
@ -884,7 +884,8 @@ static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptPar
|
|||
CTXARG_T dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
|
||||
{
|
||||
VBScript *This = impl_from_IActiveScriptParseProcedure2(iface);
|
||||
vbscode_t *code;
|
||||
class_desc_t *desc;
|
||||
vbdisp_t *vbdisp;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("(%p)->(%s %s %s %s %p %s %s %u %x %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrFormalParams),
|
||||
|
@ -894,11 +895,16 @@ static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptPar
|
|||
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
hres = compile_script(This->ctx, pstrCode, pstrDelimiter, dwFlags, &code);
|
||||
hres = compile_procedure(This->ctx, pstrCode, pstrDelimiter, dwFlags, &desc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
return create_procedure_disp(This->ctx, code, ppdisp);
|
||||
hres = create_vbdisp(desc, &vbdisp);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
*ppdisp = (IDispatch*)&vbdisp->IDispatchEx_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IActiveScriptParseProcedure2Vtbl VBScriptParseProcedureVtbl = {
|
||||
|
|
|
@ -154,7 +154,6 @@ HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*) DECLSPEC
|
|||
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,WORD,DISPPARAMS*) DECLSPEC_HIDDEN;
|
||||
HRESULT get_disp_value(script_ctx_t*,IDispatch*,VARIANT*) DECLSPEC_HIDDEN;
|
||||
void collect_objects(script_ctx_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT create_procedure_disp(script_ctx_t*,vbscode_t*,IDispatch**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_script_disp(script_ctx_t*,ScriptDisp**) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT to_int(VARIANT*,int*) DECLSPEC_HIDDEN;
|
||||
|
@ -356,6 +355,7 @@ struct _vbscode_t {
|
|||
|
||||
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,vbscode_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,class_desc_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
||||
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
||||
IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue