bson 0.1.8 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -1
- package/browser_build/bson.js +205 -176
- package/build/Release/bson.exp +0 -0
- package/build/Release/bson.lib +0 -0
- package/build/Release/bson.node +0 -0
- package/build/Release/bson.pdb +0 -0
- package/build/Release/obj/bson/bson.lastbuildstate +2 -0
- package/build/Release/obj/bson/bson.node.intermediate.manifest +10 -0
- package/build/Release/obj/bson/bson.obj +0 -0
- package/build/Release/obj/bson/bson.vcxprojResolveAssemblyReference.cache +0 -0
- package/build/Release/obj/bson/bson.write.1.tlog +3 -0
- package/build/Release/obj/bson/cl.command.1.tlog +0 -0
- package/build/Release/obj/bson/cl.read.1.tlog +0 -0
- package/build/Release/obj/bson/cl.write.1.tlog +0 -0
- package/build/Release/obj/bson/link.command.1.tlog +0 -0
- package/build/Release/obj/bson/link.read.1.tlog +0 -0
- package/build/Release/obj/bson/link.write.1.tlog +0 -0
- package/build/Release/obj/bson/mt.command.1.tlog +0 -0
- package/build/Release/obj/bson/mt.read.1.tlog +0 -0
- package/build/Release/obj/bson/mt.write.1.tlog +0 -0
- package/build/Release/obj/bson/vcwindows7.1sdk.pdb +0 -0
- package/build/binding.sln +21 -0
- package/build/bson.vcxproj +127 -0
- package/build/bson.vcxproj.filters +19 -0
- package/build/config.gypi +17 -8
- package/ext/bson.cc +68 -29
- package/ext/bson.h +9 -5
- package/ext/win32/ia32/bson.node +0 -0
- package/ext/win32/x64/bson.node +0 -0
- package/lib/bson/bson.js +192 -172
- package/lib/bson/objectid.js +4 -4
- package/package.json +2 -2
- package/benchmarks/benchmarks.js +0 -130
- package/build/Makefile +0 -355
- package/build/Release/.deps/Release/bson.node.d +0 -1
- package/build/Release/.deps/Release/obj.target/bson/ext/bson.o.d +0 -34
- package/build/Release/linker.lock +0 -0
- package/build/Release/obj.target/bson/ext/bson.o +0 -0
- package/build/binding.Makefile +0 -6
- package/build/bson.target.mk +0 -154
- package/build/gyp-mac-tool +0 -211
- package/test/browser/browser_example.htm +0 -19
- package/test/browser/bson_test.js +0 -260
- package/test/browser/nodeunit.js +0 -2034
- package/test/browser/suite2.js +0 -13
- package/test/browser/suite3.js +0 -7
- package/test/browser/test.html +0 -30
- package/test/node/bson_array_test.js +0 -240
- package/test/node/bson_parser_comparision_test.js +0 -493
- package/test/node/bson_test.js +0 -1694
- package/test/node/bson_typed_array_test.js +0 -392
- package/test/node/data/test_gs_weird_bug.png +0 -0
- package/test/node/test_full_bson.js +0 -315
- package/test/node/to_bson_test.js +0 -109
- package/test/node/tools/utils.js +0 -80
|
Binary file
|
|
Binary file
|
package/build/Release/bson.node
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
|
2
|
+
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
|
3
|
+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
4
|
+
<security>
|
|
5
|
+
<requestedPrivileges>
|
|
6
|
+
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
|
7
|
+
</requestedPrivileges>
|
|
8
|
+
</security>
|
|
9
|
+
</trustInfo>
|
|
10
|
+
</assembly>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Microsoft Visual Studio Solution File, Format Version 11.00
|
|
2
|
+
# Visual Studio 2010
|
|
3
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bson", "bson.vcxproj", "{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}"
|
|
4
|
+
EndProject
|
|
5
|
+
Global
|
|
6
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
7
|
+
Debug|x64 = Debug|x64
|
|
8
|
+
Release|x64 = Release|x64
|
|
9
|
+
EndGlobalSection
|
|
10
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
11
|
+
{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}.Debug|x64.ActiveCfg = Debug|x64
|
|
12
|
+
{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}.Debug|x64.Build.0 = Debug|x64
|
|
13
|
+
{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}.Release|x64.ActiveCfg = Release|x64
|
|
14
|
+
{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}.Release|x64.Build.0 = Release|x64
|
|
15
|
+
EndGlobalSection
|
|
16
|
+
GlobalSection(SolutionProperties) = preSolution
|
|
17
|
+
HideSolutionNode = FALSE
|
|
18
|
+
EndGlobalSection
|
|
19
|
+
GlobalSection(NestedProjects) = preSolution
|
|
20
|
+
EndGlobalSection
|
|
21
|
+
EndGlobal
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
|
5
|
+
<Configuration>Debug</Configuration>
|
|
6
|
+
<Platform>x64</Platform>
|
|
7
|
+
</ProjectConfiguration>
|
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
|
9
|
+
<Configuration>Release</Configuration>
|
|
10
|
+
<Platform>x64</Platform>
|
|
11
|
+
</ProjectConfiguration>
|
|
12
|
+
</ItemGroup>
|
|
13
|
+
<PropertyGroup Label="Globals">
|
|
14
|
+
<ProjectGuid>{C480D2C0-7E29-C7A7-FD22-F87AD7E5A4C6}</ProjectGuid>
|
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
|
16
|
+
<RootNamespace>bson</RootNamespace>
|
|
17
|
+
</PropertyGroup>
|
|
18
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
|
19
|
+
<PropertyGroup Label="Configuration">
|
|
20
|
+
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
21
|
+
</PropertyGroup>
|
|
22
|
+
<PropertyGroup Label="Locals">
|
|
23
|
+
<PlatformToolset>Windows7.1SDK</PlatformToolset>
|
|
24
|
+
</PropertyGroup>
|
|
25
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
|
26
|
+
<ImportGroup Label="ExtensionSettings"/>
|
|
27
|
+
<ImportGroup Label="PropertySheets">
|
|
28
|
+
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
|
29
|
+
</ImportGroup>
|
|
30
|
+
<PropertyGroup Label="UserMacros"/>
|
|
31
|
+
<PropertyGroup>
|
|
32
|
+
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
|
|
33
|
+
<IgnoreImportLibrary>true</IgnoreImportLibrary>
|
|
34
|
+
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
|
|
35
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
36
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
37
|
+
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
|
38
|
+
<TargetExt>.node</TargetExt>
|
|
39
|
+
<TargetName>$(ProjectName)</TargetName>
|
|
40
|
+
<TargetPath>$(OutDir)\$(ProjectName).node</TargetPath>
|
|
41
|
+
</PropertyGroup>
|
|
42
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
43
|
+
<ClCompile>
|
|
44
|
+
<AdditionalIncludeDirectories>C:\Users\ck\.node-gyp\0.10.13\src;C:\Users\ck\.node-gyp\0.10.13\deps\uv\include;C:\Users\ck\.node-gyp\0.10.13\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
45
|
+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
46
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
47
|
+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
48
|
+
<DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
49
|
+
<ExceptionHandling>Sync</ExceptionHandling>
|
|
50
|
+
<MinimalRebuild>false</MinimalRebuild>
|
|
51
|
+
<OmitFramePointers>false</OmitFramePointers>
|
|
52
|
+
<Optimization>Disabled</Optimization>
|
|
53
|
+
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;BUILDING_V8_SHARED=1;BUILDING_UV_SHARED=1;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
54
|
+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
55
|
+
<StringPooling>true</StringPooling>
|
|
56
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
57
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
58
|
+
<WarningLevel>Level3</WarningLevel>
|
|
59
|
+
</ClCompile>
|
|
60
|
+
<Link>
|
|
61
|
+
<AdditionalDependencies>C:\Users\ck\.node-gyp\0.10.13\$(Configuration)\node.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
62
|
+
<AllowIsolation>true</AllowIsolation>
|
|
63
|
+
<DataExecutionPrevention>true</DataExecutionPrevention>
|
|
64
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
65
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
66
|
+
<RandomizedBaseAddress>true</RandomizedBaseAddress>
|
|
67
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
68
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
69
|
+
</Link>
|
|
70
|
+
<ResourceCompile>
|
|
71
|
+
<AdditionalIncludeDirectories>C:\Users\ck\.node-gyp\0.10.13\src;C:\Users\ck\.node-gyp\0.10.13\deps\uv\include;C:\Users\ck\.node-gyp\0.10.13\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
72
|
+
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;BUILDING_V8_SHARED=1;BUILDING_UV_SHARED=1;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
73
|
+
</ResourceCompile>
|
|
74
|
+
</ItemDefinitionGroup>
|
|
75
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
76
|
+
<ClCompile>
|
|
77
|
+
<AdditionalIncludeDirectories>C:\Users\ck\.node-gyp\0.10.13\src;C:\Users\ck\.node-gyp\0.10.13\deps\uv\include;C:\Users\ck\.node-gyp\0.10.13\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
78
|
+
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
|
79
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
80
|
+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
81
|
+
<DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
82
|
+
<ExceptionHandling>false</ExceptionHandling>
|
|
83
|
+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
|
84
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
85
|
+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
86
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
87
|
+
<OmitFramePointers>true</OmitFramePointers>
|
|
88
|
+
<Optimization>Full</Optimization>
|
|
89
|
+
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;BUILDING_V8_SHARED=1;BUILDING_UV_SHARED=1;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
90
|
+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
91
|
+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
|
92
|
+
<StringPooling>true</StringPooling>
|
|
93
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
94
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
95
|
+
<WarningLevel>Level3</WarningLevel>
|
|
96
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
97
|
+
</ClCompile>
|
|
98
|
+
<Lib>
|
|
99
|
+
<AdditionalOptions>/LTCG %(AdditionalOptions)</AdditionalOptions>
|
|
100
|
+
</Lib>
|
|
101
|
+
<Link>
|
|
102
|
+
<AdditionalDependencies>C:\Users\ck\.node-gyp\0.10.13\$(Configuration)\node.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
103
|
+
<AllowIsolation>true</AllowIsolation>
|
|
104
|
+
<DataExecutionPrevention>true</DataExecutionPrevention>
|
|
105
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
106
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
107
|
+
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
|
108
|
+
<OptimizeReferences>true</OptimizeReferences>
|
|
109
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
110
|
+
<RandomizedBaseAddress>true</RandomizedBaseAddress>
|
|
111
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
112
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
113
|
+
</Link>
|
|
114
|
+
<ResourceCompile>
|
|
115
|
+
<AdditionalIncludeDirectories>C:\Users\ck\.node-gyp\0.10.13\src;C:\Users\ck\.node-gyp\0.10.13\deps\uv\include;C:\Users\ck\.node-gyp\0.10.13\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
116
|
+
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;BUILDING_V8_SHARED=1;BUILDING_UV_SHARED=1;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
117
|
+
</ResourceCompile>
|
|
118
|
+
</ItemDefinitionGroup>
|
|
119
|
+
<ItemGroup>
|
|
120
|
+
<None Include="..\binding.gyp"/>
|
|
121
|
+
</ItemGroup>
|
|
122
|
+
<ItemGroup>
|
|
123
|
+
<ClCompile Include="..\ext\bson.cc"/>
|
|
124
|
+
</ItemGroup>
|
|
125
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
|
126
|
+
<ImportGroup Label="ExtensionTargets"/>
|
|
127
|
+
</Project>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup>
|
|
4
|
+
<Filter Include="..">
|
|
5
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
6
|
+
</Filter>
|
|
7
|
+
<Filter Include="..\ext">
|
|
8
|
+
<UniqueIdentifier>{3EE5B703-384C-67C2-8DE0-73108365DC85}</UniqueIdentifier>
|
|
9
|
+
</Filter>
|
|
10
|
+
</ItemGroup>
|
|
11
|
+
<ItemGroup>
|
|
12
|
+
<None Include="..\binding.gyp">
|
|
13
|
+
<Filter>..</Filter>
|
|
14
|
+
</None>
|
|
15
|
+
<ClCompile Include="..\ext\bson.cc">
|
|
16
|
+
<Filter>..\ext</Filter>
|
|
17
|
+
</ClCompile>
|
|
18
|
+
</ItemGroup>
|
|
19
|
+
</Project>
|
package/build/config.gypi
CHANGED
|
@@ -5,26 +5,35 @@
|
|
|
5
5
|
"default_configuration": "Release",
|
|
6
6
|
"defines": [],
|
|
7
7
|
"include_dirs": [],
|
|
8
|
-
"libraries": []
|
|
8
|
+
"libraries": [],
|
|
9
|
+
"msbuild_toolset": "Windows7.1SDK"
|
|
9
10
|
},
|
|
10
11
|
"variables": {
|
|
11
|
-
"clang":
|
|
12
|
-
"host_arch": "
|
|
12
|
+
"clang": 0,
|
|
13
|
+
"host_arch": "ia32",
|
|
13
14
|
"node_install_npm": "true",
|
|
14
|
-
"node_install_waf": "true",
|
|
15
15
|
"node_prefix": "",
|
|
16
|
+
"node_shared_cares": "false",
|
|
17
|
+
"node_shared_http_parser": "false",
|
|
18
|
+
"node_shared_libuv": "false",
|
|
16
19
|
"node_shared_openssl": "false",
|
|
17
20
|
"node_shared_v8": "false",
|
|
18
21
|
"node_shared_zlib": "false",
|
|
19
22
|
"node_tag": "",
|
|
20
23
|
"node_unsafe_optimizations": 0,
|
|
21
24
|
"node_use_dtrace": "false",
|
|
22
|
-
"node_use_etw": "
|
|
25
|
+
"node_use_etw": "true",
|
|
23
26
|
"node_use_openssl": "true",
|
|
27
|
+
"node_use_perfctr": "true",
|
|
28
|
+
"node_use_systemtap": "false",
|
|
29
|
+
"python": "C:\\Python27\\python.exe",
|
|
24
30
|
"target_arch": "x64",
|
|
31
|
+
"v8_enable_gdbjit": 0,
|
|
25
32
|
"v8_no_strict_aliasing": 1,
|
|
26
|
-
"v8_use_snapshot": "
|
|
27
|
-
"
|
|
28
|
-
"
|
|
33
|
+
"v8_use_snapshot": "false",
|
|
34
|
+
"visibility": "",
|
|
35
|
+
"nodedir": "C:\\Users\\ck\\.node-gyp\\0.10.13",
|
|
36
|
+
"copy_dev_lib": "true",
|
|
37
|
+
"standalone_static_library": 1
|
|
29
38
|
}
|
|
30
39
|
}
|
package/ext/bson.cc
CHANGED
|
@@ -65,8 +65,17 @@ void DataStream::CheckKey(const Local<String>& keyName)
|
|
|
65
65
|
size_t keyLength = keyName->Utf8Length();
|
|
66
66
|
if(keyLength == 0) return;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
// Allocate space for the key, do not need to zero terminate as WriteUtf8 does it
|
|
69
|
+
char* keyStringBuffer = (char*) alloca(keyLength + 1);
|
|
70
|
+
// Write the key to the allocated buffer
|
|
69
71
|
keyName->WriteUtf8(keyStringBuffer);
|
|
72
|
+
// Check for the zero terminator
|
|
73
|
+
char* terminator = strchr(keyStringBuffer, 0x00);
|
|
74
|
+
|
|
75
|
+
// If the location is not at the end of the string we've got an illegal 0x00 byte somewhere
|
|
76
|
+
if(terminator != &keyStringBuffer[keyLength]) {
|
|
77
|
+
ThrowAllocatedStringException(64+keyLength, "key %s must not contain null bytes", keyStringBuffer);
|
|
78
|
+
}
|
|
70
79
|
|
|
71
80
|
if(keyStringBuffer[0] == '$')
|
|
72
81
|
{
|
|
@@ -397,16 +406,16 @@ Local<String> BSONDeserializer::ReadObjectId()
|
|
|
397
406
|
return String::New(objectId, 12);
|
|
398
407
|
}
|
|
399
408
|
|
|
400
|
-
Handle<Value> BSONDeserializer::DeserializeDocument()
|
|
409
|
+
Handle<Value> BSONDeserializer::DeserializeDocument(bool promoteLongs)
|
|
401
410
|
{
|
|
402
411
|
uint32_t length = ReadUInt32();
|
|
403
412
|
if(length < 5) ThrowAllocatedStringException(64, "Bad BSON: Document is less than 5 bytes");
|
|
404
413
|
|
|
405
414
|
BSONDeserializer documentDeserializer(*this, length-4);
|
|
406
|
-
return documentDeserializer.DeserializeDocumentInternal();
|
|
415
|
+
return documentDeserializer.DeserializeDocumentInternal(promoteLongs);
|
|
407
416
|
}
|
|
408
417
|
|
|
409
|
-
Handle<Value> BSONDeserializer::DeserializeDocumentInternal()
|
|
418
|
+
Handle<Value> BSONDeserializer::DeserializeDocumentInternal(bool promoteLongs)
|
|
410
419
|
{
|
|
411
420
|
Local<Object> returnObject = Object::New();
|
|
412
421
|
|
|
@@ -414,7 +423,7 @@ Handle<Value> BSONDeserializer::DeserializeDocumentInternal()
|
|
|
414
423
|
{
|
|
415
424
|
BsonType type = (BsonType) ReadByte();
|
|
416
425
|
const Local<String>& name = ReadCString();
|
|
417
|
-
const Handle<Value>& value = DeserializeValue(type);
|
|
426
|
+
const Handle<Value>& value = DeserializeValue(type, promoteLongs);
|
|
418
427
|
returnObject->ForceSet(name, value);
|
|
419
428
|
}
|
|
420
429
|
if(p != pEnd) ThrowAllocatedStringException(64, "Bad BSON Document: Serialize consumed unexpected number of bytes");
|
|
@@ -432,16 +441,16 @@ Handle<Value> BSONDeserializer::DeserializeDocumentInternal()
|
|
|
432
441
|
}
|
|
433
442
|
}
|
|
434
443
|
|
|
435
|
-
Handle<Value> BSONDeserializer::DeserializeArray()
|
|
444
|
+
Handle<Value> BSONDeserializer::DeserializeArray(bool promoteLongs)
|
|
436
445
|
{
|
|
437
446
|
uint32_t length = ReadUInt32();
|
|
438
447
|
if(length < 5) ThrowAllocatedStringException(64, "Bad BSON: Array Document is less than 5 bytes");
|
|
439
448
|
|
|
440
449
|
BSONDeserializer documentDeserializer(*this, length-4);
|
|
441
|
-
return documentDeserializer.DeserializeArrayInternal();
|
|
450
|
+
return documentDeserializer.DeserializeArrayInternal(promoteLongs);
|
|
442
451
|
}
|
|
443
452
|
|
|
444
|
-
Handle<Value> BSONDeserializer::DeserializeArrayInternal()
|
|
453
|
+
Handle<Value> BSONDeserializer::DeserializeArrayInternal(bool promoteLongs)
|
|
445
454
|
{
|
|
446
455
|
Local<Array> returnArray = Array::New();
|
|
447
456
|
|
|
@@ -449,7 +458,7 @@ Handle<Value> BSONDeserializer::DeserializeArrayInternal()
|
|
|
449
458
|
{
|
|
450
459
|
BsonType type = (BsonType) ReadByte();
|
|
451
460
|
uint32_t index = ReadIntegerString();
|
|
452
|
-
const Handle<Value>& value = DeserializeValue(type);
|
|
461
|
+
const Handle<Value>& value = DeserializeValue(type, promoteLongs);
|
|
453
462
|
returnArray->Set(index, value);
|
|
454
463
|
}
|
|
455
464
|
if(p != pEnd) ThrowAllocatedStringException(64, "Bad BSON Array: Serialize consumed unexpected number of bytes");
|
|
@@ -457,7 +466,7 @@ Handle<Value> BSONDeserializer::DeserializeArrayInternal()
|
|
|
457
466
|
return returnArray;
|
|
458
467
|
}
|
|
459
468
|
|
|
460
|
-
Handle<Value> BSONDeserializer::DeserializeValue(BsonType type)
|
|
469
|
+
Handle<Value> BSONDeserializer::DeserializeValue(BsonType type, bool promoteLongs)
|
|
461
470
|
{
|
|
462
471
|
switch(type)
|
|
463
472
|
{
|
|
@@ -506,7 +515,7 @@ Handle<Value> BSONDeserializer::DeserializeValue(BsonType type)
|
|
|
506
515
|
{
|
|
507
516
|
ReadUInt32();
|
|
508
517
|
const Local<Value>& code = ReadString();
|
|
509
|
-
const Handle<Value>& scope = DeserializeDocument();
|
|
518
|
+
const Handle<Value>& scope = DeserializeDocument(promoteLongs);
|
|
510
519
|
Local<Value> argv[] = { code, scope->ToObject() };
|
|
511
520
|
return bson->codeConstructor->NewInstance(2, argv);
|
|
512
521
|
}
|
|
@@ -538,15 +547,19 @@ Handle<Value> BSONDeserializer::DeserializeValue(BsonType type)
|
|
|
538
547
|
int32_t lowBits = (int32_t) ReadInt32();
|
|
539
548
|
int32_t highBits = (int32_t) ReadInt32();
|
|
540
549
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
// Promote long is enabled
|
|
551
|
+
if(promoteLongs) {
|
|
552
|
+
// If value is < 2^53 and >-2^53
|
|
553
|
+
if((highBits < 0x200000 || (highBits == 0x200000 && lowBits == 0)) && highBits >= -0x200000) {
|
|
554
|
+
// Adjust the pointer and read as 64 bit value
|
|
555
|
+
p -= 8;
|
|
556
|
+
// Read the 64 bit value
|
|
557
|
+
int64_t finalValue = (int64_t) ReadInt64();
|
|
558
|
+
return Number::New(finalValue);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
549
561
|
|
|
562
|
+
// Decode the Long value
|
|
550
563
|
Local<Value> argv[] = { Int32::New(lowBits), Int32::New(highBits) };
|
|
551
564
|
return bson->longConstructor->NewInstance(2, argv);
|
|
552
565
|
}
|
|
@@ -555,10 +568,10 @@ Handle<Value> BSONDeserializer::DeserializeValue(BsonType type)
|
|
|
555
568
|
return Date::New((double) ReadInt64());
|
|
556
569
|
|
|
557
570
|
case BSON_TYPE_ARRAY:
|
|
558
|
-
return DeserializeArray();
|
|
571
|
+
return DeserializeArray(promoteLongs);
|
|
559
572
|
|
|
560
573
|
case BSON_TYPE_OBJECT:
|
|
561
|
-
return DeserializeDocument();
|
|
574
|
+
return DeserializeDocument(promoteLongs);
|
|
562
575
|
|
|
563
576
|
case BSON_TYPE_SYMBOL:
|
|
564
577
|
{
|
|
@@ -730,11 +743,21 @@ Handle<Value> BSON::BSONDeserialize(const Arguments &args)
|
|
|
730
743
|
{
|
|
731
744
|
HandleScope scope;
|
|
732
745
|
|
|
733
|
-
//
|
|
734
|
-
if(
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
746
|
+
// Fail if the first argument is not a string or a buffer
|
|
747
|
+
if(args.Length() > 1 && !args[0]->IsString() && !Buffer::HasInstance(args[0]))
|
|
748
|
+
return VException("First Argument must be a Buffer or String.");
|
|
749
|
+
|
|
750
|
+
// Promote longs
|
|
751
|
+
bool promoteLongs = true;
|
|
752
|
+
|
|
753
|
+
// If we have an options object
|
|
754
|
+
if(args.Length() == 2 && args[1]->IsObject()) {
|
|
755
|
+
Local<Object> options = args[1]->ToObject();
|
|
756
|
+
|
|
757
|
+
if(options->Has(String::New("promoteLongs"))) {
|
|
758
|
+
promoteLongs = options->Get(String::New("promoteLongs"))->ToBoolean()->Value();
|
|
759
|
+
}
|
|
760
|
+
}
|
|
738
761
|
|
|
739
762
|
// Define pointer to data
|
|
740
763
|
Local<Object> obj = args[0]->ToObject();
|
|
@@ -760,7 +783,8 @@ Handle<Value> BSON::BSONDeserialize(const Arguments &args)
|
|
|
760
783
|
try
|
|
761
784
|
{
|
|
762
785
|
BSONDeserializer deserializer(bson, data, length);
|
|
763
|
-
|
|
786
|
+
// deserializer.promoteLongs = promoteLongs;
|
|
787
|
+
return deserializer.DeserializeDocument(promoteLongs);
|
|
764
788
|
}
|
|
765
789
|
catch(char* exception)
|
|
766
790
|
{
|
|
@@ -785,7 +809,8 @@ Handle<Value> BSON::BSONDeserialize(const Arguments &args)
|
|
|
785
809
|
try
|
|
786
810
|
{
|
|
787
811
|
BSONDeserializer deserializer(bson, data, len);
|
|
788
|
-
|
|
812
|
+
// deserializer.promoteLongs = promoteLongs;
|
|
813
|
+
Handle<Value> result = deserializer.DeserializeDocument(promoteLongs);
|
|
789
814
|
free(data);
|
|
790
815
|
return result;
|
|
791
816
|
|
|
@@ -828,6 +853,9 @@ Handle<Value> BSON::BSONSerialize(const Arguments &args)
|
|
|
828
853
|
if(args.Length() == 4 && !args[0]->IsObject() && !args[1]->IsBoolean() && !args[2]->IsBoolean() && !args[3]->IsBoolean()) return VException("One, two or tree arguments required - [object] or [object, boolean] or [object, boolean, boolean] or [object, boolean, boolean, boolean]");
|
|
829
854
|
if(args.Length() > 4) return VException("One, two, tree or four arguments required - [object] or [object, boolean] or [object, boolean, boolean] or [object, boolean, boolean, boolean]");
|
|
830
855
|
|
|
856
|
+
// Check if we have an array as the object
|
|
857
|
+
if(args[0]->IsArray()) return VException("Only javascript objects supported");
|
|
858
|
+
|
|
831
859
|
// Unpack the BSON parser instance
|
|
832
860
|
BSON *bson = ObjectWrap::Unwrap<BSON>(args.This());
|
|
833
861
|
|
|
@@ -960,6 +988,17 @@ Handle<Value> BSON::BSONDeserializeStream(const Arguments &args)
|
|
|
960
988
|
uint32_t numberOfDocuments = args[2]->Uint32Value();
|
|
961
989
|
uint32_t index = args[1]->Uint32Value();
|
|
962
990
|
uint32_t resultIndex = args[4]->Uint32Value();
|
|
991
|
+
bool promoteLongs = true;
|
|
992
|
+
|
|
993
|
+
// Check for the value promoteLongs in the options object
|
|
994
|
+
if(args.Length() == 6) {
|
|
995
|
+
Local<Object> options = args[5]->ToObject();
|
|
996
|
+
|
|
997
|
+
// Check if we have the promoteLong variable
|
|
998
|
+
if(options->Has(String::New("promoteLongs"))) {
|
|
999
|
+
promoteLongs = options->Get(String::New("promoteLongs"))->ToBoolean()->Value();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
963
1002
|
|
|
964
1003
|
// Unpack the BSON parser instance
|
|
965
1004
|
BSON *bson = ObjectWrap::Unwrap<BSON>(args.This());
|
|
@@ -982,7 +1021,7 @@ Handle<Value> BSON::BSONDeserializeStream(const Arguments &args)
|
|
|
982
1021
|
{
|
|
983
1022
|
try
|
|
984
1023
|
{
|
|
985
|
-
documents->Set(i + resultIndex, deserializer.DeserializeDocument());
|
|
1024
|
+
documents->Set(i + resultIndex, deserializer.DeserializeDocument(promoteLongs));
|
|
986
1025
|
}
|
|
987
1026
|
catch (char* exception)
|
|
988
1027
|
{
|
package/ext/bson.h
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
//===========================================================================
|
|
7
7
|
|
|
8
|
+
#ifdef __arm__
|
|
9
|
+
#define USE_MISALIGNED_MEMORY_ACCESS 0
|
|
10
|
+
#else
|
|
8
11
|
#define USE_MISALIGNED_MEMORY_ACCESS 1
|
|
12
|
+
#endif
|
|
9
13
|
|
|
10
14
|
#include <node.h>
|
|
11
15
|
#include <node_object_wrap.h>
|
|
@@ -230,7 +234,7 @@ public:
|
|
|
230
234
|
BSONDeserializer(BSON* aBson, char* data, size_t length);
|
|
231
235
|
BSONDeserializer(BSONDeserializer& parentSerializer, size_t length);
|
|
232
236
|
|
|
233
|
-
Handle<Value> DeserializeDocument();
|
|
237
|
+
Handle<Value> DeserializeDocument(bool promoteLongs);
|
|
234
238
|
|
|
235
239
|
bool HasMoreData() const { return p < pEnd; }
|
|
236
240
|
Local<String> ReadCString();
|
|
@@ -255,10 +259,10 @@ public:
|
|
|
255
259
|
size_t GetSerializeSize() const { return p - pStart; }
|
|
256
260
|
|
|
257
261
|
private:
|
|
258
|
-
Handle<Value> DeserializeArray();
|
|
259
|
-
Handle<Value> DeserializeValue(BsonType type);
|
|
260
|
-
Handle<Value> DeserializeDocumentInternal();
|
|
261
|
-
Handle<Value> DeserializeArrayInternal();
|
|
262
|
+
Handle<Value> DeserializeArray(bool promoteLongs);
|
|
263
|
+
Handle<Value> DeserializeValue(BsonType type, bool promoteLongs);
|
|
264
|
+
Handle<Value> DeserializeDocumentInternal(bool promoteLongs);
|
|
265
|
+
Handle<Value> DeserializeArrayInternal(bool promoteLongs);
|
|
262
266
|
|
|
263
267
|
BSON* bson;
|
|
264
268
|
char* const pStart;
|
package/ext/win32/ia32/bson.node
CHANGED
|
Binary file
|
package/ext/win32/x64/bson.node
CHANGED
|
Binary file
|