Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: clean up warning on std::map use
Browse files Browse the repository at this point in the history
Remove std::map use on the stack for setting up proxy traps. Use a
static sized array instead. This avoid warning C4530 about unwind
semantics not enabled in case of exception as well.
  • Loading branch information
curtisman authored and Jianchun Xu committed Jun 29, 2015
1 parent ffe5db1 commit 2bb7fc3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/src/jsrtcontextshim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ namespace jsrt
{
// V8 Global is actually proxy where the actual global is it's prototype.
// We will fake it here.
std::map<jsrt::ProxyTraps, JsNativeFunction> proxyTraps;
JsNativeFunction proxyTraps[ProxyTraps::TrapCount] = {};
proxyTraps[GetPrototypeOfTrap] = ProxyOfGlobalGetPrototypeOfCallback;
return CreateProxy(globalObject, proxyTraps, value);
});
Expand Down
7 changes: 1 addition & 6 deletions deps/chakrashim/src/jsrtcrosscontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "v8.h"
#include "jsrtutils.h"
#include <map>
#include <assert.h>

namespace jsrt
Expand Down Expand Up @@ -95,11 +94,7 @@ namespace jsrt
}
*info = crossContextInfo;
}
<<<<<<< HEAD

=======

>>>>>>> chakrashim: fix toString on cross context objects
return true;
}

Expand Down Expand Up @@ -522,7 +517,7 @@ namespace jsrt

ContextShim::Scope scope(toContextShim);

std::map<ProxyTraps, JsNativeFunction> proxyConf;
JsNativeFunction proxyConf[ProxyTraps::TrapCount] = {};
proxyConf[ProxyTraps::ApplyTrap] = CrossContextCallback<ProxyTraps::ApplyTrap, 3>;
proxyConf[ProxyTraps::ConstructTrap] = CrossContextCallback<ProxyTraps::ConstructTrap, 2>;
proxyConf[ProxyTraps::DefinePropertyTrap] = CrossContextCallback<ProxyTraps::DefinePropertyTrap, 3>;
Expand Down
11 changes: 5 additions & 6 deletions deps/chakrashim/src/jsrtproxyutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "jsrtutils.h"
#include <string>
#include <map>
#include <assert.h>

namespace jsrt
Expand Down Expand Up @@ -70,7 +69,7 @@ namespace jsrt
return error;
}

JsErrorCode CreateProxyTrapConfig(const std::map<ProxyTraps, JsNativeFunction>& config, _Out_ JsValueRef *confObj)
JsErrorCode CreateProxyTrapConfig(const JsNativeFunction proxyConf[ProxyTraps::TrapCount], _Out_ JsValueRef *confObj)
{
JsErrorCode error = JsNoError;

Expand All @@ -80,9 +79,9 @@ namespace jsrt

// Set the properties of the proxy configuration object according to the given map of proxy traps and function handlers
// For each proxy trap - set the given handler using the appropriate javascript name
for (std::map<ProxyTraps, JsNativeFunction>::const_iterator it = config.begin(); it != config.end(); it++)
for (int i = 0; i < ProxyTraps::TrapCount; i++)
{
error = SetPropertyOnTrapConfig(it->first, it->second, *confObj);
error = SetPropertyOnTrapConfig((ProxyTraps)i, proxyConf[i], *confObj);
if (error != JsNoError) return error;
}

Expand All @@ -91,7 +90,7 @@ namespace jsrt

JsErrorCode CreateProxy(
_In_ JsValueRef target,
const std::map<ProxyTraps, JsNativeFunction>& config,
_In_ const JsNativeFunction config[ProxyTraps::TrapCount],
_Out_ JsValueRef *result
)
{
Expand Down Expand Up @@ -157,7 +156,7 @@ namespace jsrt

*isUInt32 = true;
// use std:stoull as it the most comprehenisve way to convert string to int
// there is some performance issue here, so we migth optimiaze this code using the reuslts in here:
// there is some performance issue here, so we migth optimiaze this code using the results in here:
// string to int conversion - naive approach is the fastest: http://tinodidriksen.com/2010/02/16/cpp-convert-string-to-int-speed/

wchar_t* strEnd = const_cast<wchar_t*>(strPtr) + strLength;
Expand Down
3 changes: 1 addition & 2 deletions deps/chakrashim/src/jsrtproxyutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "jsrt.h"
#include "jsrtutils.h"
#include <map>

namespace jsrt
{
Expand Down Expand Up @@ -53,7 +52,7 @@ namespace jsrt

JsErrorCode CreateProxy(
_In_ JsValueRef target,
_In_ const std::map<ProxyTraps, JsNativeFunction>& conf,
_In_ const JsNativeFunction config[ProxyTraps::TrapCount],
_Out_ JsValueRef *result
);

Expand Down
3 changes: 1 addition & 2 deletions deps/chakrashim/src/v8objecttemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "v8chakra.h"
#include "jsrtutils.h"

#include <map>

using namespace jsrt;
using namespace std;
Expand Down Expand Up @@ -820,7 +819,7 @@ namespace v8
{
JsValueRef newInstanceTargetRef = newInstanceRef;

map<ProxyTraps, JsNativeFunction> proxyConf;
JsNativeFunction proxyConf[ProxyTraps::TrapCount] = {};

if (objectTemplateData->indexedPropertyGetter != nullptr || objectTemplateData->namedPropertyGetter != nullptr)
proxyConf[ProxyTraps::GetTrap] = GetCallback;
Expand Down

0 comments on commit 2bb7fc3

Please sign in to comment.