import jscript.dll from wine 1.1.4

svn path=/trunk/; revision=36121
This commit is contained in:
Christoph von Wittich 2008-09-10 11:46:31 +00:00
parent d650c233dc
commit 6196f51306
20 changed files with 10004 additions and 0 deletions

View file

@ -79,6 +79,7 @@
<property name="BASEADDRESS_SCHANNEL" value="0x6e360000" />
<property name="BASEADDRESS_COMPSTUI" value="0x6ec10000" />
<property name="BASEADDRESS_CLB" value="0x6f2b0000" />
<property name="BASEADDRESS_JSCRIPT" value="0x6fe80000" />
<property name="BASEADDRESS_FONTEXT" value="0x6f7b0000" />
<property name="BASEADDRESS_CARDS" value="0x701a0000" />
<property name="BASEADDRESS_WININET" value="0x70200000" />

View file

@ -265,6 +265,7 @@ dll\win32\imm32\imm32.dll 1
dll\win32\inetcomm\inetcomm.dll 1
dll\win32\inetmib1\inetmib1.dll 1
dll\win32\iphlpapi\iphlpapi.dll 1
dll\win32\jscript\jscript.dll 1
dll\win32\kernel32\kernel32.dll 1
dll\win32\lsasrv\lsasrv.dll 1
dll\win32\lz32\lz32.dll 1

View file

@ -0,0 +1,230 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "jscript.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
#define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = _IDispatchEx_(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = _IDispatchEx_(This);
}else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
*ppv = _IDispatchEx_(This);
}else {
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
script_release(This->ctx);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
TRACE("(%p)->(%p)\n", This, pctinfo);
*pctinfo = 1;
return S_OK;
}
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames,
LCID lcid, DISPID *rgDispId)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
UINT i;
HRESULT hres;
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
lcid, rgDispId);
for(i=0; i < cNames; i++) {
hres = IDispatchEx_GetDispID(_IDispatchEx_(This), rgszNames[i], 0, rgDispId+i);
if(FAILED(hres))
return hres;
}
return S_OK;
}
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
return IDispatchEx_InvokeEx(_IDispatchEx_(This), dispIdMember, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, NULL);
}
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%x)\n", This, id);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
return E_NOTIMPL;
}
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
FIXME("(%p)->(%p)\n", This, ppunk);
return E_NOTIMPL;
}
#undef DISPATCHEX_THIS
static IDispatchExVtbl DispatchExVtbl = {
DispatchEx_QueryInterface,
DispatchEx_AddRef,
DispatchEx_Release,
DispatchEx_GetTypeInfoCount,
DispatchEx_GetTypeInfo,
DispatchEx_GetIDsOfNames,
DispatchEx_Invoke,
DispatchEx_GetDispID,
DispatchEx_InvokeEx,
DispatchEx_DeleteMemberByName,
DispatchEx_DeleteMemberByDispID,
DispatchEx_GetMemberProperties,
DispatchEx_GetMemberName,
DispatchEx_GetNextDispID,
DispatchEx_GetNameSpaceParent
};
static HRESULT init_dispex(DispatchEx *dispex, script_ctx_t *ctx)
{
dispex->lpIDispatchExVtbl = &DispatchExVtbl;
dispex->ref = 1;
script_addref(ctx);
dispex->ctx = ctx;
return S_OK;
}
HRESULT create_dispex(script_ctx_t *ctx, DispatchEx **dispex)
{
DispatchEx *ret;
HRESULT hres;
ret = heap_alloc_zero(sizeof(DispatchEx));
if(!ret)
return E_OUTOFMEMORY;
hres = init_dispex(ret, ctx);
if(FAILED(hres))
return hres;
*dispex = ret;
return S_OK;
}

View file

@ -0,0 +1,560 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static inline HRESULT stat_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
return stat->eval(ctx, stat, rt, ret);
}
HRESULT create_exec_ctx(exec_ctx_t **ret)
{
exec_ctx_t *ctx;
ctx = heap_alloc_zero(sizeof(exec_ctx_t));
if(!ctx)
return E_OUTOFMEMORY;
*ret = ctx;
return S_OK;
}
void exec_release(exec_ctx_t *ctx)
{
if(--ctx->ref)
return;
heap_free(ctx);
}
HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
{
script_ctx_t *script = parser->script;
parser_ctx_t *prev_parser;
VARIANT val, tmp;
statement_t *stat;
exec_ctx_t *prev_ctx;
return_type_t rt;
HRESULT hres = S_OK;
prev_ctx = script->exec_ctx;
script->exec_ctx = ctx;
prev_parser = ctx->parser;
ctx->parser = parser;
V_VT(&val) = VT_EMPTY;
memset(&rt, 0, sizeof(rt));
rt.type = RT_NORMAL;
for(stat = source->statement; stat; stat = stat->next) {
hres = stat_eval(ctx, stat, &rt, &tmp);
if(FAILED(hres))
break;
VariantClear(&val);
val = tmp;
if(rt.type != RT_NORMAL)
break;
}
script->exec_ctx = prev_ctx;
ctx->parser = prev_parser;
if(rt.type != RT_NORMAL && rt.type != RT_RETURN) {
FIXME("wrong rt %d\n", rt.type);
hres = E_FAIL;
}
*ei = rt.ei;
if(FAILED(hres)) {
VariantClear(&val);
return hres;
}
if(retv)
*retv = val;
else
VariantClear(&val);
return S_OK;
}
HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT empty_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
TRACE("\n");
V_VT(ret) = VT_EMPTY;
return S_OK;
}
HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT dowhile_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT while_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT for_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT continue_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT break_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT return_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT with_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT labelled_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT try_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT member_new_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT array_literal_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT binary_or_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT binary_xor_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT binary_and_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT instanceof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT in_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT add_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT sub_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT mul_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT div_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT mod_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT void_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT typeof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT post_increment_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT post_decrement_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT pre_increment_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT less_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT lesseq_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT greater_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT greatereq_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT binary_negation_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT logical_negation_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT left_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT right_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT right2_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_lshift_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_rshift_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_mul_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_div_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_mod_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_and_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_or_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT assign_xor_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}

View file

