https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bcea8c65d05c0a699765f…
commit bcea8c65d05c0a699765fc8c0a8be42f1cb394e5
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Mon Jun 4 03:52:36 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Mon Jun 4 03:52:36 2018 +0100
[VBSCRIPT] Sync with Wine Staging 3.9. CORE-14656
---
dll/win32/vbscript/compile.c | 15 ++----
dll/win32/vbscript/interp.c | 39 +++++++--------
dll/win32/vbscript/vbscript.c | 109 ++++++++++++++++++++++++++++++++++++++++++
dll/win32/vbscript/vbscript.h | 3 ++
media/doc/README.WINE | 2 +-
5 files changed, 132 insertions(+), 36 deletions(-)
diff --git a/dll/win32/vbscript/compile.c b/dll/win32/vbscript/compile.c
index c8189d6d96..302804f4c2 100644
--- a/dll/win32/vbscript/compile.c
+++ b/dll/win32/vbscript/compile.c
@@ -1746,6 +1746,8 @@ void release_vbscode(vbscode_t *code)
for(i=0; i < code->bstr_cnt; i++)
SysFreeString(code->bstr_pool[i]);
+ if(code->context)
+ IDispatch_Release(code->context);
heap_pool_free(&code->heap);
heap_free(code->bstr_pool);
@@ -1758,7 +1760,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR
*source)
{
vbscode_t *ret;
- ret = heap_alloc(sizeof(*ret));
+ ret = heap_alloc_zero(sizeof(*ret));
if(!ret)
return NULL;
@@ -1780,19 +1782,8 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR
*source)
ret->option_explicit = ctx->parser.option_explicit;
- ret->bstr_pool = NULL;
- ret->bstr_pool_size = 0;
- ret->bstr_cnt = 0;
- ret->pending_exec = FALSE;
-
ret->main_code.type = FUNC_GLOBAL;
- ret->main_code.name = NULL;
ret->main_code.code_ctx = ret;
- ret->main_code.vars = NULL;
- ret->main_code.var_cnt = 0;
- ret->main_code.array_cnt = 0;
- ret->main_code.arg_cnt = 0;
- ret->main_code.args = NULL;
list_init(&ret->entry);
return ret;
diff --git a/dll/win32/vbscript/interp.c b/dll/win32/vbscript/interp.c
index 9ec329924c..b46bd01c0f 100644
--- a/dll/win32/vbscript/interp.c
+++ b/dll/win32/vbscript/interp.c
@@ -99,6 +99,7 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name,
vbdisp_invoke_type_
{
named_item_t *item;
function_t *func;
+ IDispatch *disp;
unsigned i;
DISPID id;
HRESULT hres;
@@ -153,6 +154,16 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name,
vbdisp_invoke_type_
}
}
+ if(ctx->func->code_ctx->context) {
+ hres = disp_get_id(ctx->func->code_ctx->context, name, invoke_type,
TRUE, &id);
+ if(SUCCEEDED(hres)) {
+ ref->type = REF_DISP;
+ ref->u.d.disp = ctx->func->code_ctx->context;
+ ref->u.d.id = id;
+ return S_OK;
+ }
+ }
+
if(ctx->func->type != FUNC_GLOBAL &&
lookup_dynamic_vars(ctx->script->global_vars, name, ref))
return S_OK;
@@ -178,29 +189,11 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name,
vbdisp_invoke_type_
return S_OK;
}
- LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry)
{
- if((item->flags & SCRIPTITEM_ISVISIBLE) &&
!strcmpiW(item->name, name)) {
- if(!item->disp) {
- IUnknown *unk;
-
- hres = IActiveScriptSite_GetItemInfo(ctx->script->site,
item->name, SCRIPTINFO_IUNKNOWN, &unk, NULL);
- if(FAILED(hres)) {
- WARN("GetItemInfo failed: %08x\n", hres);
- continue;
- }
-
- hres = IUnknown_QueryInterface(unk, &IID_IDispatch,
(void**)&item->disp);
- IUnknown_Release(unk);
- if(FAILED(hres)) {
- WARN("object does not implement IDispatch\n");
- continue;
- }
- }
-
- ref->type = REF_OBJ;
- ref->u.obj = item->disp;
- return S_OK;
- }
+ disp = lookup_named_item(ctx->script, name, SCRIPTITEM_ISVISIBLE);
+ if(disp) {
+ ref->type = REF_OBJ;
+ ref->u.obj = disp;
+ return S_OK;
}
LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry)
{
diff --git a/dll/win32/vbscript/vbscript.c b/dll/win32/vbscript/vbscript.c
index 645068e347..06a855b2b3 100644
--- a/dll/win32/vbscript/vbscript.c
+++ b/dll/win32/vbscript/vbscript.c
@@ -29,12 +29,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
#ifdef _WIN64
#define CTXARG_T DWORDLONG
+#define IActiveScriptDebugVtbl IActiveScriptDebug64Vtbl
#define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
#else
#define CTXARG_T DWORD
+#define IActiveScriptDebugVtbl IActiveScriptDebug32Vtbl
#define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
#define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
@@ -42,6 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
struct VBScript {
IActiveScript IActiveScript_iface;
+ IActiveScriptDebug IActiveScriptDebug_iface;
IActiveScriptParse IActiveScriptParse_iface;
IActiveScriptParseProcedure2 IActiveScriptParseProcedure2_iface;
IObjectSafety IObjectSafety_iface;
@@ -96,6 +99,38 @@ static void exec_queued_code(script_ctx_t *ctx)
}
}
+IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flags)
+{
+ named_item_t *item;
+ HRESULT hres;
+
+ LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) {
+ if((item->flags & flags) == flags && !strcmpiW(item->name,
name)) {
+ if(!item->disp) {
+ IUnknown *unk;
+
+ hres = IActiveScriptSite_GetItemInfo(ctx->site, item->name,
+ SCRIPTINFO_IUNKNOWN, &unk,
NULL);
+ if(FAILED(hres)) {
+ WARN("GetItemInfo failed: %08x\n", hres);
+ continue;
+ }
+
+ hres = IUnknown_QueryInterface(unk, &IID_IDispatch,
(void**)&item->disp);
+ IUnknown_Release(unk);
+ if(FAILED(hres)) {
+ WARN("object does not implement IDispatch\n");
+ continue;
+ }
+ }
+
+ return item->disp;
+ }
+ }
+
+ return NULL;
+}
+
static HRESULT set_ctx_site(VBScript *This)
{
HRESULT hres;
@@ -235,6 +270,9 @@ static HRESULT WINAPI VBScript_QueryInterface(IActiveScript *iface,
REFIID riid,
}else if(IsEqualGUID(riid, &IID_IActiveScript)) {
TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
*ppv = &This->IActiveScript_iface;
+ }else if(IsEqualGUID(riid, &IID_IActiveScriptDebug)) {
+ TRACE("(%p)->(IID_IActiveScriptDebug %p)\n", This, ppv);
+ *ppv = &This->IActiveScriptDebug_iface;
}else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
*ppv = &This->IActiveScriptParse_iface;
@@ -532,6 +570,64 @@ static const IActiveScriptVtbl VBScriptVtbl = {
VBScript_Clone
};
+static inline VBScript *impl_from_IActiveScriptDebug(IActiveScriptDebug *iface)
+{
+ return CONTAINING_RECORD(iface, VBScript, IActiveScriptDebug_iface);
+}
+
+static HRESULT WINAPI VBScriptDebug_QueryInterface(IActiveScriptDebug *iface, REFIID
riid, void **ppv)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ return IActiveScript_QueryInterface(&This->IActiveScript_iface, riid, ppv);
+}
+
+static ULONG WINAPI VBScriptDebug_AddRef(IActiveScriptDebug *iface)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ return IActiveScript_AddRef(&This->IActiveScript_iface);
+}
+
+static ULONG WINAPI VBScriptDebug_Release(IActiveScriptDebug *iface)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ return IActiveScript_Release(&This->IActiveScript_iface);
+}
+
+static HRESULT WINAPI VBScriptDebug_GetScriptTextAttributes(IActiveScriptDebug *iface,
+ LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR
*attr)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ FIXME("(%p)->(%s %u %s %#x %p)\n", This, debugstr_w(code), len,
+ debugstr_w(delimiter), flags, attr);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI VBScriptDebug_GetScriptletTextAttributes(IActiveScriptDebug
*iface,
+ LPCOLESTR code, ULONG len, LPCOLESTR delimiter, DWORD flags, SOURCE_TEXT_ATTR
*attr)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ FIXME("(%p)->(%s %u %s %#x %p)\n", This, debugstr_w(code), len,
+ debugstr_w(delimiter), flags, attr);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI VBScriptDebug_EnumCodeContextsOfPosition(IActiveScriptDebug
*iface,
+ CTXARG_T source, ULONG offset, ULONG len, IEnumDebugCodeContexts **ret)
+{
+ VBScript *This = impl_from_IActiveScriptDebug(iface);
+ FIXME("(%p)->(%s %u %u %p)\n", This, wine_dbgstr_longlong(source),
offset, len, ret);
+ return E_NOTIMPL;
+}
+
+static const IActiveScriptDebugVtbl VBScriptDebugVtbl = {
+ VBScriptDebug_QueryInterface,
+ VBScriptDebug_AddRef,
+ VBScriptDebug_Release,
+ VBScriptDebug_GetScriptTextAttributes,
+ VBScriptDebug_GetScriptletTextAttributes,
+ VBScriptDebug_EnumCodeContextsOfPosition,
+};
+
static inline VBScript *impl_from_IActiveScriptParse(IActiveScriptParse *iface)
{
return CONTAINING_RECORD(iface, VBScript, IActiveScriptParse_iface);
@@ -604,6 +700,7 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse
*iface,
DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
VBScript *This = impl_from_IActiveScriptParse(iface);
+ IDispatch *context = NULL;
vbscode_t *code;
HRESULT hres;
@@ -614,10 +711,21 @@ static HRESULT WINAPI
VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(This->thread_id != GetCurrentThreadId() || This->state ==
SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
+ if(pstrItemName) {
+ context = lookup_named_item(This->ctx, pstrItemName, 0);
+ if(!context) {
+ WARN("Inknown context %s\n", debugstr_w(pstrItemName));
+ return E_INVALIDARG;
+ }
+ }
+
hres = compile_script(This->ctx, pstrCode, pstrDelimiter, &code);
if(FAILED(hres))
return hres;
+ if(context)
+ IDispatch_AddRef(code->context = context);
+
if(!is_started(This)) {
code->pending_exec = TRUE;
return S_OK;
@@ -762,6 +870,7 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface,
IUnknown *pU
return E_OUTOFMEMORY;
ret->IActiveScript_iface.lpVtbl = &VBScriptVtbl;
+ ret->IActiveScriptDebug_iface.lpVtbl = &VBScriptDebugVtbl;
ret->IActiveScriptParse_iface.lpVtbl = &VBScriptParseVtbl;
ret->IActiveScriptParseProcedure2_iface.lpVtbl = &VBScriptParseProcedureVtbl;
ret->IObjectSafety_iface.lpVtbl = &VBScriptSafetyVtbl;
diff --git a/dll/win32/vbscript/vbscript.h b/dll/win32/vbscript/vbscript.h
index 94fdefe277..5558dc3e87 100644
--- a/dll/win32/vbscript/vbscript.h
+++ b/dll/win32/vbscript/vbscript.h
@@ -27,6 +27,7 @@
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
+#include "activdbg.h"
#ifdef __REACTOS__
#include <initguid.h>
@@ -347,6 +348,7 @@ struct _vbscode_t {
BOOL pending_exec;
function_t main_code;
+ IDispatch *context;
BSTR *bstr_pool;
unsigned bstr_pool_size;
@@ -360,6 +362,7 @@ void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,vbscode_t**)
DECLSPEC_HIDDEN;
HRESULT exec_script(script_ctx_t*,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;
typedef struct {
UINT16 len;
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index 20f1cfb5a2..56945ecaf9 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -191,7 +191,7 @@ reactos/dll/win32/url # Synced to WineStaging-3.3
reactos/dll/win32/urlmon # Synced to WineStaging-3.9
reactos/dll/win32/usp10 # Synced to WineStaging-3.9
reactos/dll/win32/uxtheme # Forked
-reactos/dll/win32/vbscript # Synced to WineStaging-3.3
+reactos/dll/win32/vbscript # Synced to WineStaging-3.9
reactos/dll/win32/version # Synced to WineStaging-3.3
reactos/dll/win32/vssapi # Synced to WineStaging-2.9
reactos/dll/win32/wbemdisp # Synced to WineStaging-3.3