本文整理汇总了C++中Handle::BooleanValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::BooleanValue方法的具体用法?C++ Handle::BooleanValue怎么用?C++ Handle::BooleanValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::BooleanValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isMatchCandidate
bool isMatchCandidate(ConstElementPtr e)
{
Context::Scope context_scope(_script->getContext());
HandleScope handleScope;
Persistent<Object> plugin = getPlugin();
Handle<String> isMatchCandidateStr = String::New("isMatchCandidate");
if (plugin->Has(isMatchCandidateStr) == false)
{
throw HootException("Error finding 'isMatchCandidate' function.");
}
Handle<v8::Value> value = plugin->Get(isMatchCandidateStr);
if (value->IsFunction() == false)
{
throw HootException("isMatchCandidate is not a function.");
}
Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(value);
Handle<Value> jsArgs[2];
int argc = 0;
jsArgs[argc++] = OsmMapJs::create(_map);
jsArgs[argc++] = ElementJs::New(e);
Handle<Value> f = func->Call(plugin, argc, jsArgs);
return f->BooleanValue();
}
示例2: printV8Value
void printV8Value(Handle<Value> value, bool force=false)
{
Logging::Level level = force ? Logging::ERROR : Logging::INFO;
if (!Logging::shouldShow(level)) return;
HandleScope handleScope;
if (value.IsEmpty())
Logging::log(level, "Empty handle\r\n");
else if (value->IsInt32())
Logging::log(level, "INT: %d\r\n", value->IntegerValue());
else if (value->IsNull())
Logging::log(level, "NULL (null)\r\n");
else if (value->IsUndefined())
Logging::log(level, "VOID (undefined)\r\n");
else if (value->IsBoolean())
Logging::log(level, "BOOLEAN: %d\r\n", value->BooleanValue());
else if (value->IsNumber())
Logging::log(level, "NUMBER: %f\r\n", value->NumberValue());
else if (value->IsString())
Logging::log(level, "STRING: ?\r\n");
else if (value->IsObject())
Logging::log(level, "OBJECT (object)\r\n");
else
Logging::log(level, "Uncertain V8 value\n");
}
示例3: callback
ClrFuncInvokeContext::ClrFuncInvokeContext(Handle<v8::Value> callbackOrSync) : _this(0), callback(0), uv_edge_async(0)
{
static MonoClassField* field;
static MonoClassField* syncField;
if (!field)
field = mono_class_get_field_from_name(GetClrFuncInvokeContextClass(), "native");
if (!syncField)
syncField = mono_class_get_field_from_name(GetClrFuncInvokeContextClass(), "Sync");
MonoObject* obj = mono_object_new(mono_domain_get(), GetClrFuncInvokeContextClass());
ClrFuncInvokeContext* thisPointer = this;
mono_field_set_value(obj, field, &thisPointer);
this->_this = mono_gchandle_new(obj, FALSE); // released in destructor
DBG("ClrFuncInvokeContext::ClrFuncInvokeContext");
if (callbackOrSync->IsFunction())
{
this->callback = new Persistent<Function>(); // released in destructor
*(this->callback) = Persistent<Function>::New(Handle<Function>::Cast(callbackOrSync));
this->Sync(FALSE);
}
else
{
this->Sync(callbackOrSync->BooleanValue());
}
}
示例4: _calculateClassification
void ScriptMatch::_calculateClassification(const ConstOsmMapPtr& map, Handle<Object> plugin)
{
Context::Scope context_scope(_script->getContext());
HandleScope handleScope;
// removing these two lines causes a crash when checking for conflicts. WTF?
Handle<Object> global = _script->getContext()->Global();
global->Get(String::NewSymbol("plugin"));
if (_plugin->Has(String::NewSymbol("isWholeGroup")))
{
Handle<Value> v = _script->call(_plugin, "isWholeGroup");
_isWholeGroup = v->BooleanValue();
}
try
{
Handle<Value> v = _call(map, plugin);
if (v.IsEmpty() || v->IsObject() == false)
{
throw IllegalArgumentException("Expected matchScore to return an associative array.");
}
QVariantMap vm = toCpp<QVariantMap>(v);
// grab the match, miss, review results. If they aren't populated they get a value of 0.
_p.setMatchP(_script->toNumber(v, "match", 0));
_p.setMissP(_script->toNumber(v, "miss", 0));
_p.setReviewP(_script->toNumber(v, "review", 0));
_explainText = vm["explain"].toString();
if (_explainText.isEmpty())
{
_explainText = _threshold->getTypeDetail(_p);
}
if (_threshold->getType(_p) == MatchType::Review)
{
if (_explainText.isEmpty())
{
throw IllegalArgumentException("If the match is a review an appropriate explanation must "
"be provided (E.g. { 'review': 1, "
"'explain': 'some reason' }.");
}
}
}
catch (NeedsReviewException& ex)
{
LOG_VAR(ex.getClassName());
_p.setReview();
_explainText = ex.getWhat();
}
_p.normalize();
}
示例5: SerializeField
void SerializeField(google::protobuf::Message *message, const Reflection *r, const FieldDescriptor *field, Handle<Value> val) {
const EnumValueDescriptor *enumValue = NULL;
bool repeated = field->is_repeated();
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
SET_VALUE(Int32, val->Int32Value());
break;
case FieldDescriptor::CPPTYPE_INT64:
SET_VALUE(Int64, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_UINT32:
SET_VALUE(UInt32, val->Uint32Value());
break;
case FieldDescriptor::CPPTYPE_UINT64:
SET_VALUE(UInt64, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_DOUBLE:
SET_VALUE(Double, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_FLOAT:
SET_VALUE(Float, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_BOOL:
SET_VALUE(Bool, val->BooleanValue());
break;
case FieldDescriptor::CPPTYPE_ENUM:
enumValue = val->IsNumber() ?
field->enum_type()->FindValueByNumber(val->Int32Value()) :
field->enum_type()->FindValueByName(*String::AsciiValue(val));
if (enumValue != NULL)
SET_VALUE(Enum, enumValue);
break;
case FieldDescriptor::CPPTYPE_MESSAGE:
if (val->IsObject()) {
Type* type = protobuf->GetType(field->message_type());
type->SerializePart(repeated ?
r->AddMessage(message, field) :
r->MutableMessage(message, field), val.As<Object>());
}
break;
case FieldDescriptor::CPPTYPE_STRING:
if (Buffer::HasInstance(val)) {
Local<Object> buf = val->ToObject();
SET_VALUE(String, std::string(Buffer::Data(buf), Buffer::Length(buf)));
} else {
String::Utf8Value utf8(val);
SET_VALUE(String, std::string(*utf8, utf8.length()));
}
break;
}
}
示例6: DBG
ClrFuncInvokeContext::ClrFuncInvokeContext(Handle<v8::Value> callbackOrSync)
{
DBG("ClrFuncInvokeContext::ClrFuncInvokeContext");
if (callbackOrSync->IsFunction())
{
this->callback = new Persistent<Function>;
*(this->callback) = Persistent<Function>::New(Handle<Function>::Cast(callbackOrSync));
this->Sync = false;
}
else
{
this->Sync = callbackOrSync->BooleanValue();
}
this->uv_edge_async = NULL;
}
示例7: ToJavaString
int Conv::ToJavaString(JNIEnv *jniEnv, Handle<Value> val, jstring *jVal) {
Handle<String> vString;
Handle<Value> empty, vRes;
jstring ob;
char buf[64];
switch(GetNaturalType(val)) {
default: {
if(val->IsObject()) {
/* call ToString() in javascript */
Handle<Object> oVal = val->ToObject();
Handle<Value> vToString = oVal->Get(sToString);
if(!vToString.IsEmpty() && vToString->IsFunction()) {
Handle<Function> fToString = Handle<Function>::Cast(vToString);
vRes = fToString->CallAsFunction(oVal, 0, &empty);
if(!vRes.IsEmpty() && (vRes->IsString() || vRes->IsStringObject())) {
return ToJavaString(jniEnv, vRes->ToString(), jVal);
}
}
}
return ErrorType;
}
case TYPE_UNDEFINED:
case TYPE_NULL:
*jVal = 0;
return OK;
case TYPE_BOOL:
return ToJavaString(jniEnv, (val->BooleanValue() ? "true" : "false"), jVal);
case TYPE_INT:
sprintf(buf, "%d", val->Int32Value());
return ToJavaString(jniEnv, buf, jVal);
case TYPE_LONG:
sprintf(buf, "%lld", val->IntegerValue());
return ToJavaString(jniEnv, buf, jVal);
case TYPE_DOUBLE:
sprintf(buf, "%g", val->NumberValue());
return ToJavaString(jniEnv, buf, jVal);
case TYPE_STRING:
return ToJavaString(jniEnv, val->ToString(), (jstring *)jVal);
}
if(ob) {
*jVal = ob;
return OK;
}
if(jniEnv->ExceptionCheck())
jniEnv->ExceptionClear();
return ErrorVM;
}
示例8: DBG
ClrFuncInvokeContext::ClrFuncInvokeContext(Handle<v8::Value> callbackOrSync)
{
DBG("ClrFuncInvokeContext::ClrFuncInvokeContext");
if (callbackOrSync->IsFunction())
{
this->callback = new Persistent<Function>;
Local<Function> callbackOrSyncFunction = Handle<Function>::Cast(callbackOrSync);
(this->callback)->Reset(Isolate::GetCurrent(), callbackOrSyncFunction);
this->Sync = false;
}
else
{
this->Sync = callbackOrSync->BooleanValue();
}
this->uv_edge_async = NULL;
}
示例9: ThrowError
Handle<Value> COPropertyGetter(Local<String> propname, const AccessorInfo& info)
{
dtEntity::Component* component = UnwrapComponent(info.Holder());
if(component == NULL)
{
return ThrowError("Trying to access deleted component!");
}
HandleScope scope;
Handle<External> ext = Handle<External>::Cast(info.Data());
dtEntity::Property* prop = static_cast<dtEntity::Property*>(ext->Value());
switch(prop->GetDataType())
{
case dtEntity::DataType::ARRAY:
case dtEntity::DataType::VEC2:
case dtEntity::DataType::VEC2D:
case dtEntity::DataType::VEC3:
case dtEntity::DataType::VEC3D:
case dtEntity::DataType::VEC4:
case dtEntity::DataType::VEC4D:
case dtEntity::DataType::GROUP:
case dtEntity::DataType::MATRIX:
case dtEntity::DataType::QUAT:
{
Handle<Value> v;// = info.Holder()->GetHiddenValue(propname);
if(true)//v.IsEmpty())
{
v = ConvertPropertyToValue(info.Holder()->CreationContext(), prop);
// info.Holder()->SetHiddenValue(propname, v);
}
else
{
Handle<Value> ret = SetValueFromProperty(prop, v);
if(ret->BooleanValue() == false) {
return ThrowError("Internal error: Did property change type on the fly?");
}
}
return scope.Close(v);
}
default:
return scope.Close(ConvertPropertyToValue(info.Holder()->CreationContext(), prop));
}
}
示例10: v8_to_gvalue
void v8_to_gvalue(Handle<Value> v, GValue *gv, GParamSpec *spec) {
if(v->IsNumber()) {
g_value_init(gv, G_TYPE_FLOAT);
g_value_set_float(gv, v->NumberValue());
} else if(v->IsString()) {
String::Utf8Value value(v->ToString());
if(spec->value_type == GST_TYPE_CAPS) {
GstCaps* caps = gst_caps_from_string(*value);
g_value_init(gv, GST_TYPE_CAPS);
g_value_set_boxed(gv, caps);
} else {
g_value_init(gv, G_TYPE_STRING);
g_value_set_string(gv, *value);
}
} else if(v->IsBoolean()) {
g_value_init(gv, G_TYPE_BOOLEAN);
g_value_set_boolean(gv, v->BooleanValue());
}
return;
}
示例11: extractBoolean
bool ScriptObject::extractBoolean(const Arguments &args, int index)
{
HandleScope handleScope;
TryCatch tryCatch;
// Get Boolean value
Handle<Value> argValue = ScriptObject::extractArgument(args, index);
if (tryCatch.HasCaught())
return false;
Handle<BooleanObject> argBoolean = Handle<BooleanObject>::Cast(argValue);
if (argBoolean.IsEmpty())
{
Local<String> message = String::New("Argument is not a Boolean object");
throw ScriptException(v8::Exception::SyntaxError(message));
}
return argBoolean->BooleanValue();
}
示例12: rr_v82rb
VALUE rr_v82rb(Handle<Value> value) {
if (value.IsEmpty()) {
return rr_v8_value_empty();
}
if (value->IsUndefined() || value->IsNull()) {
return Qnil;
}
if (value->IsExternal()) {
return rr_reflect_v8_external(value);
}
if (value->IsUint32()) {
return UINT2NUM(value->Uint32Value());
}
if (value->IsInt32()) {
return INT2FIX(value->Int32Value());
}
if (value->IsBoolean()) {
return value->BooleanValue() ? Qtrue : Qfalse;
}
if (value->IsNumber()) {
return rb_float_new(value->NumberValue());
}
if (value->IsString()) {
return rr_reflect_v8_string(value);
}
if (value->IsFunction()) {
return rr_reflect_v8_function(value);
}
if (value->IsArray()) {
return rr_reflect_v8_array(value);
}
if (value->IsDate()) {
return rr_reflect_v8_date(value);
}
if (value->IsObject()) {
return rr_reflect_v8_object(value);
}
return rr_wrap_v8_value(value);
}
示例13: SerializeField
void SerializeField(google::protobuf::Message *message, const Reflection *r, const FieldDescriptor *field, Handle<Value> val) {
const EnumValueDescriptor *enumValue = NULL;
bool repeated = field->is_repeated();
if (*val != NULL) {
if (field->is_optional() && (val->IsNull() || val->IsUndefined()))
return;
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32: {
if (repeated)
r->AddInt32(message, field, val->Int32Value());
else
r->SetInt32(message, field, val->Int32Value());
break;
}
case FieldDescriptor::CPPTYPE_INT64:
if (repeated)
if (preserve_int64 && val->IsArray()) {
Local<Object> n64_array = val->ToObject();
uint64 n64;
uint32 hi = n64_array->Get(0)->Uint32Value(), lo = n64_array->Get(1)->Uint32Value();
n64 = ((uint64)hi << 32) + (uint64)lo;
r->AddInt64(message, field, n64);
} else
r->AddInt64(message, field, val->NumberValue());
else
if (preserve_int64 && val->IsArray()) {
Local<Object> n64_array = val->ToObject();
uint64 n64;
uint32 hi = n64_array->Get(0)->Uint32Value(), lo = n64_array->Get(1)->Uint32Value();
n64 = ((uint64)hi << 32) + (uint64)lo;
r->SetInt64(message, field, n64);
} else
r->SetInt64(message, field, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_UINT32:
if (repeated)
r->AddUInt32(message, field, val->Uint32Value());
else
r->SetUInt32(message, field, val->Uint32Value());
break;
case FieldDescriptor::CPPTYPE_UINT64:
if (repeated)
if (preserve_int64 && val->IsArray()) {
Local<Object> n64_array = val->ToObject();
uint64 n64;
uint32 hi = n64_array->Get(0)->Uint32Value(), lo = n64_array->Get(1)->Uint32Value();
n64 = ((uint64)hi << 32) + (uint64)lo;
r->AddUInt64(message, field, n64);
} else
r->AddUInt64(message, field, val->NumberValue());
else
if (preserve_int64 && val->IsArray()) {
Local<Object> n64_array = val->ToObject();
uint64 n64;
uint32 hi = n64_array->Get(0)->Uint32Value(), lo = n64_array->Get(1)->Uint32Value();
n64 = ((uint64)hi << 32) + (uint64)lo;
r->SetUInt64(message, field, n64);
} else
r->SetUInt64(message, field, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_DOUBLE:
if (repeated)
r->AddDouble(message, field, val->NumberValue());
else
r->SetDouble(message, field, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_FLOAT:
if (repeated)
r->AddFloat(message, field, val->NumberValue());
else
r->SetFloat(message, field, val->NumberValue());
break;
case FieldDescriptor::CPPTYPE_BOOL:
if (repeated)
r->AddBool(message, field, val->BooleanValue());
else
r->SetBool(message, field, val->BooleanValue());
break;
case FieldDescriptor::CPPTYPE_ENUM:
// TODO: possible memory leak?
enumValue =
val->IsNumber() ?
field->enum_type()->FindValueByNumber(val->Int32Value()) :
field->enum_type()->FindValueByName(*NanAsciiString(val));
if (enumValue != NULL) {
if (repeated)
r->AddEnum(message, field, enumValue);
else
r->SetEnum(message, field, enumValue);
}
break;
case FieldDescriptor::CPPTYPE_MESSAGE:
if (val->IsObject()) {
if (repeated)
SerializePart(r->AddMessage(message, field), val.As<Object>());
else
SerializePart(r->MutableMessage(message, field), val.As<Object>());
//.........这里部分代码省略.........
示例14: ThrowError
Handle<Value> MSAddSpawner(const Arguments& args)
{
HandleScope scope;
dtEntity::MapSystem* ms = UnwrapMapSystem(args.This());
if(args.Length() != 1)
{
return ThrowError("Usage: addSpawner({components, name, guicategory, mapname, addtospawnerstore, iconpath})");
}
Handle<Object> obj = Handle<Object>::Cast(args[0]);
Handle<Value> vname = obj->Get(String::New("name"));
Handle<Value> vcomponents = obj->Get(String::New("components"));
if(vname.IsEmpty() || vcomponents.IsEmpty())
{
return ThrowError("Usage: addSpawner({components, name, guicategory, mapname, addtospawnerstore, iconpath, parentname})");
}
Handle<Value> vguicategory = obj->Get(String::New("guicategory"));
Handle<Value> vmapname = obj->Get(String::New("mapname"));
Handle<Value> vaddtospawnerstore = obj->Get(String::New("addtospawnerstore"));
Handle<Value> viconpath = obj->Get(String::New("iconpath"));
Handle<Value> vparentname = obj->Get(String::New("parentname"));
std::string name = ToStdString(vname);
std::string mapname = vmapname.IsEmpty() ? "" : ToStdString(vmapname);
Handle<Object> components = Handle<Object>::Cast(vcomponents);
dtEntity::Spawner* parent = NULL;
if(!vparentname.IsEmpty() && !vparentname->IsUndefined())
{
ms->GetSpawner(ToStdString(vparentname), parent);
}
osg::ref_ptr<dtEntity::Spawner> spawner = new dtEntity::Spawner(name, mapname, parent);
if(!vguicategory.IsEmpty() && !vguicategory->IsUndefined())
{
spawner->SetGUICategory(ToStdString(vguicategory));
}
if(!vaddtospawnerstore.IsEmpty() && !vaddtospawnerstore->IsUndefined())
{
spawner->SetAddToSpawnerStore(vaddtospawnerstore->BooleanValue());
}
if(!viconpath.IsEmpty() && !viconpath->IsUndefined())
{
spawner->SetIconPath(ToStdString(viconpath));
}
Handle<Array> keys = components->GetPropertyNames();
for(unsigned int i = 0; i < keys->Length(); ++i)
{
Handle<Value> key = keys->Get(Integer::New(i));
std::string keyname = ToStdString(key);
dtEntity::StringId ctype = dtEntity::SIDHash(keyname);
dtEntity::ComponentPluginManager::GetInstance().StartEntitySystem(ms->GetEntityManager(), ctype);
if(ms->GetEntityManager().HasEntitySystem(ctype))
{
Handle<Value> val = components->Get(key);
if(val->IsObject())
{
Handle<Object> compobj = Handle<Object>::Cast(val);
Handle<Array> compkeys = compobj->GetPropertyNames();
dtEntity::GroupProperty props;
for(unsigned int j = 0; j < compkeys->Length(); ++j)
{
Handle<Value> compkey = compkeys->Get(Integer::New(j));
std::string compkeystr = ToStdString(compkey);
Handle<Value> compval = compobj->Get(compkey);
dtEntity::Property* prop = ConvertValueToProperty(compval);
props.Add(dtEntity::SIDHash(compkeystr), prop);
}
spawner->AddComponent(ctype, props);
}
}
}
ms->AddSpawner(*spawner);
return Undefined();
}
示例15: if
jsvalue JsEngine::AnyFromV8(Handle<Value> value, Handle<Object> thisArg)
{
jsvalue v;
// Initialize to a generic error.
v.type = JSVALUE_TYPE_UNKNOWN_ERROR;
v.length = 0;
v.value.str = 0;
if (value->IsNull() || value->IsUndefined()) {
v.type = JSVALUE_TYPE_NULL;
}
else if (value->IsBoolean()) {
v.type = JSVALUE_TYPE_BOOLEAN;
v.value.i32 = value->BooleanValue() ? 1 : 0;
}
else if (value->IsInt32()) {
v.type = JSVALUE_TYPE_INTEGER;
v.value.i32 = value->Int32Value();
}
else if (value->IsUint32()) {
v.type = JSVALUE_TYPE_INDEX;
v.value.i64 = value->Uint32Value();
}
else if (value->IsNumber()) {
v.type = JSVALUE_TYPE_NUMBER;
v.value.num = value->NumberValue();
}
else if (value->IsString()) {
v = StringFromV8(value);
}
else if (value->IsDate()) {
v.type = JSVALUE_TYPE_DATE;
v.value.num = value->NumberValue();
}
else if (value->IsArray()) {
Handle<Array> object = Handle<Array>::Cast(value->ToObject());
v.length = object->Length();
jsvalue* array = new jsvalue[v.length];
if (array != NULL) {
for(int i = 0; i < v.length; i++) {
array[i] = AnyFromV8(object->Get(i));
}
v.type = JSVALUE_TYPE_ARRAY;
v.value.arr = array;
}
}
else if (value->IsFunction()) {
Handle<Function> function = Handle<Function>::Cast(value);
jsvalue* array = new jsvalue[2];
if (array != NULL) {
array[0].value.ptr = new Persistent<Object>(Persistent<Function>::New(function));
array[0].length = 0;
array[0].type = JSVALUE_TYPE_WRAPPED;
if (!thisArg.IsEmpty()) {
array[1].value.ptr = new Persistent<Object>(Persistent<Object>::New(thisArg));
array[1].length = 0;
array[1].type = JSVALUE_TYPE_WRAPPED;
} else {
array[1].value.ptr = NULL;
array[1].length = 0;
array[1].type = JSVALUE_TYPE_NULL;
}
v.type = JSVALUE_TYPE_FUNCTION;
v.value.arr = array;
}
}
else if (value->IsObject()) {
Handle<Object> obj = Handle<Object>::Cast(value);
if (obj->InternalFieldCount() == 1)
v = ManagedFromV8(obj);
else
v = WrappedFromV8(obj);
}
return v;
}