@ -0,0 +1,441 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
typedef struct _source_elements_t source_elements_t;
typedef struct _parser_ctx_t {
LONG ref;
const WCHAR *ptr;
const WCHAR *begin;
const WCHAR *end;
script_ctx_t *script;
source_elements_t *source;
BOOL nl;
HRESULT hres;
jsheap_t tmp_heap;
jsheap_t heap;
struct _parser_ctx_t *next;
} parser_ctx_t;
HRESULT script_parse(script_ctx_t*,const WCHAR*,parser_ctx_t**);
void parser_release(parser_ctx_t*);
int parser_lex(void*,parser_ctx_t*);
static inline void parser_addref(parser_ctx_t *ctx)
{
ctx->ref++;
}
static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
{
return jsheap_alloc(&ctx->heap, size);
}
static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
{
return jsheap_alloc(&ctx->tmp_heap, size);
}
struct _exec_ctx_t {
LONG ref;
parser_ctx_t *parser;
};
static inline void exec_addref(exec_ctx_t *ctx)
{
ctx->ref++;
}
void exec_release(exec_ctx_t*);
HRESULT create_exec_ctx(exec_ctx_t**);
HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*);
typedef struct _statement_t statement_t;
typedef struct _expression_t expression_t;
typedef struct _parameter_t parameter_t;
typedef struct {
VARTYPE vt;
union {
LONG lval;
double dval;
const WCHAR *wstr;
VARIANT_BOOL bval;
IDispatch *disp;
} u;
} literal_t;
typedef struct _variable_declaration_t {
const WCHAR *identifier;
expression_t *expr;
struct _variable_declaration_t *next;
} variable_declaration_t;
typedef struct {
enum{
RT_NORMAL,
RT_RETURN,
RT_BREAK,
RT_CONTINUE
} type;
jsexcept_t ei;
} return_type_t;
typedef HRESULT (*statement_eval_t)(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
struct _statement_t {
statement_eval_t eval;
statement_t *next;
};
typedef struct {
statement_t stat;
statement_t *stat_list;
} block_statement_t;
typedef struct {
statement_t stat;
variable_declaration_t *variable_list;
} var_statement_t;
typedef struct {
statement_t stat;
expression_t *expr;
} expression_statement_t;
typedef struct {
statement_t stat;
expression_t *expr;
statement_t *if_stat;
statement_t *else_stat;
} if_statement_t;
typedef struct {
statement_t stat;
expression_t *expr;
statement_t *statement;
} while_statement_t;
typedef struct {
statement_t stat;
variable_declaration_t *variable_list;
expression_t *begin_expr;
expression_t *expr;
expression_t *end_expr;
statement_t *statement;
} for_statement_t;
typedef struct {
statement_t stat;
variable_declaration_t *variable;
expression_t *expr;
expression_t *in_expr;
statement_t *statement;
} forin_statement_t;
typedef struct {
statement_t stat;
const WCHAR *identifier;
} branch_statement_t;
typedef struct {
statement_t stat;
expression_t *expr;
statement_t *statement;
} with_statement_t;
typedef struct {
statement_t stat;
const WCHAR *identifier;
statement_t *statement;
} labelled_statement_t;
typedef struct _case_clausule_t {
expression_t *expr;
statement_t *stat;
struct _case_clausule_t *next;
} case_clausule_t;
typedef struct {
statement_t stat;
expression_t *expr;
case_clausule_t *case_list;
} switch_statement_t;
typedef struct {
const WCHAR *identifier;
statement_t *statement;
} catch_block_t;
typedef struct {
statement_t stat;
statement_t *try_statement;
catch_block_t *catch_block;
statement_t *finally_statement;
} try_statement_t;
HRESULT block_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT var_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT empty_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT expression_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT if_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT dowhile_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT while_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT for_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT forin_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT continue_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT break_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT return_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT with_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT labelled_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT switch_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT throw_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
HRESULT try_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*);
typedef struct exprval_t exprval_t;
typedef HRESULT (*expression_eval_t)(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
struct _expression_t {
expression_eval_t eval;
};
struct _parameter_t {
const WCHAR *identifier;
struct _parameter_t *next;
};
typedef struct _function_declaration_t {
const WCHAR *identifier;
parameter_t *parameter_list;
source_elements_t *source_elements;
struct _function_declaration_t *next;
} function_declaration_t;
struct _source_elements_t {
statement_t *statement;
statement_t *statement_tail;
function_declaration_t *functions;
function_declaration_t *functions_tail;
};
typedef struct {
expression_t expr;
const WCHAR *identifier;
parameter_t *parameter_list;
source_elements_t *source_elements;
} function_expression_t;
typedef struct {
expression_t expr;
expression_t *expression1;
expression_t *expression2;
} binary_expression_t;
typedef struct {
expression_t expr;
expression_t *expression;
} unary_expression_t;
typedef struct {
expression_t expr;
expression_t *expression;
expression_t *true_expression;
expression_t *false_expression;
} conditional_expression_t;
typedef struct {
expression_t expr;
expression_t *member_expr;
expression_t *expression;
} array_expression_t;
typedef struct {
expression_t expr;
expression_t *expression;
const WCHAR *identifier;
} member_expression_t;
typedef struct _argument_t {
expression_t *expr;
struct _argument_t *next;
} argument_t;
typedef struct {
expression_t expr;
expression_t *expression;
argument_t *argument_list;
} call_expression_t;
typedef struct {
expression_t expr;
const WCHAR *identifier;
} identifier_expression_t;
typedef struct {
expression_t expr;
literal_t *literal;
} literal_expression_t;
typedef struct _array_element_t {
int elision;
expression_t *expr;
struct _array_element_t *next;
} array_element_t;
typedef struct {
expression_t expr;
array_element_t *element_list;
int length;
} array_literal_expression_t;
typedef struct _prop_val_t {
literal_t *name;
expression_t *value;
struct _prop_val_t *next;
} prop_val_t;
typedef struct {
expression_t expr;
prop_val_t *property_list;
} property_value_expression_t;
typedef enum {
EXPR_COMMA,
EXPR_OR,
EXPR_AND,
EXPR_BOR,
EXPR_BXOR,
EXPR_BAND,
EXPR_INSTANCEOF,
EXPR_IN,
EXPR_ADD,
EXPR_SUB,
EXPR_MUL,
EXPR_DIV,
EXPR_MOD,
EXPR_DELETE,
EXPR_VOID,
EXPR_TYPEOF,
EXPR_MINUS,
EXPR_PLUS,
EXPR_POSTINC,
EXPR_POSTDEC,
EXPR_PREINC,
EXPR_PREDEC,
EXPR_NEW,
EXPR_EQ,
EXPR_EQEQ,
EXPR_NOTEQ,
EXPR_NOTEQEQ,
EXPR_LESS,
EXPR_LESSEQ,
EXPR_GREATER,
EXPR_GREATEREQ,
EXPR_BITNEG,
EXPR_LOGNEG,
EXPR_LSHIFT,
EXPR_RSHIFT,
EXPR_RRSHIFT,
EXPR_ASSIGN,
EXPR_ASSIGNLSHIFT,
EXPR_ASSIGNRSHIFT,
EXPR_ASSIGNRRSHIFT,
EXPR_ASSIGNADD,
EXPR_ASSIGNSUB,
EXPR_ASSIGNMUL,
EXPR_ASSIGNDIV,
EXPR_ASSIGNMOD,
EXPR_ASSIGNAND,
EXPR_ASSIGNOR,
EXPR_ASSIGNXOR
} expression_type_t;
HRESULT function_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT conditional_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT array_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT member_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT member_new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT call_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT this_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT identifier_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT literal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT array_literal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT property_value_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT comma_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT logical_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT logical_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT binary_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT binary_xor_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT binary_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT instanceof_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT in_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT add_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT sub_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT mul_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT div_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT mod_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT delete_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT void_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT typeof_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT minus_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT plus_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT post_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT post_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT pre_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT pre_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT equal2_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT not_equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT not_equal2_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT less_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT lesseq_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT greater_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT greatereq_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT binary_negation_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT logical_negation_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT left_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT right_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT right2_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_lshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_rshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_rrshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_add_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_sub_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_mul_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_div_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_mod_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT assign_xor_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);

View file

