当前位置: 首页>>代码示例>>C++>>正文


C++ Handle::IsString方法代码示例

本文整理汇总了C++中Handle::IsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::IsString方法的具体用法?C++ Handle::IsString怎么用?C++ Handle::IsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Handle的用法示例。


在下文中一共展示了Handle::IsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseEncoding

enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
  HandleScope scope;

  if (!encoding_v->IsString()) return _default;

  String::Utf8Value encoding(encoding_v);

  if (strcasecmp(*encoding, "utf8") == 0) {
    return UTF8;
  } else if (strcasecmp(*encoding, "utf-8") == 0) {
    return UTF8;
  } else if (strcasecmp(*encoding, "ascii") == 0) {
    return ASCII;
  } else if (strcasecmp(*encoding, "base64") == 0) {
    return BASE64;
  } else if (strcasecmp(*encoding, "ucs2") == 0) {
    return UCS2;
  } else if (strcasecmp(*encoding, "ucs-2") == 0) {
    return UCS2;
  } else if (strcasecmp(*encoding, "binary") == 0) {
    return BINARY;
  } else if (strcasecmp(*encoding, "hex") == 0) {
    return HEX;
  } else if (strcasecmp(*encoding, "raw") == 0) {
    fprintf(stderr, "'raw' (array of integers) has been removed. "
                    "Use 'binary'.\n");
    return BINARY;
  } else if (strcasecmp(*encoding, "raws") == 0) {
    fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
                    "Please update your code.\n");
    return BINARY;
  } else {
    return _default;
  }
}
开发者ID:ngocdaothanh,项目名称:jsg,代码行数:35,代码来源:node.cpp

示例2: getKeyHandle

Handle<String> V8Config::getStringParameter(Handle<Object> element,const char* key){

	Handle<Value> handleValue = getKeyHandle(element,key);
	assert(handleValue->IsString());
	return handleValue->ToString();

}
开发者ID:anaish,项目名称:Laser,代码行数:7,代码来源:v8config.cpp

示例3: UserException

    int V8Scope::type( const char *field ){
        V8_SIMPLE_HEADER
        Handle<Value> v = get( field );
        if ( v->IsNull() )
            return jstNULL;
        if ( v->IsUndefined() )
            return Undefined;
        if ( v->IsString() )
            return String;
        if ( v->IsFunction() )
            return Code;
        if ( v->IsArray() )
            return Array;
        if ( v->IsBoolean() )
            return Bool;
        if ( v->IsInt32() )
            return NumberInt;
        if ( v->IsNumber() )
            return NumberDouble;
        if ( v->IsExternal() ){
            uassert( 10230 ,  "can't handle external yet" , 0 );
            return -1;
        }
        if ( v->IsDate() )
            return Date;
        if ( v->IsObject() )
            return Object;

        throw UserException( 12509, (string)"don't know what this is: " + field );
    }
开发者ID:IlyaM,项目名称:mongo,代码行数:30,代码来源:engine_v8.cpp

示例4: 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");
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:27,代码来源:script_engine_v8.cpp

示例5: jniScope

JNIEXPORT jobject JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeEvalString
	(JNIEnv *env, jobject self, jstring source, jstring filename)
{
	ENTER_V8(V8Runtime::globalContext);
	titanium::JNIScope jniScope(env);

	Handle<Value> jsSource = TypeConverter::javaStringToJsString(env, source);
	if (jsSource.IsEmpty() || !jsSource->IsString()) {
		LOGE(TAG, "Error converting Javascript string, aborting evalString");
		return NULL;
	}

	Handle<Value> jsFilename = TypeConverter::javaStringToJsString(env, filename);

	TryCatch tryCatch;
	Handle<Script> script = Script::Compile(jsSource->ToString(), jsFilename);
	Local<Value> result = script->Run();

	if (tryCatch.HasCaught()) {
		V8Util::openJSErrorDialog(tryCatch);
		V8Util::reportException(tryCatch, true);
		return NULL;
	}

	return TypeConverter::jsValueToJavaObject(env, result);
}
开发者ID:SreenuDevireddy,项目名称:titanium_mobile,代码行数:26,代码来源:V8Runtime.cpp

示例6: length

