Module: wine Branch: master Commit: 0bd508db2f7e05d0317d3ab0e8eeb81219aa5572 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0bd508db2f7e05d0317d3ab0e8...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 10 21:05:14 2008 +0200
jscript: Added this expression implementation.
---
dlls/jscript/engine.c | 16 +++++++++++++--- dlls/jscript/engine.h | 3 ++- dlls/jscript/jscript.c | 2 +- dlls/jscript/tests/lang.js | 1 + 4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index c15b05b..5119bb7 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -132,7 +132,7 @@ void scope_release(scope_chain_t *scope) heap_free(scope); }
-HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret) +HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret) { exec_ctx_t *ctx;
@@ -140,6 +140,9 @@ HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t * if(!ctx) return E_OUTOFMEMORY;
+ IDispatch_AddRef(this_obj); + ctx->this_obj = this_obj; + IDispatchEx_AddRef(_IDispatchEx_(var_disp)); ctx->var_disp = var_disp;
@@ -161,6 +164,8 @@ void exec_release(exec_ctx_t *ctx) scope_release(ctx->scope_chain); if(ctx->var_disp) IDispatchEx_Release(_IDispatchEx_(ctx->var_disp)); + if(ctx->this_obj) + IDispatch_Release(ctx->this_obj); heap_free(ctx); }
@@ -816,8 +821,13 @@ HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags,
HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + + ret->type = EXPRVAL_VARIANT; + V_VT(&ret->u.var) = VT_DISPATCH; + V_DISPATCH(&ret->u.var) = ctx->this_obj; + IDispatch_AddRef(ctx->this_obj); + return S_OK; }
/* ECMA-262 3rd Edition 10.1.4 */ diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index c8f41b0..57a68c2 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -76,6 +76,7 @@ struct _exec_ctx_t { parser_ctx_t *parser; scope_chain_t *scope_chain; DispatchEx *var_disp; + IDispatch *this_obj; };
static inline void exec_addref(exec_ctx_t *ctx) @@ -84,7 +85,7 @@ static inline void exec_addref(exec_ctx_t *ctx) }
void exec_release(exec_ctx_t*); -HRESULT create_exec_ctx(DispatchEx*,scope_chain_t*,exec_ctx_t**); +HRESULT create_exec_ctx(IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**); HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*);
typedef struct _statement_t statement_t; diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index a104aa9..5646cb8 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -80,7 +80,7 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) VARIANT var; HRESULT hres;
- hres = create_exec_ctx(This->ctx->script_disp, NULL, &exec_ctx); + hres = create_exec_ctx((IDispatch*)_IDispatchEx_(This->ctx->script_disp), This->ctx->script_disp, NULL, &exec_ctx); if(FAILED(hres)) return hres;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 088468a..4c26c2f 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -68,5 +68,6 @@ ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not objec ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function"); ok(typeof(String) === "function", "typeof(String) is not function"); ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function"); +ok(typeof(this) === "object", "typeof(this) is not object");
reportSuccess();