Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7e109410
Commit
7e109410
authored
Mar 16, 2018
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vbscript: Added support for script context in ParseScriptText.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
aa5b68ac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
12 deletions
+80
-12
compile.c
dlls/vbscript/compile.c
+3
-12
interp.c
dlls/vbscript/interp.c
+10
-0
run.c
dlls/vbscript/tests/run.c
+54
-0
vbscript.c
dlls/vbscript/vbscript.c
+12
-0
vbscript.h
dlls/vbscript/vbscript.h
+1
-0
No files found.
dlls/vbscript/compile.c
View file @
7e109410
...
...
@@ -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
;
...
...
dlls/vbscript/interp.c
View file @
7e109410
...
...
@@ -154,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
;
...
...
dlls/vbscript/tests/run.c
View file @
7e109410
...
...
@@ -1804,6 +1804,59 @@ static HRESULT parse_script_ar(const char *src)
return
hres
;
}
static
void
test_parse_context
(
void
)
{
IActiveScriptParse
*
parser
;
IActiveScript
*
engine
;
BSTR
str
;
HRESULT
hres
;
static
const
WCHAR
xW
[]
=
{
'x'
,
0
};
static
const
WCHAR
yW
[]
=
{
'y'
,
0
};
engine
=
create_and_init_script
(
0
);
if
(
!
engine
)
return
;
hres
=
IActiveScript_QueryInterface
(
engine
,
&
IID_IActiveScriptParse
,
(
void
**
)
&
parser
);
ok
(
hres
==
S_OK
,
"Could not get IActiveScriptParse: %08x
\n
"
,
hres
);
/* unknown identifier context is not a valid argument */
str
=
a2bstr
(
"Call reportSuccess()
\n
"
);
hres
=
IActiveScriptParse_ParseScriptText
(
parser
,
str
,
yW
,
NULL
,
NULL
,
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
hres
==
E_INVALIDARG
,
"ParseScriptText failed: %08x
\n
"
,
hres
);
SysFreeString
(
str
);
str
=
a2bstr
(
"class Cl
\n
"
" Public Sub ClMethod
\n
"
" Call reportSuccess()
\n
"
" End Sub
\n
"
"End Class
\n
"
"Dim x
\n
"
"set x = new Cl
\n
"
);
hres
=
IActiveScriptParse_ParseScriptText
(
parser
,
str
,
NULL
,
NULL
,
NULL
,
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"ParseScriptText failed: %08x
\n
"
,
hres
);
SysFreeString
(
str
);
/* known global variable is not a valid context */
str
=
a2bstr
(
"Call reportSuccess()
\n
"
);
hres
=
IActiveScriptParse_ParseScriptText
(
parser
,
str
,
xW
,
NULL
,
NULL
,
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
hres
==
E_INVALIDARG
,
"ParseScriptText failed: %08x
\n
"
,
hres
);
SysFreeString
(
str
);
SET_EXPECT
(
global_success_d
);
SET_EXPECT
(
global_success_i
);
str
=
a2bstr
(
"Call reportSuccess()
\n
"
);
hres
=
IActiveScriptParse_ParseScriptText
(
parser
,
str
,
testW
,
NULL
,
NULL
,
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
hres
==
S_OK
,
"ParseScriptText failed: %08x
\n
"
,
hres
);
SysFreeString
(
str
);
CHECK_CALLED
(
global_success_d
);
CHECK_CALLED
(
global_success_i
);
IActiveScriptParse_Release
(
parser
);
close_script
(
engine
);
}
static
void
parse_script_a
(
const
char
*
src
)
{
parse_script_af
(
SCRIPTITEM_GLOBALMEMBERS
,
src
);
...
...
@@ -2334,6 +2387,7 @@ static void run_tests(void)
test_procedures
();
test_gc
();
test_msgbox
();
test_parse_context
();
}
static
BOOL
check_vbscript
(
void
)
...
...
dlls/vbscript/vbscript.c
View file @
7e109410
...
...
@@ -636,6 +636,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
;
...
...
@@ -646,10 +647,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
;
...
...
dlls/vbscript/vbscript.h
View file @
7e109410
...
...
@@ -342,6 +342,7 @@ struct _vbscode_t {
BOOL
pending_exec
;
function_t
main_code
;
IDispatch
*
context
;
BSTR
*
bstr_pool
;
unsigned
bstr_pool_size
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment