Commit 7ce1976a authored by deuce's avatar deuce
Browse files

Add js_SyncResolve() convenience function.

parent 0a264311
......@@ -500,6 +500,26 @@ DLLCALL js_DefineSyncMethods(JSContext* cx, JSObject* obj, jsSyncMethodSpec *fun
return(JS_TRUE);
}
/*
* Always resolve all here since
* 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 ret=JS_TRUE;
if(props)
if(!js_DefineSyncProperties(cx, obj, props))
ret=JS_FALSE;
if(funcs)
if(!js_DefineSyncMethods(cx, obj, funcs))
ret=JS_FALSE;
return(ret);
}
#else // NON-JSDOCS
JSBool
......@@ -527,6 +547,35 @@ 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)
{
uint i;
if(props) {
for(i=0;props[i].name;i++) {
if(name==NULL || strcmp(name, props[i].name)==0) {
if(!JS_DefinePropertyWithTinyId(cx, obj,
props[i].name,props[i].tinyid, JSVAL_VOID, NULL, NULL, props[i].flags|JSPROP_SHARED))
return(JS_FALSE);
if(name)
return(JS_TRUE);
}
}
}
if(funcs) {
for(i=0;funcs[i].name;i++) {
if(name==NULL || strcmp(name, funcs[i].name)==0) {
if(!JS_DefineFunction(cx, obj, funcs[i].name, funcs[i].call, funcs[i].nargs, 0))
return(JS_FALSE);
if(name)
return(JS_TRUE);
}
}
}
return(JS_TRUE);
}
#endif
/* This is a stream-lined version of JS_DefineConstDoubles */
......
......@@ -968,6 +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_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