Commit 352df581 authored by deuce's avatar deuce
Browse files

Add consts and const flags to js_SyncResolve()

Fix DLLCALL usage.
parent 7ce1976a
......@@ -505,7 +505,8 @@ DLLCALL js_DefineSyncMethods(JSContext* cx, JSObject* obj, jsSyncMethodSpec *fun
* 1) We'll always be enumerating anyways
* 2) The speed penalty won't be seen in production code anyways
*/
JSBool js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs)
JSBool
DLLCALL js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs, jsConstIntSpec* consts, int flags)
{
JSBool ret=JS_TRUE;
......@@ -517,6 +518,9 @@ JSBool js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySp
if(!js_DefineSyncMethods(cx, obj, funcs))
ret=JS_FALSE;
if(consts)
if(!js_DefineConstIntegers(JSContext* cx, JSObject* obj, consts, flags)
return(ret);
}
......@@ -547,9 +551,11 @@ DLLCALL js_DefineSyncMethods(JSContext* cx, JSObject* obj, jsSyncMethodSpec *fun
return(JS_TRUE);
}
JSBool js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs)
JSBool
DLLCALL js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs, jsConstIntSpec* consts, int flags)
{
uint i;
jsval val;
if(props) {
for(i=0;props[i].name;i++) {
......@@ -572,6 +578,20 @@ JSBool js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySp
}
}
}
if(consts) {
for(i=0;ints[i].name;i++) {
if(name==NULL || strcmp(name, consts[i].name)==0) {
if(!JS_NewNumberValue(cx, ints[i].val, &val))
return(JS_FALSE);
if(!JS_DefineProperty(cx, obj, ints[i].name, val ,NULL, NULL, flags))
return(JS_FALSE);
if(name)
return(JS_TRUE);
}
}
}
return(JS_TRUE);
}
......@@ -592,7 +612,7 @@ DLLCALL js_DefineConstIntegers(JSContext* cx, JSObject* obj, jsConstIntSpec* int
if(!JS_DefineProperty(cx, obj, ints[i].name, val ,NULL, NULL, flags))
return(JS_FALSE);
}
return(JS_TRUE);
}
......
......@@ -968,7 +968,7 @@ extern "C" {
DLLEXPORT JSBool DLLCALL js_DescribeSyncConstructor(JSContext* cx, JSObject* obj, const char*);
DLLEXPORT JSBool DLLCALL js_DefineSyncMethods(JSContext* cx, JSObject* obj, jsSyncMethodSpec*, BOOL append);
DLLEXPORT JSBool DLLCALL js_DefineSyncProperties(JSContext* cx, JSObject* obj, jsSyncPropertySpec*);
DLLEXPORT JSBool DLLCALL js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs);
DLLEXPORT JSBool DLLCALL js_SyncResolve(JSContext* cx, JSObject* obj, char *name, jsSyncPropertySpec* props, jsSyncMethodSpec* funcs, jsConstIntSpec* consts, int flags);
DLLEXPORT JSBool DLLCALL js_DefineConstIntegers(JSContext* cx, JSObject* obj, jsConstIntSpec*, int flags);
DLLEXPORT JSBool DLLCALL js_CreateArrayOfStrings(JSContext* cx, JSObject* parent
,const char* name, char* str[], uintN flags);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment