本文整理汇总了C++中Local::IsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::IsString方法的具体用法?C++ Local::IsString怎么用?C++ Local::IsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::IsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isGlobalAgent
// Check if this appmetrics agent native module is loaded via the node-hc command.
// This is actually checking if this module has appmetrics/launcher.js as it's grandparent.
// For reference:
// A locally loaded module would have ancestry like:
// ...
// ^-- some_module_that_does_require('appmetrics') (grandparent)
// ^--- .../node_modules/appmetrics/index.js (parent)
// ^-- .../node_modules/appmetrics/appmetrics.node (this)
//
// A globally loaded module would have ancestry like:
// .../node_modules/appmetrics/launcher.js (grandparent)
// ^--- .../node_modules/appmetrics/index.js (parent)
// ^-- .../node_modules/appmetrics/appmetrics.node (this)
//
static bool isGlobalAgent(Handle<Object> module) {
Nan::HandleScope scope;
Local<Value> parent = module->Get(Nan::New<String>("parent").ToLocalChecked());
if (parent->IsObject()) {
Local<Value> filename = parent->ToObject()->Get(Nan::New<String>("filename").ToLocalChecked());
if (filename->IsString() && isAppMetricsFile("index.js", toStdString(filename->ToString()))) {
Local<Value> grandparent = parent->ToObject()->Get(Nan::New<String>("parent").ToLocalChecked());
Local<Value> gpfilename = grandparent->ToObject()->Get(Nan::New<String>("filename").ToLocalChecked());
if (gpfilename->IsString() && isAppMetricsFile("launcher.js", toStdString(gpfilename->ToString()))) {
return true;
}
}
}
return false;
}
示例2: find
Handle<Value> jsWindow::SetProperty(Local<String> name, Local<Value> value, const AccessorInfo& info)
{
Handle<Value> val;
std::string key = value_to_string(name);
vector<string>::iterator it = find(ro_props.begin(), ro_props.end(), key);
if (it == ro_props.end()) {
props[key] = Persistent<Value>::New(value);
val = value;
} else if (key == "location" && value->IsString()) {
std::string uri = value_to_string(value);
if (location->url.tostring() == uri) {
// reload
} else if (uri == "about:blank") {
// assign
location->url.protocol = "about";
location->url.host = "blank";
} else {
location->url.assign_with_referer(uri);
history->push_back(uri);
load(uri);
}
// todo - log the location changes
}
return val;
}
示例3: scope
static gboolean
gum_kernel_scan_context_emit_match (GumAddress address,
gsize size,
GumKernelScanContext * self)
{
ScriptScope scope (self->core->script);
auto isolate = self->core->isolate;
auto context = isolate->GetCurrentContext ();
gboolean proceed = TRUE;
auto on_match = Local<Function>::New (isolate, *self->on_match);
auto recv = Undefined (isolate);
Handle<Value> argv[] = {
_gum_v8_uint64_new (address, self->core),
Integer::NewFromUnsigned (isolate, size)
};
Local<Value> result;
if (on_match->Call (context, recv, G_N_ELEMENTS (argv), argv)
.ToLocal (&result) && result->IsString ())
{
v8::String::Utf8Value str (isolate, result);
proceed = strcmp (*str, "stop") != 0;
}
return proceed;
}
示例4: module
static gboolean
gum_script_process_handle_module_match (const GumModuleDetails * details,
gpointer user_data)
{
GumScriptMatchContext * ctx =
static_cast<GumScriptMatchContext *> (user_data);
GumScriptCore * core = ctx->self->core;
Isolate * isolate = ctx->isolate;
Local<Object> module (Object::New (isolate));
_gum_script_set_ascii (module, "name", details->name, core);
_gum_script_set_pointer (module, "base", details->range->base_address, core);
_gum_script_set_uint (module, "size", details->range->size, core);
_gum_script_set_utf8 (module, "path", details->path, core);
Handle<Value> argv[] = {
module
};
Local<Value> result = ctx->on_match->Call (ctx->receiver, 1, argv);
gboolean proceed = TRUE;
if (!result.IsEmpty () && result->IsString ())
{
String::Utf8Value str (result);
proceed = (strcmp (*str, "stop") != 0);
}
return proceed;
}
示例5: scope
JNIEXPORT jobject JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeEvalString
(JNIEnv *env, jobject self, jstring source, jstring filename)
{
HandleScope scope(V8Runtime::v8_isolate);
titanium::JNIScope jniScope(env);
Local<Value> jsSource = TypeConverter::javaStringToJsString(V8Runtime::v8_isolate, env, source);
if (jsSource.IsEmpty() || !jsSource->IsString()) {
LOGE(TAG, "Error converting Javascript string, aborting evalString");
return NULL;
}
Local<Value> jsFilename = TypeConverter::javaStringToJsString(V8Runtime::v8_isolate, env, filename);
TryCatch tryCatch(V8Runtime::v8_isolate);
Local<Script> script = Script::Compile(jsSource.As<String>(), jsFilename.As<String>());
Local<Value> result = script->Run();
if (tryCatch.HasCaught()) {
V8Util::openJSErrorDialog(V8Runtime::v8_isolate, tryCatch);
V8Util::reportException(V8Runtime::v8_isolate, tryCatch, true);
return NULL;
}
return TypeConverter::jsValueToJavaObject(V8Runtime::v8_isolate, env, result);
}
示例6: if
static Local<Value> convert_result(uint64_t result, Local<Value> enc_val) {
Local<Value> result_val;
if (node::Buffer::HasInstance(enc_val)) {
result_val = enc_val;
if (node::Buffer::Length(result_val) >= sizeof(uint64_t)) {
char* out_buf = node::Buffer::Data(result_val);
*(reinterpret_cast<uint64_t*>(&out_buf[0])) = result;
} else {
Nan::ThrowError("Buffer argument too small");
}
} else if (enc_val->IsString()) {
node::encoding enc = parse_encoding(enc_val);
if (enc == node::BASE64 ||
enc == node::HEX ||
enc == node::BINARY ||
enc == node::BUFFER) {
result_val = convert_result(result, enc);
} else {
Nan::ThrowError("invalid encoding");
}
} else {
Nan::ThrowTypeError("argument must be a Buffer or string");
}
return result_val;
}
示例7: if
void
encodeArray(bson_buffer *bb, const char *name, const Local<Value> element) {
Local<Array> a = Array::Cast(*element);
bson_buffer *arr = bson_append_start_array(bb, name);
for (int i = 0, l=a->Length(); i < l; i++) {
Local<Value> val = a->Get(Number::New(i));
stringstream keybuf;
string keyval;
keybuf << i << endl;
keybuf >> keyval;
if (val->IsString()) {
encodeString(arr, keyval.c_str(), val);
}
else if (val->IsInt32()) {
encodeInteger(arr, keyval.c_str(), val);
}
else if (val->IsNumber()) {
encodeNumber(arr, keyval.c_str(), val);
}
else if (val->IsBoolean()) {
encodeBoolean(arr, keyval.c_str(), val);
}
else if (val->IsArray()) {
encodeArray(arr, keyval.c_str(), val);
}
else if (val->IsObject()) {
bson bson(encodeObject(val));
bson_append_bson(arr, keyval.c_str(), &bson);
bson_destroy(&bson);
}
}
bson_append_finish_object(arr);
}
示例8: argToKey
argtokey_callback_t argToKey(const Local<Value> &val, MDB_val &key, bool keyIsUint32) {
// Check key type
if (keyIsUint32 && !val->IsUint32()) {
Nan::ThrowError("Invalid key. keyIsUint32 specified on the database, but the given key was not an unsigned 32-bit integer");
return nullptr;
}
if (!keyIsUint32 && !val->IsString()) {
Nan::ThrowError("Invalid key. String key expected, because keyIsUint32 isn't specified on the database.");
return nullptr;
}
// Handle uint32_t key
if (keyIsUint32) {
uint32_t *v = new uint32_t;
*v = val->Uint32Value();
key.mv_size = sizeof(uint32_t);
key.mv_data = v;
return ([](MDB_val &key) -> void {
delete (uint32_t*)key.mv_data;
});
}
// Handle string key
CustomExternalStringResource::writeTo(val->ToString(), &key);
return ([](MDB_val &key) -> void {
delete[] (uint16_t*)key.mv_data;
});
return nullptr;
}
示例9: range
static gboolean
gum_v8_process_handle_malloc_range_match (const GumMallocRangeDetails * details,
gpointer user_data)
{
GumV8MatchContext * ctx =
static_cast<GumV8MatchContext *> (user_data);
GumV8Core * core = ctx->self->core;
Isolate * isolate = ctx->isolate;
Local<Object> range (Object::New (isolate));
_gum_v8_object_set_pointer (range, "base", details->range->base_address, core);
_gum_v8_object_set_uint (range, "size", details->range->size, core);
Handle<Value> argv[] = {
range
};
Local<Value> result = ctx->on_match->Call (ctx->receiver, 1, argv);
gboolean proceed = TRUE;
if (!result.IsEmpty () && result->IsString ())
{
String::Utf8Value str (result);
proceed = (strcmp (*str, "stop") != 0);
}
return proceed;
}
示例10: justificationSetter
void FieldDefn::justificationSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This());
OGRJustification justification;
std::string str = TOSTR(value);
if(value->IsString()){
if(str == "Left") {
justification = OJLeft;
} else if (str == "Right") {
justification = OJRight;
} else if (str == "Undefined") {
justification = OJUndefined;
} else {
NODE_THROW("Unrecognized justification");
return;
}
} else if (value->IsNull() || value->IsUndefined()){
justification = OJUndefined;
} else {
NODE_THROW("justification must be a string or undefined");
return;
}
def->this_->SetJustify(justification);
}
示例11: thread
static gboolean
gum_script_process_thread_match (const GumThreadDetails * details,
gpointer user_data)
{
GumScriptMatchContext * ctx =
static_cast<GumScriptMatchContext *> (user_data);
GumScriptCore * core = ctx->self->core;
Isolate * isolate = ctx->isolate;
if (gum_script_is_ignoring (details->id))
return TRUE;
Local<Object> thread (Object::New (isolate));
_gum_script_set (thread, "id", Number::New (isolate, details->id), core);
_gum_script_set (thread, "state", String::NewFromOneByte (isolate,
reinterpret_cast<const uint8_t *> (gum_script_thread_state_to_string (
details->state))),
core);
_gum_script_set (thread, "context", _gum_script_cpu_context_new (
&details->cpu_context, ctx->self->core), core);
Handle<Value> argv[] = { thread };
Local<Value> result = ctx->on_match->Call (ctx->receiver, 1, argv);
gboolean proceed = TRUE;
if (!result.IsEmpty () && result->IsString ())
{
String::Utf8Value str (result);
proceed = (strcmp (*str, "stop") != 0);
}
return proceed;
}
示例12: nameSetter
void FieldDefn::nameSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This());
if(!value->IsString()){
NODE_THROW("Name must be string");
return;
}
def->this_->SetName(TOSTR(value));
}
示例13: ThrowException
Handle<Value> Feature::addAttributes(const Arguments& args)
{
HandleScope scope;
Feature* fp = ObjectWrap::Unwrap<Feature>(args.This());
if (args.Length() > 0 ) {
Local<Value> value = args[0];
if (value->IsNull() || value->IsUndefined()) {
return ThrowException(Exception::TypeError(String::New("object expected")));
} else {
Local<Object> attr = value->ToObject();
try
{
Local<Array> names = attr->GetPropertyNames();
uint32_t i = 0;
uint32_t a_length = names->Length();
boost::scoped_ptr<mapnik::transcoder> tr(new mapnik::transcoder("utf8"));
while (i < a_length) {
Local<Value> name = names->Get(i)->ToString();
Local<Value> value = attr->Get(name);
if (value->IsString()) {
UnicodeString ustr = tr->transcode(TOSTR(value));
boost::put(*fp->get(),TOSTR(name),ustr);
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
int integer = value->IntegerValue();
boost::put(*fp->get(),TOSTR(name),integer);
} else {
double dub_val = value->NumberValue();
boost::put(*fp->get(),TOSTR(name),dub_val);
}
} else {
std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
}
i++;
}
}
catch (const std::exception & ex )
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
catch (...) {
return ThrowException(Exception::Error(
String::New("Unknown exception happended - please report bug")));
}
}
}
return Undefined();
}
示例14: ClassNameSetter
void Widget::ClassNameSetter(Local<String> name, Local<Value> value, const AccessorInfo& info)
{
HandleScope scope;
if (value->IsString()) {
ClutterActor *instance = ObjectWrap::Unwrap<Actor>(info.This())->_actor;
ObjectWrap::Unwrap<Widget>(info.This())->hasClassName = TRUE;
mx_stylable_set_style_class(MX_STYLABLE(instance), *String::Utf8Value(value->ToString()));
mx_stylable_set_style(MX_STYLABLE(instance), mx_style_get_default());
}
}
示例15: build_http_msg_buffer
void Msg_Struct::build_http_msg_buffer(Isolate* isolate, v8::Local<v8::Object> object, std::string &str) {
std::stringstream stream;
for(std::vector<Field_Info>::const_iterator iter = field_vec().begin();
iter != field_vec().end(); iter++) {
stream.str("");
stream << "\"" << iter->field_name << "\":";
Local<Value> value = object->Get(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, iter->field_name.c_str(), NewStringType::kNormal).ToLocalChecked()).ToLocalChecked();
if(iter->field_type == "int8" || iter->field_type == "int16" ||
iter->field_type == "int32") {
int32_t val = 0;
if (value->IsInt32()) {
val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
stream << val << ",";
}
else if(iter->field_type == "int64") {
int64_t val = 0;
if (value->IsNumber()) {
val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
}
stream << val << ",";
}
else if(iter->field_type == "double") {
double val = 0;
if (value->IsNumber()) {
val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
}
stream << val << ",";
}
else if(iter->field_type == "bool") {
bool val = 0;
if (value->IsBoolean()) {
val = value->BooleanValue(isolate->GetCurrentContext()).FromJust();
}
stream << val << ",";
}
else if(iter->field_type == "string") {
if (value->IsString()) {
String::Utf8Value str(value->ToString(isolate->GetCurrentContext()).ToLocalChecked());
stream << "\"" << ToCString(str) << "\",";
} else {
stream << "\"\",";
}
}
else {
LOG_ERROR("Can not find the field_type:%s, struct_name:%s", iter->field_type.c_str(), struct_name().c_str());
}
str += stream.str();
}
}