summaryrefslogtreecommitdiff
path: root/scripting/engine_spidermonkey.h
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-03-25 19:21:32 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-03-25 19:21:32 +0100
commit0ca01a91ae0a3562e54c226e7b9512feb2ea83d0 (patch)
tree2b3886e435b0217d6afd63a213b04d32bb4b4f6f /scripting/engine_spidermonkey.h
parenta696359b248adef0cc8576fce3f473535e995136 (diff)
downloadmongodb-0ca01a91ae0a3562e54c226e7b9512feb2ea83d0.tar.gz
Imported Upstream version 1.4.0
Diffstat (limited to 'scripting/engine_spidermonkey.h')
-rw-r--r--scripting/engine_spidermonkey.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/scripting/engine_spidermonkey.h b/scripting/engine_spidermonkey.h
index 8aeb56c..a39d8fb 100644
--- a/scripting/engine_spidermonkey.h
+++ b/scripting/engine_spidermonkey.h
@@ -93,6 +93,7 @@ namespace mongo {
extern JSClass dbref_class;
extern JSClass bindata_class;
extern JSClass timestamp_class;
+ extern JSClass numberlong_class;
extern JSClass minkey_class;
extern JSClass maxkey_class;
@@ -112,5 +113,22 @@ namespace mongo {
#define JSVAL_IS_OID(v) ( JSVAL_IS_OBJECT( v ) && JS_InstanceOf( cx , JSVAL_TO_OBJECT( v ) , &object_id_class , 0 ) )
bool isDate( JSContext * cx , JSObject * o );
-
+
+ // JS private data must be 2byte aligned, so we use a holder to refer to an unaligned pointer.
+ struct BinDataHolder {
+ BinDataHolder( const char *c, int copyLen = -1 ) :
+ c_( const_cast< char * >( c ) ),
+ iFree_( copyLen != -1 ) {
+ if ( copyLen != -1 ) {
+ c_ = (char*)malloc( copyLen );
+ memcpy( c_, c, copyLen );
+ }
+ }
+ ~BinDataHolder() {
+ if ( iFree_ )
+ free( c_ );
+ }
+ char *c_;
+ bool iFree_;
+ };
}