summaryrefslogtreecommitdiff
path: root/scripting/v8_wrapper.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-08-29 20:54:51 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-08-29 20:54:51 +0200
commit83957b73f9177f6e38bd5375bd93ca1f6a47188c (patch)
treef20b7d6ac9a9c64ff5bb6b5910a24abbb356b1d5 /scripting/v8_wrapper.cpp
parent5071d203970edd4c995493d810abe20987e76fe9 (diff)
Imported Upstream version 2.2.0upstream/2.2.0
Diffstat (limited to 'scripting/v8_wrapper.cpp')
-rw-r--r--scripting/v8_wrapper.cpp99
1 files changed, 0 insertions, 99 deletions
diff --git a/scripting/v8_wrapper.cpp b/scripting/v8_wrapper.cpp
deleted file mode 100644
index 7c28a39cceb..00000000000
--- a/scripting/v8_wrapper.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// v8_wrapper.cpp
-
-/* Copyright 2009 10gen Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#if defined(_WIN32)
-/** this is a hack - v8stdint.h defined uint16_t etc. on _WIN32 only, and that collides with
- our usage of boost */
-#include "boost/cstdint.hpp"
-using namespace boost;
-#define V8STDINT_H_
-#endif
-
-#include "v8_wrapper.h"
-#include "v8_utils.h"
-#include "v8_db.h"
-#include "engine_v8.h"
-
-#include <iostream>
-
-using namespace std;
-using namespace v8;
-
-namespace mongo {
-
-#define DDD(x)
-
- // --- object wrapper ---
-
- class WrapperHolder {
- public:
- WrapperHolder( V8Scope* scope, const BSONObj * o , bool readOnly , bool iDelete )
- : _scope(scope), _o(o), _readOnly( readOnly ), _iDelete( iDelete ) {
- }
-
- ~WrapperHolder() {
- if ( _o && _iDelete ) {
- delete _o;
- }
- _o = 0;
- }
-
- v8::Handle<v8::Value> get( v8::Local<v8::String> name ) {
- const string& s = toSTLString( name );
- const BSONElement& e = _o->getField( s );
- return _scope->mongoToV8Element(e);
- }
-
- V8Scope* _scope;
- const BSONObj * _o;
- bool _readOnly;
- bool _iDelete;
- };
-
- WrapperHolder * createWrapperHolder( V8Scope* scope, const BSONObj * o , bool readOnly , bool iDelete ) {
- return new WrapperHolder( scope, o , readOnly , iDelete );
- }
-
- WrapperHolder * getWrapper( v8::Handle<v8::Object> o ) {
- Handle<v8::Value> t = o->GetRealNamedProperty( v8::String::New( "_wrapper" ) );
- assert( t->IsExternal() );
- Local<External> c = External::Cast( *t );
- WrapperHolder * w = (WrapperHolder*)(c->Value());
- assert( w );
- return w;
- }
-
-
- Handle<Value> wrapperCons(V8Scope* scope, const Arguments& args) {
- if ( ! ( args.Length() == 1 && args[0]->IsExternal() ) )
- return v8::ThrowException( v8::String::New( "wrapperCons needs 1 External arg" ) );
-
- args.This()->Set( v8::String::New( "_wrapper" ) , args[0] );
-
- return v8::Undefined();
- }
-
- v8::Handle<v8::Value> wrapperGetHandler( v8::Local<v8::String> name, const v8::AccessorInfo &info) {
- return getWrapper( info.This() )->get( name );
- }
-
- v8::Handle<v8::FunctionTemplate> getObjectWrapperTemplate(V8Scope* scope) {
- v8::Handle<v8::FunctionTemplate> t = scope->createV8Function(wrapperCons);
- t->InstanceTemplate()->SetNamedPropertyHandler( wrapperGetHandler );
- return t;
- }
-}