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


C++ Local::HasRealNamedProperty方法代码示例

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


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

示例1: TransformParameter

bool CQueryParameter::TransformParameter( Isolate* isolate, Local< Value > value, sBindParameter** pOutParam )
{
	HandleScope scope( isolate );
	Local< Context > context = isolate->GetCurrentContext( );

	sBindParameter* pParameter = *pOutParam;

	if( value->IsNull( ) )
	{
		pParameter->SetNull( );
	}
	else if( value->IsString( ) )
	{
		pParameter->SetString( value.As<String>( ) );
	}
	else if( value->IsBoolean( ) )
	{
		pParameter->SetBool( value->BooleanValue( context ).FromJust( ) );
	}
	else if( value->IsInt32( ) )
	{
		pParameter->SetInt( value->Int32Value( context ).FromJust( ) );
	}
	else if( value->IsUint32( ) )
	{
		pParameter->SetUInt( value->Uint32Value( context ).FromJust( ) );
	}
	else if( value->IsNumber( ) )
	{
		double d = value->NumberValue( context ).FromJust( );
		if( _isnan( d ) || !_finite( d ) )
		{
			return false;
		}
		else if( d == floor( d ) &&
				 d >= std::numeric_limits<int64_t>::min( ) &&
				 d <= std::numeric_limits<int64_t>::max( )
				 )
		{
			pParameter->SetInt64( value->IntegerValue( context ).FromJust( ) );
		}
		else
		{
			pParameter->SetDouble( value->NumberValue( context ).FromJust( ) );
		}
	}
	else if( value->IsDate( ) )
	{
		Local<Date> dateObject = value.As<Date>( );

		pParameter->SetDate( dateObject->NumberValue( context ).FromJust( ) );
	}
	else if( value->IsObject( ) )
	{
		Local<Object> objValue = value.As<Object>( );

		if( node::Buffer::HasInstance( value ) )
		{
			pParameter->SetBuffer( isolate, objValue );
		}
		else
		{
			Local< String > strId = String::NewFromUtf8( isolate, "_objId", NewStringType::kNormal ).ToLocalChecked( );


			if( objValue->HasRealNamedProperty( context, strId ).FromJust( ) )
			{
				Local< Uint32 > numTypeId = objValue->Get( context, strId ).ToLocalChecked( ).As< Uint32 >( );

				uint32_t nType = numTypeId->Int32Value( context ).FromJust( );

				switch( nType )
				{
					case ID_INPUT_STREAM:
					{
						Local<Value> type = objValue->Get(
							context, String::NewFromUtf8( isolate, "type", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> stream = objValue->Get(
							context, String::NewFromUtf8( isolate, "stream", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> length = objValue->Get(
							context, String::NewFromUtf8( isolate, "length", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						pParameter->SetStream( isolate, type->Uint32Value( context ).FromJust( ), stream, static_cast< SQLUINTEGER >( length->IntegerValue( context ).FromJust( ) ) );

						break;
					}
					case ID_NUMERIC_VALUE:
					{
						Local< Value > precision = objValue->Get(
							context, String::NewFromUtf8( isolate, "precision", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> scale = objValue->Get(
							context, String::NewFromUtf8( isolate, "scale", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );
//.........这里部分代码省略.........
开发者ID:ItsClemi,项目名称:node-odbc,代码行数:101,代码来源:QueryParameter.cpp

示例2: Undefined

Handle<Value>
NodeSandbox::node_spawn(const Arguments& args)
{
  HandleScope scope;
  char** argv;
  std::map<std::string, std::string> envp;
  SandboxWrapper* wrap;

  wrap = node::ObjectWrap::Unwrap<SandboxWrapper>(args.This());
  argv = static_cast<char**>(calloc (sizeof (char*), args.Length()+1));
  argv[args.Length()] = nullptr;

  for(int i = 0; i < args.Length(); i++) {
    if (args[i]->IsString()) {
      Local<String> v = args[i]->ToString();
      argv[i] = static_cast<char*>(calloc(sizeof(char), v->Utf8Length()+1));
      v->WriteUtf8(argv[i]);
    } else {
      if (i <= args.Length() - 2 ) {
        ThrowException(Exception::TypeError(String::New("Arguments must be strings.")));
        goto out;
      } else {
        // Last parameter is an options structure
        Local<Object> options = args[i]->ToObject();
        if (!options.IsEmpty()) {
          if (options->HasRealNamedProperty(String::NewSymbol("env"))) {
            Local<Object> envOptions = options->Get(String::NewSymbol("env"))->ToObject();
            if (!envOptions.IsEmpty()) {
              Local<Array> envArray = envOptions->GetOwnPropertyNames();
              for (uint32_t i = 0; i < envArray->Length(); i++) {
                std::vector<char> strName;
                std::vector<char> strValue;
                Local<String> envName;
                Local<String> envValue;

                if (!(envArray->Get(i)->IsString() && envArray->Get(i)->IsString()))
                  goto err_env;

                envName = envArray->Get(i)->ToString();
                envValue = envOptions->Get(envName)->ToString();

                strName.resize (envName->Utf8Length()+1);
                strValue.resize (envValue->Utf8Length()+1);
                envName->WriteUtf8 (strName.data());
                envValue->WriteUtf8 (strValue.data());
                envp.insert (std::make_pair(std::string (strName.data()), std::string(strValue.data())));
              }
            } else {
              goto err_env;
            }
          }
        } else {
          goto err_options;
        }
      }
    }
  }

  wrap->sbox->getVFS().setCWD ("/contract/");
  wrap->sbox->spawn(argv, envp);

  goto out;

err_env:
  ThrowException(Exception::TypeError(String::New("'env' option must be a map of string:string")));
  goto out;

err_options:
  ThrowException(Exception::TypeError(String::New("Last argument must be an options structure.")));
  goto out;

out:
  for (int i = 0; i < args.Length();i ++) {
    free (argv[i]);
  }
  free (argv);

  return Undefined();
}
开发者ID:codius,项目名称:codius-sandbox,代码行数:79,代码来源:sandbox-node-module.cpp

示例3: PropertyAttribute

Handle<Value> Proxy::proxyConstructor(const Arguments& args)
{
	HandleScope scope;
	JNIEnv *env = JNIScope::getEnv();
	Local<Object> jsProxy = args.Holder();

	Handle<Object> properties = Object::New();
	jsProxy->Set(propertiesSymbol, properties, PropertyAttribute(DontEnum));

	Handle<Object> prototype = jsProxy->GetPrototype()->ToObject();

	Handle<Function> constructor = Handle<Function>::Cast(prototype->Get(constructorSymbol));
	jclass javaClass = (jclass) External::Unwrap(constructor->Get(javaClassSymbol));

	// If ProxyFactory::createV8Proxy invoked us, unwrap
	// the pre-created Java proxy it sent.
	jobject javaProxy = ProxyFactory::unwrapJavaProxy(args);
	bool deleteRef = false;
	if (!javaProxy) {
		javaProxy = ProxyFactory::createJavaProxy(javaClass, jsProxy, args);
		deleteRef = true;
	}

	JNIUtil::logClassName("Create proxy: %s", javaClass);

	Proxy *proxy = new Proxy(javaProxy);
	proxy->Wrap(jsProxy);

	int length = args.Length();

	if (length > 0 && args[0]->IsObject()) {
		/*
		Handle<Value> argsStr = V8Util::jsonStringify(args[0]);
		String::Utf8Value str(argsStr);
		LOGV(TAG, "    with args: %s", *str);
		*/

		bool extend = true;
		Handle<Object> createProperties = args[0]->ToObject();
		Local<String> constructorName = createProperties->GetConstructorName();
		if (strcmp(*String::Utf8Value(constructorName), "Arguments") == 0) {
			extend = false;
			int32_t argsLength = createProperties->Get(String::New("length"))->Int32Value();
			if (argsLength > 1) {
				Handle<Value> properties = createProperties->Get(1);
				if (properties->IsObject()) {
					extend = true;
					createProperties = properties->ToObject();
				}
			}
		}

		if (extend) {
			Handle<Array> names = createProperties->GetOwnPropertyNames();
			int length = names->Length();

			for (int i = 0; i < length; ++i) {
				Handle<Value> name = names->Get(i);
				Handle<Value> value = createProperties->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) {
					properties->Set(name, value);
				}
			}
		}
	}


	if (!args.Data().IsEmpty() && args.Data()->IsFunction()) {
		Handle<Function> proxyFn = Handle<Function>::Cast(args.Data());
		Handle<Value> *fnArgs = new Handle<Value>[length];
		for (int i = 0; i < length; ++i) {
			fnArgs[i] = args[i];
		}
		proxyFn->Call(jsProxy, length, fnArgs);
	}

	if (deleteRef) {
		JNIEnv *env = JNIScope::getEnv();
		if (env) {
			env->DeleteLocalRef(javaProxy);
		}
	}

	return jsProxy;
}
开发者ID:ayeung,项目名称:titanium_mobile,代码行数:94,代码来源:Proxy.cpp


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