Add some more helper methods to Value

Reviewed By: mhorowitz

Differential Revision: D4197278

fbshipit-source-id: 9a538ff2747d32a54d42627a9f78e4a348dce639
This commit is contained in:
Pieter De Baets
2016-11-18 06:25:24 -08:00
committed by Facebook Github Bot
parent 1604f10889
commit 674d86cdcb
13 changed files with 121 additions and 133 deletions

View File

@@ -10,6 +10,8 @@
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
using namespace facebook::react;
static JSValueRef nativeCaptureHeap(
JSContextRef ctx,
JSObjectRef function,
@@ -19,18 +21,18 @@ static JSValueRef nativeCaptureHeap(
JSValueRef* exception) {
if (argumentCount < 1) {
if (exception) {
*exception = facebook::react::makeJSCException(
*exception = Value::makeError(
ctx,
"nativeCaptureHeap requires the path to save the capture");
}
return JSValueMakeUndefined(ctx);
return Value::makeUndefined(ctx);
}
JSStringRef outputFilename = JSValueToStringCopy(ctx, arguments[0], exception);
std::string finalFilename = facebook::react::String::ref(outputFilename).str();
JSCaptureHeap(ctx, finalFilename.c_str(), exception);
JSStringRelease(outputFilename);
return JSValueMakeUndefined(ctx);
return Value::makeUndefined(ctx);
}
#endif // WITH_FB_MEMORY_PROFILING