vbscript: Added class_initializer support.
This commit is contained in:
parent
888ce00531
commit
28bddf8dd1
@ -893,6 +893,8 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
static const WCHAR class_initializeW[] = {'c','l','a','s','s','_','i','n','i','t','i','a','l','i','z','e',0};
|
||||||
|
|
||||||
if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name)
|
if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name)
|
||||||
|| lookup_class_name(ctx, class_decl->name)) {
|
|| lookup_class_name(ctx, class_decl->name)) {
|
||||||
FIXME("%s: redefinition\n", debugstr_w(class_decl->name));
|
FIXME("%s: redefinition\n", debugstr_w(class_decl->name));
|
||||||
@ -909,6 +911,7 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
|||||||
|
|
||||||
class_desc->func_cnt = 1; /* always allocate slot for default getter */
|
class_desc->func_cnt = 1; /* always allocate slot for default getter */
|
||||||
class_desc->prop_cnt = 0;
|
class_desc->prop_cnt = 0;
|
||||||
|
class_desc->class_initialize_id = 0;
|
||||||
|
|
||||||
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) {
|
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) {
|
||||||
for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) {
|
for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) {
|
||||||
@ -932,6 +935,15 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!strcmpiW(class_initializeW, func_decl->name)) {
|
||||||
|
if(func_decl->type != FUNC_SUB) {
|
||||||
|
FIXME("class initializer is not sub\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
class_desc->class_initialize_id = i;
|
||||||
|
}
|
||||||
|
|
||||||
hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + (func_prop_decl ? 0 : i));
|
hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + (func_prop_decl ? 0 : i));
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
@ -465,6 +465,7 @@ obj.publicProp = 3
|
|||||||
Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
|
Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
|
||||||
obj.publicProp() = 3
|
obj.publicProp() = 3
|
||||||
|
|
||||||
|
Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
|
||||||
Call obj.setPrivateProp(6)
|
Call obj.setPrivateProp(6)
|
||||||
Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
|
Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
|
||||||
|
|
||||||
@ -485,6 +486,9 @@ funcCalled = ""
|
|||||||
Call ok(obj = 3, "(x = obj) = " & obj)
|
Call ok(obj = 3, "(x = obj) = " & obj)
|
||||||
Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
|
Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
|
||||||
|
|
||||||
|
Call obj.Class_Initialize
|
||||||
|
Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
|
||||||
|
|
||||||
x = (New testclass).publicProp
|
x = (New testclass).publicProp
|
||||||
|
|
||||||
reportSuccess()
|
reportSuccess()
|
||||||
|
@ -375,6 +375,18 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
|
|||||||
vbdisp->ref = 1;
|
vbdisp->ref = 1;
|
||||||
vbdisp->desc = desc;
|
vbdisp->desc = desc;
|
||||||
|
|
||||||
|
if(desc->class_initialize_id) {
|
||||||
|
DISPPARAMS dp = {0};
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = exec_script(desc->ctx, desc->funcs[desc->class_initialize_id].entries[VBDISP_CALLGET],
|
||||||
|
(IDispatch*)&vbdisp->IDispatchEx_iface, &dp, NULL);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
IDispatchEx_Release(&vbdisp->IDispatchEx_iface);
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ret = vbdisp;
|
*ret = vbdisp;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ typedef struct {
|
|||||||
typedef struct _class_desc_t {
|
typedef struct _class_desc_t {
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
script_ctx_t *ctx;
|
script_ctx_t *ctx;
|
||||||
|
unsigned class_initialize_id;
|
||||||
unsigned func_cnt;
|
unsigned func_cnt;
|
||||||
vbdisp_funcprop_desc_t *funcs;
|
vbdisp_funcprop_desc_t *funcs;
|
||||||
unsigned prop_cnt;
|
unsigned prop_cnt;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user