diff options
author | Ben Becker <ben.becker@10gen.com> | 2013-01-18 14:15:28 -0800 |
---|---|---|
committer | Ben Becker <ben.becker@10gen.com> | 2013-01-18 14:15:43 -0800 |
commit | 41c1110326ae00fc7fb279b3bfeabadc3a82bc5a (patch) | |
tree | 646e122504532957a3517ea1b3e82070c629d091 /src/mongo/scripting/v8_db.cpp | |
parent | 98d2e5d364e01581a4ba1b2e7df25f79ebd836b2 (diff) | |
download | mongo-41c1110326ae00fc7fb279b3bfeabadc3a82bc5a.tar.gz |
SERVER-8104: clean up js global object
Diffstat (limited to 'src/mongo/scripting/v8_db.cpp')
-rw-r--r-- | src/mongo/scripting/v8_db.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/mongo/scripting/v8_db.cpp b/src/mongo/scripting/v8_db.cpp index a0a8c8e58c6..e056dfbe206 100644 --- a/src/mongo/scripting/v8_db.cpp +++ b/src/mongo/scripting/v8_db.cpp @@ -102,94 +102,6 @@ namespace mongo { return mongo; } - v8::Handle<v8::FunctionTemplate> getNumberLongFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> numberLong = scope->createV8Function(numberLongInit); - v8::Local<v8::Template> proto = numberLong->PrototypeTemplate(); - scope->injectV8Function("valueOf", numberLongValueOf, proto); - scope->injectV8Function("toNumber", numberLongToNumber, proto); - scope->injectV8Function("toString", numberLongToString, proto); - return numberLong; - } - - v8::Handle<v8::FunctionTemplate> getNumberIntFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> numberInt = scope->createV8Function(numberIntInit); - v8::Local<v8::Template> proto = numberInt->PrototypeTemplate(); - scope->injectV8Function("valueOf", numberIntValueOf, proto); - scope->injectV8Function("toNumber", numberIntToNumber, proto); - scope->injectV8Function("toString", numberIntToString, proto); - return numberInt; - } - - v8::Handle<v8::FunctionTemplate> getBinDataFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> binData = scope->createV8Function(binDataInit); - binData->InstanceTemplate()->SetInternalFieldCount(1); - v8::Local<v8::Template> proto = binData->PrototypeTemplate(); - scope->injectV8Function("toString", binDataToString, proto); - scope->injectV8Function("base64", binDataToBase64, proto); - scope->injectV8Function("hex", binDataToHex, proto); - return binData; - } - - v8::Handle<v8::FunctionTemplate> getUUIDFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> templ = scope->createV8Function(uuidInit); - return templ; - } - - v8::Handle<v8::FunctionTemplate> getMD5FunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> templ = scope->createV8Function(md5Init); - return templ; - } - - v8::Handle<v8::FunctionTemplate> getHexDataFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> templ = scope->createV8Function(hexDataInit); - return templ; - } - - v8::Handle<v8::FunctionTemplate> getTimestampFunctionTemplate(V8Scope* scope) { - v8::Handle<v8::FunctionTemplate> ts = scope->createV8Function(dbTimestampInit); - ts->InstanceTemplate()->SetInternalFieldCount(1); - return ts; - } - - void installDBTypes(V8Scope* scope, v8::Handle<v8::Object>& global) { - v8::Handle<v8::FunctionTemplate> db = scope->createV8Function(dbInit); - db->InstanceTemplate()->SetNamedPropertyHandler(collectionGetter, collectionSetter); - global->ForceSet(scope->v8StringData("DB"), db->GetFunction()); - v8::Handle<v8::FunctionTemplate> dbCollection = scope->createV8Function(collectionInit); - dbCollection->InstanceTemplate()->SetNamedPropertyHandler(collectionGetter, - collectionSetter); - global->ForceSet(scope->v8StringData("DBCollection"), dbCollection->GetFunction()); - - v8::Handle<v8::FunctionTemplate> dbQuery = scope->createV8Function(dbQueryInit); - dbQuery->InstanceTemplate()->SetIndexedPropertyHandler(dbQueryIndexAccess); - global->ForceSet(scope->v8StringData("DBQuery"), dbQuery->GetFunction()); - - scope->injectV8Function("ObjectId", objectIdInit, global); - scope->injectV8Function("DBRef", dbRefInit, global); - scope->injectV8Function("DBPointer", dbPointerInit, global); - - global->ForceSet(scope->v8StringData("BinData"), getBinDataFunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("UUID"), getUUIDFunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("MD5"), getMD5FunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("HexData"), getHexDataFunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("NumberLong"), - getNumberLongFunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("NumberInt"), - getNumberIntFunctionTemplate(scope)->GetFunction()); - global->ForceSet(scope->v8StringData("Timestamp"), - getTimestampFunctionTemplate(scope)->GetFunction()); - - BSONObjBuilder b; - b.appendMaxKey(""); - b.appendMinKey(""); - BSONObj o = b.obj(); - BSONObjIterator i(o); - global->ForceSet(scope->v8StringData("MaxKey"), scope->mongoToV8Element(i.next())); - global->ForceSet(scope->v8StringData("MinKey"), scope->mongoToV8Element(i.next())); - global->Get(scope->v8StringData("Object"))->ToObject()->ForceSet(scope->v8StringData("bsonsize"), - scope->createV8Function(bsonsize)->GetFunction()); - } - void destroyConnection(v8::Persistent<v8::Value> self, void* parameter) { delete static_cast<DBClientBase*>(parameter); self.Dispose(); |