SERVER-446 js implementation of keySet()

This commit is contained in:
Aaron
2009-12-21 11:21:25 -08:00
parent 83d4e4f2e1
commit 81b7e051b2
14 changed files with 597 additions and 446 deletions

View File

@@ -947,29 +947,6 @@ namespace mongo {
}
// ------ special helpers -------
JSBool object_keyset(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
JSIdArray * properties = JS_Enumerate( cx , obj );
assert( properties );
JSObject * array = JS_NewArrayObject( cx , properties->length , 0 );
assert( array );
for ( jsint i=0; i<properties->length; i++ ){
jsid id = properties->vector[i];
jsval idval;
assert( JS_IdToValue( cx , id , &idval ) );
assert( JS_SetElement( cx , array , i , &idval ) );
}
JS_DestroyIdArray( cx , properties );
*rval = OBJECT_TO_JSVAL( array );
return JS_TRUE;
}
// ------ scope ------
@@ -1002,11 +979,6 @@ namespace mongo {
JS_DefineFunctions( _context , _global , globalHelpers );
// install my special helpers
assert( JS_DefineFunction( _context , _convertor->getGlobalPrototype( "Object" ) ,
"keySet" , object_keyset , 0 , JSPROP_READONLY ) );
//JS_SetGCCallback( _context , no_gc ); // this is useful for seeing if something is a gc problem
_postCreateHacks();