jscript: Added JSON object stub implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e00708e3aa
commit
4e1e2ee451
|
@ -15,6 +15,7 @@ C_SRCS = \
|
||||||
global.c \
|
global.c \
|
||||||
jscript.c \
|
jscript.c \
|
||||||
jscript_main.c \
|
jscript_main.c \
|
||||||
|
json.c \
|
||||||
jsregexp.c \
|
jsregexp.c \
|
||||||
jsstr.c \
|
jsstr.c \
|
||||||
jsutils.c \
|
jsutils.c \
|
||||||
|
|
|
@ -67,6 +67,7 @@ static const WCHAR ScriptEngineBuildVersionW[] =
|
||||||
{'S','c','r','i','p','t','E','n','g','i','n','e','B','u','i','l','d','V','e','r','s','i','o','n',0};
|
{'S','c','r','i','p','t','E','n','g','i','n','e','B','u','i','l','d','V','e','r','s','i','o','n',0};
|
||||||
static const WCHAR CollectGarbageW[] = {'C','o','l','l','e','c','t','G','a','r','b','a','g','e',0};
|
static const WCHAR CollectGarbageW[] = {'C','o','l','l','e','c','t','G','a','r','b','a','g','e',0};
|
||||||
static const WCHAR MathW[] = {'M','a','t','h',0};
|
static const WCHAR MathW[] = {'M','a','t','h',0};
|
||||||
|
static const WCHAR JSONW[] = {'J','S','O','N',0};
|
||||||
static const WCHAR encodeURIW[] = {'e','n','c','o','d','e','U','R','I',0};
|
static const WCHAR encodeURIW[] = {'e','n','c','o','d','e','U','R','I',0};
|
||||||
static const WCHAR decodeURIW[] = {'d','e','c','o','d','e','U','R','I',0};
|
static const WCHAR decodeURIW[] = {'d','e','c','o','d','e','U','R','I',0};
|
||||||
static const WCHAR encodeURIComponentW[] = {'e','n','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0};
|
static const WCHAR encodeURIComponentW[] = {'e','n','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0};
|
||||||
|
@ -1107,6 +1108,19 @@ HRESULT init_global(script_ctx_t *ctx)
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
if(ctx->version >= 2) {
|
||||||
|
jsdisp_t *json;
|
||||||
|
|
||||||
|
hres = create_json(ctx, &json);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
hres = jsdisp_propput_dontenum(ctx->global, JSONW, jsval_obj(json));
|
||||||
|
jsdisp_release(json);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
hres = create_activex_constr(ctx, &constr);
|
hres = create_activex_constr(ctx, &constr);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -117,7 +117,8 @@ typedef enum {
|
||||||
JSCLASS_REGEXP,
|
JSCLASS_REGEXP,
|
||||||
JSCLASS_STRING,
|
JSCLASS_STRING,
|
||||||
JSCLASS_ARGUMENTS,
|
JSCLASS_ARGUMENTS,
|
||||||
JSCLASS_VBARRAY
|
JSCLASS_VBARRAY,
|
||||||
|
JSCLASS_JSON
|
||||||
} jsclass_t;
|
} jsclass_t;
|
||||||
|
|
||||||
jsdisp_t *iface_to_jsdisp(IUnknown*) DECLSPEC_HIDDEN;
|
jsdisp_t *iface_to_jsdisp(IUnknown*) DECLSPEC_HIDDEN;
|
||||||
|
@ -317,6 +318,7 @@ HRESULT create_string(script_ctx_t*,jsstr_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
|
HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
|
HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
|
HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
|
HRESULT create_json(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NO_HINT,
|
NO_HINT,
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 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 "wine/debug.h"
|
||||||
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
|
||||||
|
|
||||||
|
static const WCHAR parseW[] = {'p','a','r','s','e',0};
|
||||||
|
static const WCHAR stringifyW[] = {'s','t','r','i','n','g','i','f','y',0};
|
||||||
|
|
||||||
|
static HRESULT JSON_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
|
||||||
|
{
|
||||||
|
FIXME("\n");
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
|
||||||
|
{
|
||||||
|
FIXME("\n");
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const builtin_prop_t JSON_props[] = {
|
||||||
|
{parseW, JSON_parse, PROPF_METHOD|2},
|
||||||
|
{stringifyW, JSON_stringify, PROPF_METHOD|3}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const builtin_info_t JSON_info = {
|
||||||
|
JSCLASS_JSON,
|
||||||
|
{NULL, NULL, 0},
|
||||||
|
sizeof(JSON_props)/sizeof(*JSON_props),
|
||||||
|
JSON_props,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT create_json(script_ctx_t *ctx, jsdisp_t **ret)
|
||||||
|
{
|
||||||
|
jsdisp_t *json;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
json = heap_alloc_zero(sizeof(*json));
|
||||||
|
if(!json)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
hres = init_dispex_from_constr(json, ctx, &JSON_info, ctx->object_constr);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
heap_free(json);
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ret = json;
|
||||||
|
return S_OK;
|
||||||
|
}
|
|
@ -54,7 +54,7 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
||||||
static const WCHAR stringW[] = {'S','t','r','i','n','g',0};
|
static const WCHAR stringW[] = {'S','t','r','i','n','g',0};
|
||||||
/* Keep in sync with jsclass_t enum */
|
/* Keep in sync with jsclass_t enum */
|
||||||
static const WCHAR *names[] = {NULL, arrayW, booleanW, dateW, errorW,
|
static const WCHAR *names[] = {NULL, arrayW, booleanW, dateW, errorW,
|
||||||
functionW, NULL, mathW, numberW, objectW, regexpW, stringW, objectW, objectW};
|
functionW, NULL, mathW, numberW, objectW, regexpW, stringW, objectW, objectW, objectW};
|
||||||
|
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
|
|
||||||
|
|
|
@ -2717,6 +2717,14 @@ testFunctions(VBArray.prototype, [
|
||||||
["lbound", 0],
|
["lbound", 0],
|
||||||
["toArray", 0],
|
["toArray", 0],
|
||||||
["ubound", 0]
|
["ubound", 0]
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(invokeVersion < 2)
|
||||||
|
ok(typeof(JSON) === "undefined", "JSON is not undefined");
|
||||||
|
else
|
||||||
|
testFunctions(JSON, [
|
||||||
|
["parse", 2],
|
||||||
|
["stringify", 3]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
|
ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
|
||||||
|
|
Loading…
Reference in New Issue