size_t length(Handle<Value> v) {
    if (v->IsString()) {
        return v->ToString()->Utf8Length();
    } else if (Buffer::HasInstance(v)) {
        return Buffer::Length(v->ToObject());
    } else {
        return 0;
    }
}
开发者ID:NHQ,项目名称:node_mdns,代码行数:9,代码来源:txt_record_set_value.cpp

示例7: GetNaturalType

int Conv::GetNaturalType(Handle<Value> val) {
  if(val.IsEmpty()) return TYPE_INVALID;
  if(val->IsUndefined()) return TYPE_UNDEFINED;
  if(val->IsNull()) return TYPE_NULL;
  if(val->IsBoolean() || val->IsBooleanObject()) return TYPE_BOOL;
  if(val->IsInt32()) return TYPE_INT;
  if(val->IsUint32()) return TYPE_LONG;
  if(val->IsNumber() || val->IsNumberObject()) return TYPE_DOUBLE;
  if(val->IsString() || val->IsStringObject()) return TYPE_STRING;
  return GetNaturalType(Handle<Object>::Cast(val));
}
开发者ID:Armen138,项目名称:anode,代码行数:11,代码来源:Conv.cpp

示例8: VisitLiteral

void AstOptimizer::VisitLiteral(Literal* node) {
  Handle<Object> literal = node->handle();
  if (literal->IsSmi()) {
    node->type()->SetAsLikelySmi();
  } else if (literal->IsString()) {
    Handle<String> lit_str(Handle<String>::cast(literal));
    if (!Heap::prototype_symbol()->Equals(*lit_str)) {
      func_name_inferrer_.PushName(lit_str);
    }
  }
}
开发者ID:BlitzMaxModules,项目名称:axe.mod,代码行数:11,代码来源:rewriter.cpp

示例9: keyStr

Susi::Util::Any Susi::JS::Engine::convertFromJS(Handle<Value> jsVal){
	if(jsVal->IsArray()){
		Susi::Util::Any::Array result;
		auto obj = jsVal->ToObject();
		const Local<Array> props = obj->GetPropertyNames();
		const uint32_t length = props->Length();
		for (uint32_t i=0 ; i<length ; ++i){
			const Local<Value> key = props->Get(i);
			const Local<Value> value = obj->Get(key);
			result.push_back(Susi::JS::Engine::convertFromJS(value));
		}
		return result;
	}
	if(jsVal->IsObject()){
		Susi::Util::Any result = Susi::Util::Any::Object{};
		auto obj = jsVal->ToObject();
		const Local<Array> props = obj->GetPropertyNames();
		const uint32_t length = props->Length();
		for (uint32_t i=0 ; i<length ; ++i){
			const Local<Value> key = props->Get(i);
			const Local<Value> value = obj->Get(key);
			String::Utf8Value keyStr(key);
			result[std::string(*keyStr)] = Susi::JS::Engine::convertFromJS(value);
		}
		return result;
	}
	if(jsVal->IsString()){
		String::Utf8Value val(jsVal);
		Susi::Util::Any result{std::string(*val)};
		return result;
	}
	if(jsVal->IsNumber()){
		Susi::Util::Any result{jsVal->ToNumber()->Value()};
		return result;
	}
	if(jsVal->IsBoolean()){
		Susi::Util::Any result{jsVal->ToBoolean()->Value()};
		return result;
	}
	if(jsVal->IsNativeError()){
		String::Utf8Value val(jsVal);
		Susi::Util::Any result{std::string(*val)};
		return result;
	}
	if(jsVal->IsUndefined()){
		Susi::Util::Any result;
		return result;
	}
	return Susi::Util::Any{"type not known"};
}
开发者ID:Spacefish,项目名称:susi,代码行数:50,代码来源:JSEngine.cpp

示例10: setField

inline bool setField(OGRFeature* f, int field_index, Handle<Value> val){
	if (val->IsInt32()) {
		f->SetField(field_index, val->Int32Value());
	} else if (val->IsNumber()) {
		f->SetField(field_index, val->NumberValue());
	} else if (val->IsString()) {
		std::string str = *NanUtf8String(val);
		f->SetField(field_index, str.c_str());
	} else if(val->IsNull() || val->IsUndefined()) {
		f->UnsetField(field_index);
	} else {
		return true;
	}
	return false;
}
开发者ID:drownedout,项目名称:datamap,代码行数:15,代码来源:feature_fields.cpp

示例11: ThrowException