@ -0,0 +1,690 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "jscript.h"
#include "engine.h"
#include "objsafe.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
typedef struct {
const IActiveScriptVtbl *lpIActiveScriptVtbl;
const IActiveScriptParseVtbl *lpIActiveScriptParseVtbl;
const IActiveScriptParseProcedure2Vtbl *lpIActiveScriptParseProcedure2Vtbl;
const IActiveScriptPropertyVtbl *lpIActiveScriptPropertyVtbl;
const IObjectSafetyVtbl *lpIObjectSafetyVtbl;
LONG ref;
DWORD safeopt;
script_ctx_t *ctx;
LONG thread_id;
IActiveScriptSite *site;
parser_ctx_t *queue_head;
parser_ctx_t *queue_tail;
} JScript;
#define ACTSCRIPT(x) ((IActiveScript*) &(x)->lpIActiveScriptVtbl)
#define ASPARSE(x) ((IActiveScriptParse*) &(x)->lpIActiveScriptParseVtbl)
#define ASPARSEPROC(x) ((IActiveScriptParseProcedure2*) &(x)->lpIActiveScriptParseProcedure2Vtbl)
#define ACTSCPPROP(x) ((IActiveScriptProperty*) &(x)->lpIActiveScriptPropertyVtbl)
#define OBJSAFETY(x) ((IObjectSafety*) &(x)->lpIObjectSafetyVtbl)
void script_release(script_ctx_t *ctx)
{
if(--ctx->ref)
return;
heap_free(ctx);
}
static void change_state(JScript *This, SCRIPTSTATE state)
{
if(This->ctx->state == state)
return;
This->ctx->state = state;
IActiveScriptSite_OnStateChange(This->site, state);
}
static inline BOOL is_started(script_ctx_t *ctx)
{
return ctx->state == SCRIPTSTATE_STARTED
|| ctx->state == SCRIPTSTATE_CONNECTED
|| ctx->state == SCRIPTSTATE_DISCONNECTED;
}
static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
{
exec_ctx_t *exec_ctx;
jsexcept_t jsexcept;
VARIANT var;
HRESULT hres;
hres = create_exec_ctx(&exec_ctx);
if(FAILED(hres))
return hres;
IActiveScriptSite_OnEnterScript(This->site);
memset(&jsexcept, 0, sizeof(jsexcept));
hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var);
VariantClear(&jsexcept.var);
exec_release(exec_ctx);
if(SUCCEEDED(hres))
VariantClear(&var);
IActiveScriptSite_OnLeaveScript(This->site);
return hres;
}
static void clear_script_queue(JScript *This)
{
parser_ctx_t *iter, *iter2;
if(!This->queue_head)
return;
iter = This->queue_head;
while(iter) {
iter2 = iter->next;
iter->next = NULL;
parser_release(iter);
iter = iter2;
}
This->queue_head = This->queue_tail = NULL;
}
static void exec_queued_code(JScript *This)
{
parser_ctx_t *iter;
for(iter = This->queue_head; iter; iter = iter->next)
exec_global_code(This, iter);
clear_script_queue(This);
}
#define ACTSCRIPT_THIS(iface) DEFINE_THIS(JScript, IActiveScript, iface)
static HRESULT WINAPI JScript_QueryInterface(IActiveScript *iface, REFIID riid, void **ppv)
{
JScript *This = ACTSCRIPT_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(riid, &IID_IUnknown)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = ACTSCRIPT(This);
}else if(IsEqualGUID(riid, &IID_IActiveScript)) {
TRACE("(%p)->(IID_IActiveScript %p)\n", This, ppv);
*ppv = ACTSCRIPT(This);
}else if(IsEqualGUID(riid, &IID_IActiveScriptParse)) {
TRACE("(%p)->(IID_IActiveScriptParse %p)\n", This, ppv);
*ppv = ASPARSE(This);
}else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure)) {
TRACE("(%p)->(IID_IActiveScriptParseProcedure %p)\n", This, ppv);
*ppv = ASPARSEPROC(This);
}else if(IsEqualGUID(riid, &IID_IActiveScriptParseProcedure2)) {
TRACE("(%p)->(IID_IActiveScriptParseProcedure2 %p)\n", This, ppv);
*ppv = ASPARSEPROC(This);
}else if(IsEqualGUID(riid, &IID_IActiveScriptProperty)) {
TRACE("(%p)->(IID_IActiveScriptProperty %p)\n", This, ppv);
*ppv = ACTSCPPROP(This);
}else if(IsEqualGUID(riid, &IID_IObjectSafety)) {
TRACE("(%p)->(IID_IObjectSafety %p)\n", This, ppv);
*ppv = OBJSAFETY(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
static ULONG WINAPI JScript_AddRef(IActiveScript *iface)
{
JScript *This = ACTSCRIPT_THIS(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI JScript_Release(IActiveScript *iface)
{
JScript *This = ACTSCRIPT_THIS(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", iface, ref);
if(!ref) {
if(This->ctx && This->ctx->state != SCRIPTSTATE_CLOSED)
IActiveScript_Close(ACTSCRIPT(This));
if(This->ctx)
script_release(This->ctx);
heap_free(This);
unlock_module();
}
return ref;
}
static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
IActiveScriptSite *pass)
{
JScript *This = ACTSCRIPT_THIS(iface);
LCID lcid;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, pass);
if(!pass)
return E_POINTER;
if(This->site)
return E_UNEXPECTED;
if(!This->ctx) {
hres = IActiveScriptParse_InitNew(ASPARSE(This));
if(FAILED(hres))
return hres;
}
hres = create_dispex(This->ctx, &This->ctx->script_disp);
if(FAILED(hres))
return hres;
if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
return E_UNEXPECTED;
This->site = pass;
IActiveScriptSite_AddRef(This->site);
hres = IActiveScriptSite_GetLCID(This->site, &lcid);
if(hres == S_OK)
This->ctx->lcid = lcid;
change_state(This, SCRIPTSTATE_INITIALIZED);
return S_OK;
}
static HRESULT WINAPI JScript_GetScriptSite(IActiveScript *iface, REFIID riid,
void **ppvObject)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ss)
{
JScript *This = ACTSCRIPT_THIS(iface);
TRACE("(%p)->(%d)\n", This, ss);
if(!This->ctx || GetCurrentThreadId() != This->thread_id)
return E_UNEXPECTED;
switch(ss) {
case SCRIPTSTATE_STARTED:
if(This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
exec_queued_code(This);
break;
default:
FIXME("unimplemented state %d\n", ss);
return E_NOTIMPL;
}
change_state(This, ss);
return S_OK;
}
static HRESULT WINAPI JScript_GetScriptState(IActiveScript *iface, SCRIPTSTATE *pssState)
{
JScript *This = ACTSCRIPT_THIS(iface);
TRACE("(%p)->(%p)\n", This, pssState);
if(!pssState)
return E_POINTER;
if(!This->thread_id) {
*pssState = SCRIPTSTATE_UNINITIALIZED;
return S_OK;
}
if(This->thread_id != GetCurrentThreadId())
return E_UNEXPECTED;
*pssState = This->ctx ? This->ctx->state : SCRIPTSTATE_UNINITIALIZED;
return S_OK;
}
static HRESULT WINAPI JScript_Close(IActiveScript *iface)
{
JScript *This = ACTSCRIPT_THIS(iface);
TRACE("(%p)->()\n", This);
if(This->thread_id != GetCurrentThreadId())
return E_UNEXPECTED;
clear_script_queue(This);
if(This->ctx) {
change_state(This, SCRIPTSTATE_CLOSED);
if(This->ctx->script_disp) {
IDispatchEx_Release(_IDispatchEx_(This->ctx->script_disp));
This->ctx->script_disp = NULL;
}
}
if(This->site) {
IActiveScriptSite_Release(This->site);
This->site = NULL;
}
return S_OK;
}
static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface,
LPCOLESTR pstrName, DWORD dwFlags)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->(%s %x)\n", This, debugstr_w(pstrName), dwFlags);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_AddTypeLib(IActiveScript *iface, REFGUID rguidTypeLib,
DWORD dwMajor, DWORD dwMinor, DWORD dwFlags)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR pstrItemName,
IDispatch **ppdisp)
{
JScript *This = ACTSCRIPT_THIS(iface);
TRACE("(%p)->(%p)\n", This, ppdisp);
if(!ppdisp)
return E_POINTER;
if(This->thread_id != GetCurrentThreadId() || !This->ctx->script_disp) {
*ppdisp = NULL;
return E_UNEXPECTED;
}
*ppdisp = (IDispatch*)_IDispatchEx_(This->ctx->script_disp);
IDispatch_AddRef(*ppdisp);
return S_OK;
}
static HRESULT WINAPI JScript_GetCurrentScriptThreadID(IActiveScript *iface,
SCRIPTTHREADID *pstridThread)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_GetScriptThreadID(IActiveScript *iface,
DWORD dwWin32ThreadId, SCRIPTTHREADID *pstidThread)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_GetScriptThreadState(IActiveScript *iface,
SCRIPTTHREADID stidThread, SCRIPTTHREADSTATE *pstsState)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_InterruptScriptThread(IActiveScript *iface,
SCRIPTTHREADID stidThread, const EXCEPINFO *pexcepinfo, DWORD dwFlags)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI JScript_Clone(IActiveScript *iface, IActiveScript **ppscript)
{
JScript *This = ACTSCRIPT_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
#undef ACTSCRIPT_THIS
static const IActiveScriptVtbl JScriptVtbl = {
JScript_QueryInterface,
JScript_AddRef,
JScript_Release,
JScript_SetScriptSite,
JScript_GetScriptSite,
JScript_SetScriptState,
JScript_GetScriptState,
JScript_Close,
JScript_AddNamedItem,
JScript_AddTypeLib,
JScript_GetScriptDispatch,
JScript_GetCurrentScriptThreadID,
JScript_GetScriptThreadID,
JScript_GetScriptThreadState,
JScript_InterruptScriptThread,
JScript_Clone
};
#define ASPARSE_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
static HRESULT WINAPI JScriptParse_QueryInterface(IActiveScriptParse *iface, REFIID riid, void **ppv)
{
JScript *This = ASPARSE_THIS(iface);
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
}
static ULONG WINAPI JScriptParse_AddRef(IActiveScriptParse *iface)
{
JScript *This = ASPARSE_THIS(iface);
return IActiveScript_AddRef(ACTSCRIPT(This));
}
static ULONG WINAPI JScriptParse_Release(IActiveScriptParse *iface)
{
JScript *This = ASPARSE_THIS(iface);
return IActiveScript_Release(ACTSCRIPT(This));
}
static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
{
JScript *This = ASPARSE_THIS(iface);
script_ctx_t *ctx;
TRACE("(%p)\n", This);
if(This->ctx)
return E_UNEXPECTED;
ctx = heap_alloc_zero(sizeof(script_ctx_t));
if(!ctx)
return E_OUTOFMEMORY;
ctx->ref = 1;
ctx->state = SCRIPTSTATE_UNINITIALIZED;
ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL);
if(ctx) {
script_release(ctx);
return E_UNEXPECTED;
}
return S_OK;
}
static HRESULT WINAPI JScriptParse_AddScriptlet(IActiveScriptParse *iface,
LPCOLESTR pstrDefaultName, LPCOLESTR pstrCode, LPCOLESTR pstrItemName,
LPCOLESTR pstrSubItemName, LPCOLESTR pstrEventName, LPCOLESTR pstrDelimiter,
DWORD dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags,
BSTR *pbstrName, EXCEPINFO *pexcepinfo)
{
JScript *This = ASPARSE_THIS(iface);
FIXME("(%p)->(%s %s %s %s %s %s %x %u %x %p %p)\n", This, debugstr_w(pstrDefaultName),
debugstr_w(pstrCode), debugstr_w(pstrItemName), debugstr_w(pstrSubItemName),
debugstr_w(pstrEventName), debugstr_w(pstrDelimiter), dwSourceContextCookie,
ulStartingLineNumber, dwFlags, pbstrName, pexcepinfo);
return E_NOTIMPL;
}
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
LPCOLESTR pstrDelimiter, DWORD dwSourceContextCookie, ULONG ulStartingLine,
DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
JScript *This = ASPARSE_THIS(iface);
parser_ctx_t *parser_ctx;
HRESULT hres;
TRACE("(%p)->(%s %s %p %s %x %u %x %p %p)\n", This, debugstr_w(pstrCode),
debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
dwSourceContextCookie, ulStartingLine, dwFlags, pvarResult, pexcepinfo);
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
hres = script_parse(This->ctx, pstrCode, &parser_ctx);
if(FAILED(hres))
return hres;
if(!is_started(This->ctx)) {
if(This->queue_tail)
This->queue_tail = This->queue_tail->next = parser_ctx;
else
This->queue_head = This->queue_tail = parser_ctx;
return S_OK;
}
hres = exec_global_code(This, parser_ctx);
parser_release(parser_ctx);
return hres;
}
#undef ASPARSE_THIS
static const IActiveScriptParseVtbl JScriptParseVtbl = {
JScriptParse_QueryInterface,
JScriptParse_AddRef,
JScriptParse_Release,
JScriptParse_InitNew,
JScriptParse_AddScriptlet,
JScriptParse_ParseScriptText
};
#define ASPARSEPROC_THIS(iface) DEFINE_THIS(JScript, IActiveScriptParse, iface)
static HRESULT WINAPI JScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2 *iface, REFIID riid, void **ppv)
{
JScript *This = ASPARSEPROC_THIS(iface);
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
}
static ULONG WINAPI JScriptParseProcedure_AddRef(IActiveScriptParseProcedure2 *iface)
{
JScript *This = ASPARSEPROC_THIS(iface);
return IActiveScript_AddRef(ACTSCRIPT(This));
}
static ULONG WINAPI JScriptParseProcedure_Release(IActiveScriptParseProcedure2 *iface)
{
JScript *This = ASPARSEPROC_THIS(iface);
return IActiveScript_Release(ACTSCRIPT(This));
}
static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2 *iface,
LPCOLESTR pstrCode, LPCOLESTR pstrFormalParams, LPCOLESTR pstrProcedureName,
LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter,
DWORD dwSourceContextCookie, ULONG ulStartingLineNumber, DWORD dwFlags, IDispatch **ppdisp)
{
JScript *This = ASPARSEPROC_THIS(iface);
FIXME("(%p)->()\n", This);
return E_NOTIMPL;
}
#undef ASPARSEPROC_THIS
static const IActiveScriptParseProcedure2Vtbl JScriptParseProcedureVtbl = {
JScriptParseProcedure_QueryInterface,
JScriptParseProcedure_AddRef,
JScriptParseProcedure_Release,
JScriptParseProcedure_ParseProcedureText,
};
#define ACTSCPPROP_THIS(iface) DEFINE_THIS(JScript, IActiveScriptProperty, iface)
static HRESULT WINAPI JScriptProperty_QueryInterface(IActiveScriptProperty *iface, REFIID riid, void **ppv)
{
JScript *This = ACTSCPPROP_THIS(iface);
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
}
static ULONG WINAPI JScriptProperty_AddRef(IActiveScriptProperty *iface)
{
JScript *This = ACTSCPPROP_THIS(iface);
return IActiveScript_AddRef(ACTSCRIPT(This));
}
static ULONG WINAPI JScriptProperty_Release(IActiveScriptProperty *iface)
{
JScript *This = ACTSCPPROP_THIS(iface);
return IActiveScript_Release(ACTSCRIPT(This));
}
static HRESULT WINAPI JScriptProperty_GetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
VARIANT *pvarIndex, VARIANT *pvarValue)
{
JScript *This = ACTSCPPROP_THIS(iface);
FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
return E_NOTIMPL;
}
static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, DWORD dwProperty,
VARIANT *pvarIndex, VARIANT *pvarValue)
{
JScript *This = ACTSCPPROP_THIS(iface);
FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue);
return E_NOTIMPL;
}
#undef ACTSCPPROP_THIS
static const IActiveScriptPropertyVtbl JScriptPropertyVtbl = {
JScriptProperty_QueryInterface,
JScriptProperty_AddRef,
JScriptProperty_Release,
JScriptProperty_GetProperty,
JScriptProperty_SetProperty
};
#define OBJSAFETY_THIS(iface) DEFINE_THIS(JScript, IObjectSafety, iface)
static HRESULT WINAPI JScriptSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
{
JScript *This = OBJSAFETY_THIS(iface);
return IActiveScript_QueryInterface(ACTSCRIPT(This), riid, ppv);
}
static ULONG WINAPI JScriptSafety_AddRef(IObjectSafety *iface)
{
JScript *This = OBJSAFETY_THIS(iface);
return IActiveScript_AddRef(ACTSCRIPT(This));
}
static ULONG WINAPI JScriptSafety_Release(IObjectSafety *iface)
{
JScript *This = OBJSAFETY_THIS(iface);
return IActiveScript_Release(ACTSCRIPT(This));
}
#define SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER)
static HRESULT WINAPI JScriptSafety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
{
JScript *This = OBJSAFETY_THIS(iface);
TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
if(!pdwSupportedOptions || !pdwEnabledOptions)
return E_POINTER;
*pdwSupportedOptions = SUPPORTED_OPTIONS;
*pdwEnabledOptions = This->safeopt;
return S_OK;
}
static HRESULT WINAPI JScriptSafety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
DWORD dwOptionSetMask, DWORD dwEnabledOptions)
{
JScript *This = OBJSAFETY_THIS(iface);
TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
if(dwOptionSetMask & ~SUPPORTED_OPTIONS)
return E_FAIL;
This->safeopt = dwEnabledOptions & dwEnabledOptions;
return S_OK;
}
#undef OBJSAFETY_THIS
static const IObjectSafetyVtbl JScriptSafetyVtbl = {
JScriptSafety_QueryInterface,
JScriptSafety_AddRef,
JScriptSafety_Release,
JScriptSafety_GetInterfaceSafetyOptions,
JScriptSafety_SetInterfaceSafetyOptions
};
HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
REFIID riid, void **ppv)
{
JScript *ret;
HRESULT hres;
TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
lock_module();
ret = heap_alloc_zero(sizeof(*ret));
ret->lpIActiveScriptVtbl = &JScriptVtbl;
ret->lpIActiveScriptParseVtbl = &JScriptParseVtbl;
ret->lpIActiveScriptParseProcedure2Vtbl = &JScriptParseProcedureVtbl;
ret->lpIActiveScriptPropertyVtbl = &JScriptPropertyVtbl;
ret->lpIObjectSafetyVtbl = &JScriptSafetyVtbl;
ret->ref = 1;
ret->safeopt = INTERFACE_USES_DISPEX;
hres = IActiveScript_QueryInterface(ACTSCRIPT(ret), riid, ppv);
IActiveScript_Release(ACTSCRIPT(ret));
return hres;
}

