diff options
Diffstat (limited to 'scripting/engine_spidermonkey.h')
-rw-r--r-- | scripting/engine_spidermonkey.h | 20 |
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_; + }; } |