std::vector<char>
NodeSandbox::mapFilename(std::vector<char> fname)
{
  Handle<Value> argv[1] = {
    String::NewSymbol (fname.data())
  };
  Handle<Value> callbackRet = node::MakeCallback (wrap->nodeThis, "mapFilename", 1, argv);
  if (callbackRet->IsString()) {
    std::vector<char> buf;
    buf.resize (callbackRet->ToString()->Utf8Length()+1);
    callbackRet->ToString()->WriteUtf8 (buf.data());
    buf[buf.size()-1] = 0;
    return buf;
  } else {
    ThrowException(Exception::TypeError(String::New("Expected a string return value")));
  }
  return std::vector<char>();
}
开发者ID:codius,项目名称:codius-sandbox,代码行数:18,代码来源:sandbox-node-module.cpp

示例12: 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;
}
开发者ID:dturing,项目名称:node-gstreamer-superficial,代码行数:21,代码来源:GLibHelpers.cpp

示例13: setImage

int NativeImageViewObject::setImage(TiObject* obj)
{
	Handle<Value> img = obj->getValue();
	imageView_->resetImage();
    if (img->IsString()) {
        QString imagePath = V8ValueToQString(obj->getValue());
        if(imagePath.startsWith("http://") || imagePath.startsWith("https://"))
        {
        	ImageLoader::loadImage(imageView_, QUrl(imagePath));
            return NATIVE_ERROR_OK;
        }
        if(!QFile(imagePath).exists())
        {
        	imagePath = getResourcePath(imagePath);
        }
        imageView_->setImage(QUrl(imagePath));
    } else {
        TiObject* obj = TiObject::getTiObjectFromJsObject(img);
        // Ok, this is the old blob object, so get it, use it, and return.
        if (obj != NULL && strcmp(obj->getName(), "Blob") == 0)
        {
			TiBlobObject* blob = static_cast<TiBlobObject*>(obj);
			Image image(blob->data());
			imageView_->setImage(image);
		    return NATIVE_ERROR_OK;
        }
        // This might be the new blob object
        Handle<External> proxyObject = Handle<External>::Cast(img->ToObject()->GetHiddenValue(String::New("proxy")));

        // But return if it's not
        if(proxyObject.IsEmpty())
    		return NATIVE_ERROR_OK;

    	Ti::TiBlob* blob = static_cast<Ti::TiBlob*>(proxyObject->Value());
		Image image(blob->getData());
		imageView_->setImage(image);

    }
    return NATIVE_ERROR_OK;
}
开发者ID:HazemKhaled,项目名称:titanium_mobile_blackberry,代码行数:40,代码来源:NativeImageViewObject.cpp

示例14: 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);  
}
开发者ID:Cythnk,项目名称:territory_mapper,代码行数:39,代码来源:rr.cpp

示例15: jniScope

JNIEXPORT void JNICALL
Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeUpdateProperties
	(JNIEnv *env, jobject object, jlong ptr, jobject jprops)
{
	ENTER_V8(V8Runtime::globalContext);
	titanium::JNIScope jniScope(env);

	Handle<Object> jsProxy;
	if (ptr != 0) {
		jsProxy = Persistent<Object>((Object *) ptr);
	} else {
		jsProxy = TypeConverter::javaObjectToJsValue(env, object)->ToObject();
	}


	Handle<Object> proxyProperties = jsProxy->Get(Proxy::propertiesSymbol)->ToObject();
	Handle<Object> properties = TypeConverter::javaHashMapToJsValue(env, jprops);
	
	Handle<Array> names = properties->GetOwnPropertyNames();
	int length = names->Length();

	for (int i = 0; i < length; ++i) {
		Handle<Value> name = names->Get(i);
		Handle<Value> value = properties->Get(name);
		bool isProperty = true;
		if (name->IsString()) {
			Handle<String> nameString = name->ToString();
			if (!jsProxy->HasRealNamedCallbackProperty(nameString)
				&& !jsProxy->HasRealNamedProperty(nameString)) {
				jsProxy->Set(name, value);
				isProperty = false;
			}
		}
		if (isProperty) {
			proxyProperties->Set(name, value);
		}
	}
}
开发者ID:mohdaminyuddin,项目名称:titanium_mobile,代码行数:38,代码来源:V8Object.cpp


注:本文中的Handle::IsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。