View file

@ -0,0 +1,118 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "wine/unicode.h"
#include "wine/list.h"
typedef struct _script_ctx_t script_ctx_t;
typedef struct _exec_ctx_t exec_ctx_t;
typedef struct {
EXCEPINFO ei;
VARIANT var;
} jsexcept_t;
typedef struct DispatchEx {
const IDispatchExVtbl *lpIDispatchExVtbl;
LONG ref;
script_ctx_t *ctx;
} DispatchEx;
#define _IDispatchEx_(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
HRESULT create_dispex(script_ctx_t*,DispatchEx**);
struct _script_ctx_t {
LONG ref;
SCRIPTSTATE state;
exec_ctx_t *exec_ctx;
LCID lcid;
DispatchEx *script_disp;
};
void script_release(script_ctx_t*);
static inline void script_addref(script_ctx_t *ctx)
{
ctx->ref++;
}
HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
typedef struct {
void **blocks;
DWORD block_cnt;
DWORD last_block;
DWORD offset;
struct list custom_blocks;
} jsheap_t;
void jsheap_init(jsheap_t*);
void *jsheap_alloc(jsheap_t*,DWORD);
void jsheap_clear(jsheap_t*);
void jsheap_free(jsheap_t*);
extern LONG module_ref;
static inline void lock_module(void)
{
InterlockedIncrement(&module_ref);
}
static inline void unlock_module(void)
{
InterlockedDecrement(&module_ref);
}
static inline void *heap_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *heap_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}
static inline BOOL heap_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))

View file

@ -0,0 +1,97 @@
[version]
Signature="$CHICAGO$"
[RegisterDll]
AddReg=Classes.Reg
[UnregisterDll]
DelReg=Classes.Reg
[Classes.Reg]
HKCR,"CLSID\%CLSID_JScript%",,,"JScript Language"
HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,,
HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,,
HKCR,"CLSID\%CLSID_JScript%\InprocServer32",,,"%MODULE%"
HKCR,"CLSID\%CLSID_JScript%\InprocServer32","ThreadingModel",,"Both"
HKCR,"CLSID\%CLSID_JScript%\OLEScript",,,
HKCR,"CLSID\%CLSID_JScript%\ProgID",,,"JScript"
HKCR,"CLSID\%CLSID_JScriptAuthor%",,,"JScript Language Authoring"
HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,,
HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32",,,"%MODULE%"
HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32","ThreadingModel",,"Both"
HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,,
HKCR,"CLSID\%CLSID_JScriptAuthor%\ProgID",,,"JScript Author"
HKCR,"CLSID\%CLSID_JScriptEncode%",,,"JScript Language Encoding"
HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,,
HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,,
HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,,
HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32",,,"%MODULE%"
HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32","ThreadingModel",,"Both"
HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,,
HKCR,"CLSID\%CLSID_JScriptEncode%\ProgID",,,"JScript.Encode"
HKCR,"Component Categories\%CATID_ActiveScriptAuthor%","409",,"Active Scripting Engine with Authoring"
HKCR,"Component Categories\%CATID_ActiveScript%","409",,"Active Scripting Engine"
HKCR,"Component Categories\%CATID_ActiveScriptParse%","409",,"Active Scripting Engine with Parsing"
HKCR,"Component Categories\%CATID_ActiveScriptEncode%","409",,"Active Scripting Engine with Encoding"
HKCR,"ECMAScript",,,"JScript Language"
HKCR,"ECMAScript\CLSID",,,"%CLSID_JScript%"
HKCR,"ECMAScript\OLEScript",,,
HKCR,"JavaScript",,,"JScript Language"
HKCR,"JavaScript\CLSID",,,"%CLSID_JScript%"
HKCR,"JavaScript\OLEScript",,,
HKCR,"JavaScript Author",,,"JScript Language Authoring"
HKCR,"JavaScript Author\CLSID",,,"%CLSID_JScriptAuthor%"
HKCR,"JavaScript Author\OLEScript",,,
HKCR,"JavaScript1.1",,,"JScript Language"
HKCR,"JavaScript1.1\CLSID",,,"%CLSID_JScript%"
HKCR,"JavaScript1.1\OLEScript",,,
HKCR,"JavaScript1.1 Author",,,"JScript Language Authoring"
HKCR,"JavaScript1.1 Author\CLSID",,,"%CLSID_JScriptAuthor%"
HKCR,"JavaScript1.1 Author\OLEScript",,,
HKCR,"JavaScript1.2",,,"JScript Language"
HKCR,"JavaScript1.2\CLSID",,,"%CLSID_JScript%"
HKCR,"JavaScript1.2\OLEScript",,,
HKCR,"JavaScript1.2 Author",,,"JScript Language Authoring"
HKCR,"JavaScript1.2 Author\CLSID",,,"%CLSID_JScriptAuthor%"
HKCR,"JavaScript1.2 Author\OLEScript",,,
HKCR,"JavaScript1.3",,,"JScript Language"
HKCR,"JavaScript1.3\CLSID",,,"%CLSID_JScript%"
HKCR,"JavaScript1.3\OLEScript",,,
HKCR,"JScript",,,"JScript Language"
HKCR,"JScript\CLSID",,,"%CLSID_JScript%"
HKCR,"JScript\OLEScript",,,
HKCR,"JScript Author",,,"JScript Language Authoring"
HKCR,"JScript Author\CLSID",,,"%CLSID_JScriptAuthor%"
HKCR,"JScript Author\OLEScript",,,
HKCR,"JScript.Encode",,,"JScript Language Encoding"
HKCR,"JScript.Encode\CLSID",,,"%CLSID_JScriptEncode%"
HKCR,"JScript.Encode\OLEScript",,,
HKCR,"LiveScript",,,"JScript Language"
HKCR,"LiveScript\CLSID",,,"%CLSID_JScript%"
HKCR,"LiveScript\OLEScript",,,
HKCR,"LiveScript Author",,,"JScript Language Authoring"
HKCR,"LiveScript Author\CLSID",,,"%CLSID_JScriptAuthor%"
HKCR,"LiveScript Author\OLEScript",,,
[Strings]
MODULE="jscript.dll"

View file

@ -0,0 +1,31 @@
<group>
<module name="jscript" type="win32dll" baseaddress="${BASEADDRESS_JSCRIPT}" installbase="system32" installname="jscript.dll">
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<importlibrary definition="jscript.spec.def" />
<include base="jscript">.</include>
<include base="jscript" root="intermediate">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x601</define>
<define name="WINVER">0x501</define>
<dependency>jsglobal</dependency>
<library>wine</library>
<library>kernel32</library>
<library>oleaut32</library>
<file>dispex.c</file>
<file>engine.c</file>
<file>jscript.c</file>
<file>jscript_main.c</file>
<file>jsutils.c</file>
<file>lex.c</file>
<file>parser.tab.c</file>
<file>rsrc.rc</file>
<file>jscript.spec</file>
</module>
<module name="jsglobal" type="embeddedtypelib">
<dependency>stdole2</dependency>
<file>jsglobal.idl</file>
</module>
</group>

View file

@ -0,0 +1,4 @@
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()

View file

@ -0,0 +1,215 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "initguid.h"
#include "jscript.h"
#include "winreg.h"
#include "advpub.h"
#include "activaut.h"
#include "objsafe.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
LONG module_ref = 0;
static const CLSID CLSID_JScript =
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
static const CLSID CLSID_JScriptAuthor =
{0xf414c261,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
static const CLSID CLSID_JScriptEncode =
{0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
static HINSTANCE jscript_hinstance;
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
*ppv = iface;
}else if(IsEqualGUID(&IID_IClassFactory, riid)) {
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
*ppv = iface;
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
{
TRACE("(%p)\n", iface);
return 2;
}
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
{
TRACE("(%p)\n", iface);
return 1;
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
{
TRACE("(%p)->(%x)\n", iface, fLock);
if(fLock)
lock_module();
else
unlock_module();
return S_OK;
}
static const IClassFactoryVtbl JScriptFactoryVtbl = {
ClassFactory_QueryInterface,
ClassFactory_AddRef,
ClassFactory_Release,
JScriptFactory_CreateInstance,
ClassFactory_LockServer
};
static IClassFactory JScriptFactory = { &JScriptFactoryVtbl };
/******************************************************************
* DllMain (jscript.@)
*/
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
switch(fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
jscript_hinstance = hInstDLL;
break;
}
return TRUE;
}
/***********************************************************************
* DllGetClassObject (jscript.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
if(IsEqualGUID(&CLSID_JScript, rclsid)) {
TRACE("(CLSID_JScript %s %p)\n", debugstr_guid(riid), ppv);
return IClassFactory_QueryInterface(&JScriptFactory, riid, ppv);
}
FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
/***********************************************************************
* DllCanUnloadNow (jscript.@)
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
TRACE("() ref=%d\n", module_ref);
return module_ref ? S_FALSE : S_OK;
}
/***********************************************************************
* register_inf
*/
#define INF_SET_ID(id) \
do \
{ \
static CHAR name[] = #id; \
\
pse[i].pszName = name; \
clsids[i++] = &id; \
} while (0)
static HRESULT register_inf(BOOL doregister)
{
HRESULT hres;
HMODULE hAdvpack;
HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
STRTABLEA strtable;
STRENTRYA pse[7];
static CLSID const *clsids[7];
unsigned int i = 0;
static const WCHAR advpackW[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
INF_SET_ID(CLSID_JScript);
INF_SET_ID(CLSID_JScriptAuthor);
INF_SET_ID(CLSID_JScriptEncode);
INF_SET_ID(CATID_ActiveScript);
INF_SET_ID(CATID_ActiveScriptParse);
INF_SET_ID(CATID_ActiveScriptEncode);
INF_SET_ID(CATID_ActiveScriptAuthor);
for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
sprintf(pse[i].pszValue, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
}
strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
strtable.pse = pse;
hAdvpack = LoadLibraryW(advpackW);
pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
hres = pRegInstall(jscript_hinstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
return hres;
}
#undef INF_SET_CLSID
/***********************************************************************
* DllRegisterServer (jscript.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
TRACE("()\n");
return register_inf(TRUE);
}
/***********************************************************************
* DllUnregisterServer (jscript.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
TRACE("()\n");
return register_inf(FALSE);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,273 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* GlobalObj */
#define DISPID_GLOBAL_NAN 0x0000
#define DISPID_GLOBAL_INFINITY 0x0001
#define DISPID_GLOBAL_ARRAY 0x0002
#define DISPID_GLOBAL_BOOLEAN 0x0003
#define DISPID_GLOBAL_DATE 0x0004
#define DISPID_GLOBAL_FUNCTION 0x0005
#define DISPID_GLOBAL_NUMBER 0x0006
#define DISPID_GLOBAL_OBJECT 0x0007
#define DISPID_GLOBAL_STRING 0x0008
#define DISPID_GLOBAL_REGEXP 0x0009
#define DISPID_GLOBAL_ACTIVEXOBJ 0x000a
#define DISPID_GLOBAL_VBARRAY 0x000b
#define DISPID_GLOBAL_ENUMERATOR 0x000c
#define DISPID_GLOBAL_ESCAPE 0x000d
#define DISPID_GLOBAL_EVAL 0x000e
#define DISPID_GLOBAL_ISNAN 0x000f
#define DISPID_GLOBAL_ISFINITE 0x0010
#define DISPID_GLOBAL_PARSEINT 0x0011
#define DISPID_GLOBAL_PARSEFLOAT 0x0012
#define DISPID_GLOBAL_UNESCAPE 0x0013
#define DISPID_GLOBAL_GETOBJECT 0x0014
#define DISPID_GLOBAL_SCRIPTENGINE 0x0015
#define DISPID_GLOBAL_MAJORVER 0x0016
#define DISPID_GLOBAL_MINORVER 0x0017
#define DISPID_GLOBAL_BUILDVER 0x0018
#define DISPID_GLOBAL_COLLECT 0x0019
#define DISPID_GLOBAL_MATH 0x001a
/* DateObj */
#define DISPID_DATEOBJ_PARSE 0x0064
#define DISPID_DATEOBJ_UTC 0x0065
/* MathObj */
#define DISPID_MATHOBJ_E 0x00c8
#define DISPID_MATHOBJ_LOG2E 0x00c9
#define DISPID_MATHOBJ_LOG10E 0x00ca
#define DISPID_MATHOBJ_LN2 0x00cb
#define DISPID_MATHOBJ_LN10 0x00cc
#define DISPID_MATHOBJ_PI 0x00cd
#define DISPID_MATHOBJ_SQRT2 0x00ce
#define DISPID_MATHOBJ_SQRT1_2 0x00cf
#define DISPID_MATHOBJ_ABS 0x00d0
#define DISPID_MATHOBJ_ACOS 0x00d1
#define DISPID_MATHOBJ_ASIN 0x00d2
#define DISPID_MATHOBJ_ATAN 0x00d3
#define DISPID_MATHOBJ_ATAN2 0x00d4
#define DISPID_MATHOBJ_CEIL 0x00d5
#define DISPID_MATHOBJ_COS 0x00d6
#define DISPID_MATHOBJ_EXP 0x00d7
#define DISPID_MATHOBJ_FLOOR 0x00d8
#define DISPID_MATHOBJ_LOG 0x00d9
#define DISPID_MATHOBJ_MAX 0x00da
#define DISPID_MATHOBJ_MIN 0x00db
#define DISPID_MATHOBJ_POW 0x00dc
#define DISPID_MATHOBJ_RANDOM 0x00dd
#define DISPID_MATHOBJ_ROUND 0x00de
#define DISPID_MATHOBJ_SIN 0x00df
#define DISPID_MATHOBJ_SQRT 0x00e0
#define DISPID_MATHOBJ_TAN 0x00e1
/* NumberObj */
#define DISPID_NUMBEROBJ_MAX_VALUE 0x012c
#define DISPID_NUMBEROBJ_MIN_VALUE 0x012d
#define DISPID_NUMBEROBJ_NAN 0x012e
#define DISPID_NUMBEROBJ_NEGATIVE_INFINITY 0x012f
#define DISPID_NUMBEROBJ_POSITIVE_INFINITY 0x0130
/* RegExpObj */
#define DISPID_REGEXPOBJ_INDEX 0x0190
#define DISPID_REGEXPOBJ_INPUT 0x0191
#define DISPID_REGEXPOBJ_LASTINDEX 0x0192
/* StringObj */
#define DISPID_STRINGOBJ_FROMCHARCODE 0x01f4
/* ArrayInstance */
#define DISPID_ARRAY_LENGTH 0x0258
#define DISPID_ARRAY_CONCAT 0x0259
#define DISPID_ARRAY_JOIN 0x025a
#define DISPID_ARRAY_POP 0x025b
#define DISPID_ARRAY_PUSH 0x025c
#define DISPID_ARRAY_REVERSE 0x025d
#define DISPID_ARRAY_SHIFT 0x025e
#define DISPID_ARRAY_SLICE 0x025f
#define DISPID_ARRAY_SORT 0x0260
#define DISPID_ARRAY_SPLICE 0x0261
#define DISPID_ARRAY_TOSTRING 0x0262
#define DISPID_ARRAY_TOLOCSTRING 0x0263
#define DISPID_ARRAY_VALUEOF 0x0264
#define DISPID_ARRAY_UNSHIFT 0x0265
#define DISPID_ARRAY_HASOWNPROP 0x0266
#define DISPID_ARRAY_PROPISENUM 0x0267
#define DISPID_ARRAY_ISPROTOF 0x0268
/* FunctionInstance */
#define DISPID_FUNCTION_LENGTH 0x02bc
#define DISPID_FUNCTION_TOSTRING 0x02bd
#define DISPID_FUNCTION_TOLOCSTRING 0x02be
#define DISPID_FUNCTION_VALUEOF 0x02bf
#define DISPID_FUNCTION_APPLY 0x02c0
#define DISPID_FUNCTION_CALL 0x02c1
#define DISPID_FUNCTION_HASOWNPROP 0x02c2
#define DISPID_FUNCTION_PROPISENUM 0x02c3
#define DISPID_FUNCTION_ISPROTOF 0x02c4
/* StringInstance */
#define DISPID_STRING_LENGTH 0x0320
#define DISPID_STRING_TOSTRING 0x0321
#define DISPID_STRING_VALUEOF 0x0322
#define DISPID_STRING_ANCHOR 0x0323
#define DISPID_STRING_BIG 0x0324
#define DISPID_STRING_BLINK 0x0325
#define DISPID_STRING_BOLD 0x0326
#define DISPID_STRING_CHARAT 0x0327
#define DISPID_STRING_CHARCODEAT 0x0328
#define DISPID_STRING_CONCAT 0x0329
#define DISPID_STRING_FIXED 0x032a
#define DISPID_STRING_FONTCOLOR 0x032b
#define DISPID_STRING_FONTSIZE 0x032c
#define DISPID_STRING_INDEXOF 0x032d
#define DISPID_STRING_ITALICS 0x032e
#define DISPID_STRING_LASTINDEXOF 0x032f
#define DISPID_STRING_LINK 0x0330
#define DISPID_STRING_MATCH 0x0331
#define DISPID_STRING_REPLACE 0x0332
#define DISPID_STRING_SEARCH 0x0333
#define DISPID_STRING_SLICE 0x0334
#define DISPID_STRING_SMALL 0x0335
#define DISPID_STRING_SPLIT 0x0336
#define DISPID_STRING_STRIKE 0x0337
#define DISPID_STRING_SUB 0x0338
#define DISPID_STRING_SUBSTRING 0x0339
#define DISPID_STRING_SUBSTR 0x033a
#define DISPID_STRING_SUP 0x033b
#define DISPID_STRING_TOLOWERCASE 0x033c
#define DISPID_STRING_TOUPPERCASE 0x033d
#define DISPID_STRING_TOLOCLOWERCASE 0x033e
#define DISPID_STRING_TOLOCUPPERCASE 0x033f
#define DISPID_STRING_LOCCOMPARE 0x0340
#define DISPID_STRING_HASOWNPROP 0x0341
#define DISPID_STRING_PROPISENUM 0x0342
#define DISPID_STRING_ISPROTOF 0x0343
/* BoolInstance */
#define DISPID_BOOL_TOSTRING 0x0384
#define DISPID_BOOL_TOLOCSTRING 0x0385
#define DISPID_BOOL_VALUEOF 0x0386
#define DISPID_BOOL_HASOWNPROP 0x0387
#define DISPID_BOOL_PROPISENUM 0x0388
#define DISPID_BOOL_ISPROTOF 0x0389
/* NumberInstance */
#define DISPID_NUMBER_TOSTRING 0x03e8
#define DISPID_NUMBER_TOLOCSTRING 0x03e9
#define DISPID_NUMBER_TOFIXED 0x03ea
#define DISPID_NUMBER_TOEXPONENTIAL 0x03eb
#define DISPID_NUMBER_TOPRECISION 0x03ec
#define DISPID_NUMBER_VALUEOF 0x03ed
#define DISPID_NUMBER_HASOWNPROP 0x03ee
#define DISPID_NUMBER_PROPISENUM 0x03ef
#define DISPID_NUMBER_ISPROTOF 0x03f0
/* ObjectInstance */
#define DISPID_OBJECT_TOSTRING 0x044c
#define DISPID_OBJECT_TOLOCSTRING 0x044d
#define DISPID_OBJECT_HASOWNPROP 0x044e
#define DISPID_OBJECT_PROPISENUM 0x044f
#define DISPID_OBJECT_ISPROTOF 0x0450
#define DISPID_OBJECT_VALUEOF 0x0451
/* DateInstance */
#define DISPID_DATE_TOSTRING 0x04b0
#define DISPID_DATE_TOLOCSTRING 0x04b1
#define DISPID_DATE_HASOWNPROP 0x04b2
#define DISPID_DATE_PROPISENUM 0x04b3
#define DISPID_DATE_ISPROTOF 0x04b4
#define DISPID_DATE_VALUEOF 0x04b5
#define DISPID_DATE_TOUTCSTRING 0x04b6
#define DISPID_DATE_TODATESTRING 0x04b7
#define DISPID_DATE_TOTIMESTRING 0x04b8
#define DISPID_DATE_TOLOCDATESTRING 0x04b9
#define DISPID_DATE_TOLOCTIMESTRING 0x04ba
#define DISPID_DATE_GETTIME 0x04bb
#define DISPID_DATE_GETFULLYEAR 0x04bc
#define DISPID_DATE_GETUTCFULLYEAR 0x04bd
#define DISPID_DATE_GETMONTH 0x04be
#define DISPID_DATE_GETUTCMONTH 0x04bf
#define DISPID_DATE_GETDATE 0x04c0
#define DISPID_DATE_GETUTCDATE 0x04c1
#define DISPID_DATE_GETDAY 0x04c2
#define DISPID_DATE_GETUTCDAY 0x04c3
#define DISPID_DATE_GETHOURS 0x04c4
#define DISPID_DATE_GETUTCHOURS 0x04c5
#define DISPID_DATE_GETMINUTES 0x04c6
#define DISPID_DATE_GETUTCMINUTES 0x04c7
#define DISPID_DATE_GETSECONDS 0x04c8
#define DISPID_DATE_GETUTCSECONDS 0x04c9
#define DISPID_DATE_GETMILLISECONDS 0x04ca
#define DISPID_DATE_GETUTCMILLISECONDS 0x04cb
#define DISPID_DATE_GETTIMEZONEOFFSET 0x04cc
#define DISPID_DATE_SETTIME 0x04cd
#define DISPID_DATE_SETMILLISECONDS 0x04ce
#define DISPID_DATE_SETUTCMILLISECONDS 0x04cf
#define DISPID_DATE_SETSECONDS 0x04d0
#define DISPID_DATE_SETUTCSECONDS 0x04d1
#define DISPID_DATE_SETMINUTES 0x04d2
#define DISPID_DATE_SETUTCMINUTES 0x04d3
#define DISPID_DATE_SETHOURS 0x04d4
#define DISPID_DATE_SETUTCHOURS 0x04d5
#define DISPID_DATE_SETDATE 0x04d6
#define DISPID_DATE_SETUTCDATE 0x04d7
#define DISPID_DATE_SETMONTH 0x04d8
#define DISPID_DATE_SETUTCMONTH 0x04d9
#define DISPID_DATE_SETFULLYEAR 0x04da
#define DISPID_DATE_SETUTCFULLYEAR 0x04db
/* RegExpInstance */
#define DISPID_REGEXP_SOURCE 0x0514
#define DISPID_REGEXP_GLOBAL 0x0515
#define DISPID_REGEXP_IGNORECASE 0x0516
#define DISPID_REGEXP_MULTILINE 0x0517
#define DISPID_REGEXP_LASTINDEX 0x0518
#define DISPID_REGEXP_TOSTRING 0x0519
#define DISPID_REGEXP_TOLOCSTRING 0x051a
#define DISPID_REGEXP_HASOWNPROP 0x051b
#define DISPID_REGEXP_PROPISENUM 0x051c
#define DISPID_REGEXP_ISPROTOF 0x051d
#define DISPID_REGEXP_EXEC 0x051e
/* ErrorInstance */
#define DISPID_ERROR_NAME 0x0578
#define DISPID_ERROR_MESSAGE 0x0579
#define DISPID_ERROR_IGNORECASE 0x057a
#define DISPID_ERROR_MULTILINE 0x057b
#define DISPID_ERROR_LASTINDEX 0x057c
#define DISPID_ERROR_TOSTRING 0x057d
#define DISPID_ERROR_TOLOCSTRING 0x057e
#define DISPID_ERROR_HASOWNPROP 0x057f
#define DISPID_ERROR_PROPISENUM 0x0580
#define DISPID_ERROR_ISPROTOF 0x0581

View file

@ -0,0 +1,112 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "jscript.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
#define MIN_BLOCK_SIZE 128
static inline DWORD block_size(DWORD block)
{
return MIN_BLOCK_SIZE << block;
}
void jsheap_init(jsheap_t *heap)
{
memset(heap, 0, sizeof(*heap));
list_init(&heap->custom_blocks);
}
void *jsheap_alloc(jsheap_t *heap, DWORD size)
{
struct list *list;
void *tmp;
if(!heap->block_cnt) {
if(!heap->blocks) {
heap->blocks = heap_alloc(sizeof(void*));
if(!heap->blocks)
return NULL;
}
tmp = heap_alloc(block_size(0));
if(!tmp)
return NULL;
heap->blocks[0] = tmp;
heap->block_cnt = 1;
}
if(heap->offset + size < block_size(heap->last_block)) {
tmp = ((BYTE*)heap->blocks[heap->last_block])+heap->offset;
heap->offset += size;
return tmp;
}
if(size < block_size(heap->last_block+1)) {
if(heap->last_block+1 == heap->block_cnt) {
tmp = heap_realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*));
if(!tmp)
return NULL;
heap->blocks = tmp;
}
tmp = heap_alloc(block_size(heap->block_cnt+1));
if(!tmp)
return NULL;
heap->blocks[heap->block_cnt++] = tmp;
heap->last_block++;
heap->offset = size;
return heap->blocks[heap->last_block];
}
list = heap_alloc(size + sizeof(struct list));
if(!list)
return NULL;
list_add_head(&heap->custom_blocks, list);
return list+1;
}
void jsheap_clear(jsheap_t *heap)
{
struct list *tmp;
while((tmp = list_next(&heap->custom_blocks, &heap->custom_blocks))) {
list_remove(tmp);
heap_free(tmp);
}
}
void jsheap_free(jsheap_t *heap)
{
DWORD i;
jsheap_clear(heap);
for(i=0; i < heap->block_cnt; i++)
heap_free(heap->blocks[i]);
heap_free(heap->blocks);
jsheap_init(heap);
}

View file

@ -0,0 +1,687 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <math.h>
#include "jscript.h"
#include "activscp.h"
#include "objsafe.h"
#include "engine.h"
#define YYSTYPE
#include "parser.tab.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static const WCHAR breakW[] = {'b','r','e','a','k',0};
static const WCHAR caseW[] = {'c','a','s','e',0};
static const WCHAR catchW[] = {'c','a','t','c','h',0};
static const WCHAR continueW[] = {'c','o','n','t','i','n','u','e',0};
static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
static const WCHAR deleteW[] = {'d','e','l','e','t','e',0};
static const WCHAR doW[] = {'d','o',0};
static const WCHAR elseW[] = {'e','l','s','e',0};
static const WCHAR falseW[] = {'f','a','l','s','e',0};
static const WCHAR finallyW[] = {'f','i','n','a','l','l','y',0};
static const WCHAR forW[] = {'f','o','r',0};
static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
static const WCHAR ifW[] = {'i','f',0};
static const WCHAR inW[] = {'i','n',0};
static const WCHAR instanceofW[] = {'i','n','s','t','a','n','c','e','o','f',0};
static const WCHAR newW[] = {'n','e','w',0};
static const WCHAR nullW[] = {'n','u','l','l',0};
static const WCHAR returnW[] = {'r','e','t','u','r','n',0};
static const WCHAR switchW[] = {'s','w','i','t','c','h',0};
static const WCHAR thisW[] = {'t','h','i','s',0};
static const WCHAR throwW[] = {'t','h','r','o','w',0};
static const WCHAR trueW[] = {'t','r','u','e',0};
static const WCHAR tryW[] = {'t','r','y',0};
static const WCHAR typeofW[] = {'t','y','p','e','o','f',0};
static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
static const WCHAR varW[] = {'v','a','r',0};
static const WCHAR voidW[] = {'v','o','i','d',0};
static const WCHAR whileW[] = {'w','h','i','l','e',0};
static const WCHAR withW[] = {'w','i','t','h',0};
static const struct {
const WCHAR *word;
int token;
} keywords[] = {
{breakW, kBREAK},
{caseW, kCASE},
{catchW, kCATCH},
{continueW, kCONTINUE},
{defaultW, kDEFAULT},
{deleteW, kDELETE},
{doW, kDO},
{elseW, kELSE},
{falseW, kFALSE},
{finallyW, kFINALLY},
{forW, kFOR},
{functionW, kFUNCTION},
{ifW, kIF},
{inW, kIN},
{instanceofW, kINSTANCEOF},
{newW, kNEW},
{nullW, kNULL},
{returnW, kRETURN},
{switchW, kSWITCH},
{thisW, kTHIS},
{throwW, kTHROW},
{trueW, kTRUE},
{tryW, kTRY},
{typeofW, kTYPEOF},
{undefinedW, kUNDEFINED},
{varW, kVAR},
{voidW, kVOID},
{whileW, kWHILE},
{withW, kWITH}
};
static int lex_error(parser_ctx_t *ctx, HRESULT hres)
{
ctx->hres = hres;
return -1;
}
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word)
{
const WCHAR *p1 = ctx->ptr;
const WCHAR *p2 = word;
while(p1 < ctx->end && *p2) {
if(*p1 != *p2)
return *p1 - *p2;
p1++;
p2++;
}
if(*p2 || (p1 < ctx->end && isalnumW(*p1)))
return 1;
ctx->ptr = p1;
return 0;
}
/* ECMA-262 3rd Edition 7.3 */
static BOOL is_endline(WCHAR c)
{
return c == '\n' || c == '\r' || c == 0x2028 || c == 0x2029;
}
static BOOL is_identifier_char(WCHAR c)
{
return isalnumW(c) || c == '$' || c == '_' || c == '\\';
}
static int hex_to_int(WCHAR c)
{
if('0' <= c && c <= '9')
return c-'0';
if('a' <= c && c <= 'f')
return c-'a'+10;
if('A' <= c && c <= 'F')
return c-'A'+10;
return -1;
}
static int check_keywords(parser_ctx_t *ctx)
{
int min = 0, max = sizeof(keywords)/sizeof(keywords[0])-1, r, i;
while(min <= max) {
i = (min+max)/2;
r = check_keyword(ctx, keywords[i].word);
if(!r)
return keywords[i].token;
if(r > 0)
min = i+1;
else
max = i-1;
}
return 0;
}
static void skip_spaces(parser_ctx_t *ctx)
{
while(ctx->ptr < ctx->end && isspaceW(*ctx->ptr)) {
if(is_endline(*ctx->ptr++))
ctx->nl = TRUE;
}
}
static BOOL skip_comment(parser_ctx_t *ctx)
{
if(ctx->ptr+1 >= ctx->end || *ctx->ptr != '/')
return FALSE;
switch(ctx->ptr[1]) {
case '*':
ctx->ptr += 2;
while(ctx->ptr+1 < ctx->end && (ctx->ptr[0] != '*' || ctx->ptr[1] != '/'))
ctx->ptr++;
if(ctx->ptr[0] == '*' && ctx->ptr[1] == '/') {
ctx->ptr += 2;
}else {
WARN("unexpected end of file (missing end of comment)\n");
ctx->ptr = ctx->end;
}
break;
case '/':
ctx->ptr += 2;
while(ctx->ptr < ctx->end && !is_endline(*ctx->ptr))
ctx->ptr++;
break;
default:
return FALSE;
}
return TRUE;
}
static BOOL unescape(WCHAR *str)
{
WCHAR *pd, *p, c;
int i;
pd = p = str;
while(*p) {
if(*p != '\\') {
*pd++ = *p++;
continue;
}
p++;
c = 0;
switch(*p) {
case '\'':
case '\"':
case '\\':
c = *p;
break;
case 'b':
c = '\b';
break;
case 't':
c = '\t';
break;
case 'n':
c = '\n';
break;
case 'v':
c = '\v';
break;
case 'f':
c = '\f';
break;
case 'r':
c = '\r';
break;
case '0':
break;
case 'x':
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c = i << 16;
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c += i;
break;
case 'u':
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c = i << 24;
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c += i << 16;
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c += 1 << 8;
i = hex_to_int(*++p);
if(i == -1)
return FALSE;
c += i;
break;
default:
c = *p;
}
*pd++ = c;
p++;
}
*pd = 0;
return TRUE;
}
static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret)
{
const WCHAR *ptr = ctx->ptr++;
WCHAR *wstr;
int len;
while(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr))
ctx->ptr++;
len = ctx->ptr-ptr;
*ret = wstr = parser_alloc(ctx, (len+1)*sizeof(WCHAR));
memcpy(wstr, ptr, (len+1)*sizeof(WCHAR));
wstr[len] = 0;
/* FIXME: unescape */
return tIdentifier;
}
static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endch)
{
const WCHAR *ptr = ++ctx->ptr;
WCHAR *wstr;
int len;
while(ctx->ptr < ctx->end && *ctx->ptr != endch) {
if(*ctx->ptr++ == '\\')
ctx->ptr++;
}
if(ctx->ptr == ctx->end) {
WARN("unexpected end of file\n");
return lex_error(ctx, E_FAIL);
}
len = ctx->ptr-ptr;
*ret = wstr = parser_alloc(ctx, (len+1)*sizeof(WCHAR));
memcpy(wstr, ptr, (len+1)*sizeof(WCHAR));
wstr[len] = 0;
ctx->ptr++;
if(!unescape(wstr)) {
WARN("unescape failed\n");
return lex_error(ctx, E_FAIL);
}
return tStringLiteral;
}
static literal_t *alloc_int_literal(parser_ctx_t *ctx, LONG l)
{
literal_t *ret = parser_alloc(ctx, sizeof(literal_t));
ret->vt = VT_I4;
ret->u.lval = l;
return ret;
}
static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **literal)
{
double d, tmp = 1.0;
if(ctx->ptr == ctx->end || !isdigitW(*ctx->ptr)) {
ERR("No digit after point\n");
return 0;
}
d = int_part;
while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr))
d += (tmp /= 10.0)*(*ctx->ptr++ - '0');
if(ctx->ptr < ctx->end && (*ctx->ptr == 'e' || *ctx->ptr == 'E')) {
int sign = 1, e = 0;
ctx->ptr++;
if(ctx->ptr < ctx->end) {
if(*ctx->ptr == '+') {
ctx->ptr++;
}else if(*ctx->ptr == '-') {
sign = -1;
ctx->ptr++;
}else if(!isdigitW(*ctx->ptr)) {
WARN("Expected exponent part\n");
return lex_error(ctx, E_FAIL);
}
}
if(ctx->ptr == ctx->end) {
WARN("unexpected end of file\n");
return lex_error(ctx, E_FAIL);
}
while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr))
e = e*10 + *ctx->ptr++ - '0';
e *= sign;
d = pow(d, e);
}
*literal = parser_alloc(ctx, sizeof(literal_t));
(*literal)->vt = VT_R8;
(*literal)->u.dval = d;
return tNumericLiteral;
}
static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
{
LONG l, d;
l = *ctx->ptr++ - '0';
if(ctx->ptr == ctx->end) {
*literal = alloc_int_literal(ctx, l);
return tNumericLiteral;
}
if(!l) {
if(*ctx->ptr == 'x' || *ctx->ptr == 'X') {
if(++ctx->ptr == ctx->end) {
ERR("unexpexted end of file\n");
return 0;
}
while(ctx->ptr < ctx->end && (d = hex_to_int(*ctx->ptr)) != -1) {
l = l*16 + d;
ctx->ptr++;
}
if(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr)) {
WARN("unexpected identifier char\n");
return lex_error(ctx, E_FAIL);
}
*literal = alloc_int_literal(ctx, l);
return tNumericLiteral;
}
if(isdigitW(*ctx->ptr) || is_identifier_char(*ctx->ptr)) {
WARN("wrong char after zero\n");
return lex_error(ctx, E_FAIL);
}
*literal = alloc_int_literal(ctx, 0);
}
while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr))
l = l*10 + *(ctx->ptr++)-'0';
if(ctx->ptr < ctx->end) {
if(*ctx->ptr == '.') {
ctx->ptr++;
return parse_double_literal(ctx, l, literal);
}
if(is_identifier_char(*ctx->ptr)) {
WARN("unexpected identifier char\n");
return lex_error(ctx, E_FAIL);
}
}
*literal = alloc_int_literal(ctx, l);
return tNumericLiteral;
}
int parser_lex(void *lval, parser_ctx_t *ctx)
{
int ret;
ctx->nl = FALSE;
do {
skip_spaces(ctx);
if(ctx->ptr == ctx->end)
return 0;
}while(skip_comment(ctx));
if(isalphaW(*ctx->ptr)) {
ret = check_keywords(ctx);
if(ret)
return ret;
return parse_identifier(ctx, (const WCHAR**)lval);
}
if(isdigitW(*ctx->ptr))
return parse_numeric_literal(ctx, lval);
switch(*ctx->ptr) {
case '{':
case '}':
case '(':
case ')':
case '[':
case ']':
case ';':
case ',':
case '~':
case '?':
case ':':
return *ctx->ptr++;
case '.':
if(++ctx->ptr < ctx->end && isdigitW(*ctx->ptr))
return parse_double_literal(ctx, 0, lval);
return '.';
case '<':
if(++ctx->ptr == ctx->end) {
*(int*)lval = EXPR_LESS;
return tRelOper;
}
switch(*ctx->ptr) {
case '=': /* <= */
ctx->ptr++;
*(int*)lval = EXPR_LESSEQ;
return tRelOper;
case '<': /* << */
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* <<= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNLSHIFT;
return tAssignOper;
}
*(int*)lval = EXPR_LSHIFT;
return tShiftOper;
default: /* < */
*(int*)lval = EXPR_LESS;
return tRelOper;
}
case '>':
if(++ctx->ptr == ctx->end) { /* > */
*(int*)lval = EXPR_GREATER;
return tRelOper;
}
switch(*ctx->ptr) {
case '=': /* >= */
ctx->ptr++;
*(int*)lval = EXPR_GREATEREQ;
return tRelOper;
case '>': /* >> */
if(++ctx->ptr < ctx->end) {
if(*ctx->ptr == '=') { /* >>= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNRSHIFT;
return tAssignOper;
}
if(*ctx->ptr == '>') { /* >>> */
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* >>>= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNRRSHIFT;
return tAssignOper;
}
*(int*)lval = EXPR_RRSHIFT;
return tRelOper;
}
}
*(int*)lval = EXPR_RSHIFT;
return tShiftOper;
default:
*(int*)lval = EXPR_GREATER;
return tRelOper;
}
case '+':
ctx->ptr++;
if(ctx->ptr < ctx->end) {
switch(*ctx->ptr) {
case '+': /* ++ */
ctx->ptr++;
return tINC;
case '=': /* += */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNADD;
return tAssignOper;
}
}
return '+';
case '-':
ctx->ptr++;
if(ctx->ptr < ctx->end) {
switch(*ctx->ptr) {
case '-': /* -- */
ctx->ptr++;
return tDEC;
case '=': /* -= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNSUB;
return tAssignOper;
}
}
return '-';
case '*':
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* *= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNMUL;
return tAssignOper;
}
return '*';
case '%':
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* %= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNMOD;
return tAssignOper;
}
return '%';
case '&':
if(++ctx->ptr < ctx->end) {
switch(*ctx->ptr) {
case '=': /* &= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNAND;
return tAssignOper;
case '&': /* && */
ctx->ptr++;
return tANDAND;
}
}
return '&';
case '|':
if(++ctx->ptr < ctx->end) {
switch(*ctx->ptr) {
case '=': /* |= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNOR;
return tAssignOper;
case '|': /* || */
ctx->ptr++;
return tOROR;
}
}
return '|';
case '^':
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* ^= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNXOR;
return tAssignOper;
}
return '^';
case '!':
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* != */
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* !== */
ctx->ptr++;
*(int*)lval = EXPR_NOTEQEQ;
return tEqOper;
}
*(int*)lval = EXPR_NOTEQ;
return tEqOper;
}
return '!';
case '=':
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* == */
if(++ctx->ptr < ctx->end && *ctx->ptr == '=') { /* === */
ctx->ptr++;
*(int*)lval = EXPR_EQEQ;
return tEqOper;
}
*(int*)lval = EXPR_EQ;
return tEqOper;
}
return '=';
case '/':
if(++ctx->ptr < ctx->end) {
if(*ctx->ptr == '=') { /* /= */
ctx->ptr++;
*(int*)lval = EXPR_ASSIGNMUL;
return tAssignOper;
}
}
return '/';
case '\"':
case '\'':
return parse_string_literal(ctx, (const WCHAR**)lval, *ctx->ptr);
case '_':
case '$':
return parse_identifier(ctx, lval);
}
WARN("unexpected char '%c' %d\n", *ctx->ptr, *ctx->ptr);
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,151 @@
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
kBREAK = 258,
kCASE = 259,
kCATCH = 260,
kCONTINUE = 261,
kDEFAULT = 262,
kDELETE = 263,
kDO = 264,
kELSE = 265,
kIF = 266,
kFINALLY = 267,
kFOR = 268,
kFUNCTION = 269,
kIN = 270,
kINSTANCEOF = 271,
kNEW = 272,
kNULL = 273,
kUNDEFINED = 274,
kRETURN = 275,
kSWITCH = 276,
kTHIS = 277,
kTHROW = 278,
kTRUE = 279,
kFALSE = 280,
kTRY = 281,
kTYPEOF = 282,
kVAR = 283,
kVOID = 284,
kWHILE = 285,
kWITH = 286,
tANDAND = 287,
tOROR = 288,
tINC = 289,
tDEC = 290,
tIdentifier = 291,
tAssignOper = 292,
tEqOper = 293,
tShiftOper = 294,
tRelOper = 295,
tNumericLiteral = 296,
tStringLiteral = 297
};
#endif
/* Tokens. */
#define kBREAK 258
#define kCASE 259
#define kCATCH 260
#define kCONTINUE 261
#define kDEFAULT 262
#define kDELETE 263
#define kDO 264
#define kELSE 265
#define kIF 266
#define kFINALLY 267
#define kFOR 268
#define kFUNCTION 269
#define kIN 270
#define kINSTANCEOF 271
#define kNEW 272
#define kNULL 273
#define kUNDEFINED 274
#define kRETURN 275
#define kSWITCH 276
#define kTHIS 277
#define kTHROW 278
#define kTRUE 279
#define kFALSE 280
#define kTRY 281
#define kTYPEOF 282
#define kVAR 283
#define kVOID 284
#define kWHILE 285
#define kWITH 286
#define tANDAND 287
#define tOROR 288
#define tINC 289
#define tDEC 290
#define tIdentifier 291
#define tAssignOper 292
#define tEqOper 293
#define tShiftOper 294
#define tRelOper 295
#define tNumericLiteral 296
#define tStringLiteral 297
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 147 "parser.y"
typedef union YYSTYPE {
int ival;
LPCWSTR wstr;
literal_t *literal;
argument_list_t *argument_list;
case_clausule_t *case_clausule;
case_list_t *case_list;
catch_block_t *catch_block;
element_list_t *element_list;
expression_t *expr;
const WCHAR *identifier;
function_declaration_t *function_declaration;
parameter_list_t *parameter_list;
property_list_t *property_list;
source_elements_t *source_elements;
statement_t *statement;
statement_list_t *statement_list;
variable_list_t *variable_list;
variable_declaration_t *variable_declaration;
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 143 "parser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* @makedep: jscript.inf */
REGINST REGINST jscript.inf
/* @makedep: jsglobal.tlb */
1 TYPELIB LOADONCALL DISCARDABLE jsglobal.tlb

View file

@ -124,6 +124,9 @@
<directory name="iphlpapi">
<xi:include href="iphlpapi/iphlpapi.rbuild" />
</directory>
<directory name="jscript">
<xi:include href="jscript/jscript.rbuild" />
</directory>
<directory name="kernel32">
<xi:include href="kernel32/kernel32.rbuild" />
</directory>