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


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

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


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

示例1: newIndexBound

Handle<Value> newIndexBound(const Arguments &args) {
    HandleScope scope;

    const Local<Object> spec = args[0]->ToObject();
    Local<Value> v;
    Local<Object> o;

    NdbIndexScanOperation::IndexBound * bound =
        new NdbIndexScanOperation::IndexBound;
    Local<Object> jsBound = IndexBoundEnvelope.newWrapper();
    wrapPointerInObject(bound, IndexBoundEnvelope, jsBound);

    bound->low_key = 0;
    v = spec->Get(BOUND_LOW_KEY);
    if(v->IsNull()) {
        bound->low_key = 0;
    } else {
        o = v->ToObject();
        bound->low_key = node::Buffer::Data(o);
    }

    bound->low_key_count = 0;
    v = spec->Get(BOUND_LOW_KEY_COUNT);
    if(! v->IsNull()) {
        bound->low_key_count = v->Uint32Value();
    }

    bound->low_inclusive = false;
    v = spec->Get(BOUND_LOW_INCLUSIVE);
    if(! v->IsNull()) {
        bound->low_inclusive = v->BooleanValue();
    }

    bound->high_key = 0;
    v = spec->Get(BOUND_HIGH_KEY);
    if(v->IsNull()) {
        bound->high_key = 0;
    } else {
        o = v->ToObject();
        bound->high_key = node::Buffer::Data(o);
    }

    bound->high_key_count = 0;
    v = spec->Get(BOUND_HIGH_KEY_COUNT);
    if(! v->IsNull()) {
        bound->high_key_count = v->Uint32Value();
    }

    bound->high_inclusive = false;
    v = spec->Get(BOUND_HIGH_INCLUSIVE);
    if(! v->IsNull()) {
        bound->high_inclusive = v->BooleanValue();
    }

    bound->range_no = 0;
    v = spec->Get(BOUND_RANGE_NO);
    if(! v->IsNull()) {
        bound->range_no = v->Uint32Value();
    }

    debug_print_bound(bound);

    return scope.Close(jsBound);
}
开发者ID:WhiteWaterCoder,项目名称:mysql-js,代码行数:64,代码来源:IndexBoundHelper.cpp

示例2: ConnectParseOptions


//.........这里部分代码省略.........
    }
    else if (tva_str_casecmp(optionName, "gdMaxOut") == 0)
    {
      request->gdMaxOut = optionValue->Int32Value();
    }
    else if (tva_str_casecmp(optionName, "config") == 0)
    {
      if (optionValue->IsObject())
      {
        Local<Object> config = Local<Object>::Cast(optionValue);
        std::vector<std::string> configNames = cvv8::CastFromJS<std::vector<std::string> >(config->GetPropertyNames());
        for (size_t j = 0; j < configNames.size(); j++)
        {
          char* configName = (char*)(configNames[j].c_str());
          Local<Value> configValue = config->Get(String::NewSymbol(configName));

          if (configValue->IsUndefined())
          {
            continue;
          }

          for (size_t c = 0; c < NUM_PARAMS; c++)
          {
            ConnectConfigParam* cp = &g_connectConfig[c];
            if (tva_str_casecmp(configName, cp->jsName) == 0)
            {
              switch (cp->configType)
              {
              case ConfigTypeBool:
                {
                  bool bVal;
                  if (configValue->IsBoolean())
                  {
                    bVal = configValue->BooleanValue();
                  }
                  else if (configValue->IsNumber())
                  {
                    bVal = (configValue->NumberValue() != 0);
                  }
                  else if (configValue->IsString())
                  {
                    String::AsciiValue bStrVal(config->ToString());
                    bVal = (tva_str_casecmp(*bStrVal, "true") == 0);
                  }

                  tvaAppCfgSet(cp->tvaParam, &bVal, (TVA_INT32)sizeof(bVal));
                }
                break;

              case ConfigTypeInt:
                {
                  int intVal = configValue->Int32Value();
                  tvaAppCfgSet(cp->tvaParam, &intVal, (TVA_INT32)sizeof(intVal));
                }
                break;

              case ConfigTypeString:
                {
                  String::AsciiValue strVal(configValue->ToString());
                  tvaAppCfgSet(cp->tvaParam, *strVal, (TVA_INT32)strlen(*strVal));
                }
                break;

              case ConfigTypeCustom:
                if (cp->tvaParam == TVA_APPCFG_DATA_TRANSPORT_TYPE)
                {
开发者ID:hgokhale,项目名称:tvanode,代码行数:67,代码来源:Tervela.cpp

示例3: SetArrayElement

void ArrayElementAccessor::SetArrayElement(const Local<Object>& array, uint32_t index, const string& arraySignature, Local<Value>& value)
{
	JEnv env;

	Isolate* isolate = Isolate::GetCurrent();
	HandleScope handleScope(isolate);

	jweak arr = objectManager->GetJavaObjectByJsObject(array);

	const string elementSignature = arraySignature.substr(1);
	jboolean isCopy = false;

	if (elementSignature == "Z") //bool
	{
		jboolean boolElementValue = (jboolean) value->BooleanValue();
		jbooleanArray boolArr = reinterpret_cast<jbooleanArray>(arr);
		env.SetBooleanArrayRegion(boolArr, index, 1, &boolElementValue);
	}
	else if (elementSignature == "B") //byte
	{
		jbyte byteElementValue = (jbyte) value->Int32Value();
		jbyteArray byteArr = reinterpret_cast<jbyteArray>(arr);
		env.SetByteArrayRegion(byteArr, index, 1, &byteElementValue);
	}
	else if (elementSignature == "C") //char
	{
		String::Utf8Value utf8(value->ToString());
		JniLocalRef s(env.NewString((jchar*) *utf8, 1));
		const char* singleChar = env.GetStringUTFChars(s, &isCopy);
		jchar charElementValue = *singleChar;
		env.ReleaseStringUTFChars(s, singleChar);
		jcharArray charArr = reinterpret_cast<jcharArray>(arr);
		env.SetCharArrayRegion(charArr, index, 1, &charElementValue);
	}
	else if (elementSignature == "S") //short
	{
		jshort shortElementValue = (jshort) value->Int32Value();
		jshortArray shortArr = reinterpret_cast<jshortArray>(arr);
		env.SetShortArrayRegion(shortArr, index, 1, &shortElementValue);
	}
	else if (elementSignature == "I") //int
	{
		jint intElementValue = value->Int32Value();
		jintArray intArr = reinterpret_cast<jintArray>(arr);
		env.SetIntArrayRegion(intArr, index, 1, &intElementValue);
	}
	else if (elementSignature == "J") //long
	{
		jlong longElementValue;
		if (value->IsObject())
		{
			longElementValue = (jlong) ArgConverter::ConvertToJavaLong(value);
		}
		else
		{
			longElementValue = (jlong) value->IntegerValue();
		}
		jlongArray longArr = reinterpret_cast<jlongArray>(arr);
		env.SetLongArrayRegion(longArr, index, 1, &longElementValue);
	}
	else if (elementSignature == "F") //float
	{
		jfloat floatElementValue = (jfloat) value->NumberValue();
		jfloatArray floatArr = reinterpret_cast<jfloatArray>(arr);
		env.SetFloatArrayRegion(floatArr, index, 1, &floatElementValue);
	}
	else if (elementSignature == "D") //double
	{
		jdouble doubleElementValue = (jdouble) value->NumberValue();
		jdoubleArray doubleArr = reinterpret_cast<jdoubleArray>(arr);
		env.SetDoubleArrayRegion(doubleArr, index, 1, &doubleElementValue);
	}
	else //string or object
	{
		bool isReferenceType = value->IsObject() || value->IsString();
		if (isReferenceType)
		{
			auto object = value.As<Object>();

			JsArgToArrayConverter argConverter(value, false, (int)Type::Null);
			if (argConverter.IsValid())
			{
				jobjectArray objArr = reinterpret_cast<jobjectArray>(arr);
				jobject objectElementValue = argConverter.GetConvertedArg();
				env.SetObjectArrayElement(objArr, index, objectElementValue);
			}
			else
			{
				JsArgToArrayConverter::Error err = argConverter.GetError();
				throw NativeScriptException(string(err.msg));
			}
		}
		else
		{
			throw NativeScriptException(string("Cannot assign primitive value to array of objects."));
		}
	}
}
开发者ID:slavchev,项目名称:android-runtime,代码行数:98,代码来源:ArrayElementAccessor.cpp

示例4: getBoolean

bool Settings::getBoolean(const char* property, bool defaultValue = false) {
  Local<Value> tmp = get(property);
  return (tmp->IsBoolean())? tmp->BooleanValue() : defaultValue;
}
开发者ID:Dinesh-Ramakrishnan,项目名称:appjs,代码行数:4,代码来源:util.cpp

示例5: BindParameters

    bool QueryOperation::BindParameters( Handle<Array> node_params )
    {
        uint32_t count = node_params->Length();

        if( count > 0 ) {

            for( uint32_t i = 0; i < count; ++i ) {

                Local<Value> p = node_params->Get( i );
                ParamBinding binding;

                if( p->IsNull() ) {

                    binding.js_type = ParamBinding::JS_NULL;
                    binding.c_type = SQL_C_CHAR;
                    binding.sql_type = SQL_CHAR;
                    binding.param_size = 1;
                    binding.digits = 0;
                    binding.buffer = NULL;
                    binding.buffer_len = 0;
                    binding.indptr = SQL_NULL_DATA;
                }
                else if( p->IsString() ) {

                    binding.js_type = ParamBinding::JS_STRING;
                    binding.c_type = SQL_C_WCHAR;
                    binding.sql_type = SQL_WVARCHAR;
                    Local<String> str_param = p->ToString();
                    int str_len = str_param->Length();
                    binding.buffer = new uint16_t[ str_len + 1 ];   // null terminator
                    str_param->Write( static_cast<uint16_t*>( binding.buffer ));
                    if( str_len > 4000 ) {
                        binding.param_size = 0;     // max types require 0 precision
                    }
                    else {
                        binding.param_size = str_len;
                    }
                    binding.buffer_len = str_len * sizeof( uint16_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsBoolean() ) {
                    
                    binding.js_type = ParamBinding::JS_BOOLEAN;
                    binding.c_type = SQL_C_BIT;
                    binding.sql_type = SQL_BIT;
                    binding.buffer = new uint16_t;
                    binding.buffer_len = sizeof( uint16_t );
                    *static_cast<uint16_t*>( binding.buffer ) = p->BooleanValue();
                    binding.param_size = 1;
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsInt32()) {

                    binding.js_type = ParamBinding::JS_INT;
                    binding.c_type = SQL_C_SLONG;
                    binding.sql_type = SQL_INTEGER;
                    binding.buffer = new int32_t;
                    binding.buffer_len = sizeof( int32_t );
                    *static_cast<int32_t*>( binding.buffer ) = p->Int32Value();
                    binding.param_size = sizeof( int32_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsUint32()) {

                    binding.js_type = ParamBinding::JS_UINT;
                    binding.c_type = SQL_C_ULONG;
                    binding.sql_type = SQL_BIGINT;
                    binding.buffer = new uint32_t;
                    binding.buffer_len = sizeof( uint32_t );
                    *static_cast<int32_t*>( binding.buffer ) = p->Uint32Value();
                    binding.param_size = sizeof( uint32_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsNumber()) {

                    // numbers can be either integers or doubles.  We attempt to determine which it is through a simple
                    // cast and equality check
                    double d = p->NumberValue();
                    if( _isnan( d ) || !_finite( d ) ) {

                        return ParameterErrorToUserCallback( i, "Invalid number parameter" );

                    }
                    else if( d == floor( d ) && 
                             d >= std::numeric_limits<int64_t>::min() && 
                             d <= std::numeric_limits<int64_t>::max() ) {

                        binding.js_type = ParamBinding::JS_NUMBER;
                        binding.c_type = SQL_C_SBIGINT;
                        binding.sql_type = SQL_BIGINT;
                        binding.buffer = new int64_t;
                        binding.buffer_len = sizeof( int64_t );
                        *static_cast<int64_t*>( binding.buffer ) = p->IntegerValue();
                        binding.param_size = sizeof( int64_t );
                        binding.digits = 0;
                        binding.indptr = binding.buffer_len;
//.........这里部分代码省略.........
开发者ID:ArronYR,项目名称:node-sqlserver,代码行数:101,代码来源:OdbcOperation.cpp

示例6: SetJavaField

void FieldAccessor::SetJavaField(const Local<Object>& target, const Local<Value>& value, FieldCallbackData *fieldData)
{
	JEnv env;

	auto isolate = Isolate::GetCurrent();
	HandleScope handleScope(isolate);

	jweak targetJavaObject;

	const auto& fieldTypeName = fieldData->signature;
	auto isStatic = fieldData->isStatic;

	auto isPrimitiveType = fieldTypeName.size() == 1;
	auto isFieldArray = fieldTypeName[0] == '[';

	if (fieldData->fid == nullptr)
	{
		auto fieldJniSig = isPrimitiveType
							? fieldTypeName
								:
								(isFieldArray
									? fieldTypeName
										:
										("L" + fieldTypeName + ";"));

		if (isStatic)
		{
			fieldData->clazz = env.FindClass(fieldData->declaringType);
			assert(fieldData->clazz != nullptr);
			fieldData->fid = env.GetStaticFieldID(fieldData->clazz, fieldData->name, fieldJniSig);
			assert(fieldData->fid != nullptr);
		}
		else
		{
			fieldData->clazz = env.FindClass(fieldData->declaringType);
			assert(fieldData->clazz != nullptr);
			fieldData->fid = env.GetFieldID(fieldData->clazz, fieldData->name, fieldJniSig);
			assert(fieldData->fid != nullptr);
		}
	}

	if (!isStatic)
	{
		targetJavaObject = objectManager->GetJavaObjectByJsObject(target);

		if (targetJavaObject == nullptr)
		{
			stringstream ss;
			ss << "Cannot access property '" << fieldData->name << "' because there is no corresponding Java object";
			throw NativeScriptException(ss.str());
		}
	}

	auto fieldId = fieldData->fid;
	auto clazz = fieldData->clazz;

	if (isPrimitiveType)
	{
		switch (fieldTypeName[0])
		{
			case 'Z': //bool
			{
				//TODO: validate value is a boolean before calling
				if (isStatic)
				{
					env.SetStaticBooleanField(clazz, fieldId, value->BooleanValue());
				}
				else
				{
					env.SetBooleanField(targetJavaObject, fieldId, value->BooleanValue());
				}
				break;
			}
			case 'B': //byte
			{
				//TODO: validate value is a byte before calling
				if (isStatic)
				{
					env.SetStaticByteField(clazz, fieldId, value->Int32Value());
				}
				else
				{
					env.SetByteField(targetJavaObject, fieldId, value->Int32Value());
				}
				break;
			}
			case 'C': //char
			{
				//TODO: validate value is a single char
				String::Utf8Value stringValue(value->ToString());
				JniLocalRef value(env.NewStringUTF(*stringValue));
				const char* chars = env.GetStringUTFChars(value, 0);

				if (isStatic)
				{
					env.SetStaticCharField(clazz, fieldId, chars[0]);
				}
				else
				{
					env.SetCharField(targetJavaObject, fieldId, chars[0]);
//.........这里部分代码省略.........
开发者ID:Naveenzinke,项目名称:android-runtime,代码行数:101,代码来源:FieldAccessor.cpp

示例7: 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

示例8: runscript

inline bool runscript(const char *source) {
    Local<Script> script = Script::Compile(String::New(source));
    Local<Value> result = script->Run();
    return result->BooleanValue();
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:5,代码来源:v8test.cpp

示例9: SCRSetFullScreen

 void SCRSetFullScreen(Local<String> propname, Local<Value> value, const AccessorInfo& info)
 {
    dtEntity::GetWindowInterface()->SetFullscreen(0, value->BooleanValue());
 }
开发者ID:mathieu,项目名称:dtEntity,代码行数:4,代码来源:screenwrapper.cpp

示例10: SCRSetShowCursor

 void SCRSetShowCursor(Local<String> propname, Local<Value> value, const AccessorInfo& info)
 {
    dtEntity::GetWindowInterface()->SetShowCursor(value->BooleanValue());
 }
开发者ID:mathieu,项目名称:dtEntity,代码行数:4,代码来源:screenwrapper.cpp

示例11: setFlagFromValue

void setFlagFromValue(int *flags, int flag, const char *name, bool defaultValue, Local<Object> options) {
    Local<Value> opt = options->Get(Nan::New<String>(name).ToLocalChecked());
    if (opt->IsBoolean() ? opt->BooleanValue() : defaultValue) {
        *flags |= flag;
    }
}
开发者ID:2nd,项目名称:node-lmdb,代码行数:6,代码来源:misc.cpp

示例12: GetParametersFromArray

Parameter* ODBC::GetParametersFromArray (Local<Array> values, int *paramCount) {
    DEBUG_PRINTF("ODBC::GetParametersFromArray\n");
    *paramCount = values->Length();

    Parameter* params = NULL;

    if (*paramCount > 0) {
        params = (Parameter *) malloc(*paramCount * sizeof(Parameter));
    }

    for (int i = 0; i < *paramCount; i++) {
        Local<Value> value = values->Get(i);

        params[i].ColumnSize       = 0;
        params[i].StrLen_or_IndPtr = SQL_NULL_DATA;
        params[i].BufferLength     = 0;
        params[i].DecimalDigits    = 0;

        DEBUG_PRINTF("ODBC::GetParametersFromArray - param[%i].length = %lli\n",
                     i, params[i].StrLen_or_IndPtr);

        if (value->IsString()) {
            Local<String> string = value->ToString();
            int length = string->Length();

            params[i].ValueType         = SQL_C_TCHAR;
            params[i].ColumnSize        = 0; //SQL_SS_LENGTH_UNLIMITED
#ifdef UNICODE
            params[i].ParameterType     = SQL_WVARCHAR;
            params[i].BufferLength      = (length * sizeof(uint16_t)) + sizeof(uint16_t);
#else
            params[i].ParameterType     = SQL_VARCHAR;
            params[i].BufferLength      = string->Utf8Length() + 1;
#endif
            params[i].ParameterValuePtr = malloc(params[i].BufferLength);
            params[i].StrLen_or_IndPtr  = SQL_NTS;//params[i].BufferLength;

#ifdef UNICODE
            string->Write((uint16_t *) params[i].ParameterValuePtr);
#else
            string->WriteUtf8((char *) params[i].ParameterValuePtr);
#endif

            DEBUG_PRINTF("ODBC::GetParametersFromArray - IsString(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%s\n",
                         i, params[i].ValueType, params[i].ParameterType,
                         params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
                         (char*) params[i].ParameterValuePtr);
        }
        else if (value->IsNull()) {
            params[i].ValueType = SQL_C_DEFAULT;
            params[i].ParameterType   = SQL_VARCHAR;
            params[i].StrLen_or_IndPtr = SQL_NULL_DATA;

            DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNull(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli\n",
                         i, params[i].ValueType, params[i].ParameterType,
                         params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr);
        }
        else if (value->IsInt32()) {
            int64_t  *number = new int64_t(value->IntegerValue());
            params[i].ValueType = SQL_C_SBIGINT;
            params[i].ParameterType   = SQL_BIGINT;
            params[i].ParameterValuePtr = number;
            params[i].StrLen_or_IndPtr = 0;

            DEBUG_PRINTF("ODBC::GetParametersFromArray - IsInt32(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%lld\n",
                         i, params[i].ValueType, params[i].ParameterType,
                         params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
                         *number);
        }
        else if (value->IsNumber()) {
            double *number   = new double(value->NumberValue());

            params[i].ValueType         = SQL_C_DOUBLE;
            params[i].ParameterType     = SQL_DECIMAL;
            params[i].ParameterValuePtr = number;
            params[i].BufferLength      = sizeof(double);
            params[i].StrLen_or_IndPtr  = params[i].BufferLength;
            params[i].DecimalDigits     = 7;
            params[i].ColumnSize        = sizeof(double);

            DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNumber(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%f\n",
                         i, params[i].ValueType, params[i].ParameterType,
                         params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
                         *number);
        }
        else if (value->IsBoolean()) {
            bool *boolean = new bool(value->BooleanValue());
            params[i].ValueType         = SQL_C_BIT;
            params[i].ParameterType     = SQL_BIT;
            params[i].ParameterValuePtr = boolean;
            params[i].StrLen_or_IndPtr  = 0;

            DEBUG_PRINTF("ODBC::GetParametersFromArray - IsBoolean(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli\n",
                         i, params[i].ValueType, params[i].ParameterType,
                         params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr);
        }
    }

    return params;
}
开发者ID:jstopchick,项目名称:node-odbc,代码行数:100,代码来源:odbc.cpp

示例13: SetBlur

void Window::SetBlur(Local<String> property, Local<Value> value, const AccessorInfo& info) {
  NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());
  window->SetBlur(value->BooleanValue());
}
开发者ID:jasperla,项目名称:appjs,代码行数:4,代码来源:appjs_window.cpp

示例14: ConvertArg

bool JsArgToArrayConverter::ConvertArg(const Local<Value>& arg, int index)
{
	bool success = false;
	stringstream s;

	JEnv env;

	Type returnType = JType::getClassType(m_return_type);

	if (arg.IsEmpty())
	{
		s << "Cannot convert empty JavaScript object";
		success = false;
	}
	else if (arg->IsInt32() && (returnType == Type::Int || returnType == Type::Null))
	{
		jint value = arg->Int32Value();
		JniLocalRef javaObject(JType::NewInt(env, value));
		SetConvertedObject(env, index, javaObject);

		success = true;
	}
	else if (arg->IsNumber() || arg->IsNumberObject())
	{
		double d = arg->NumberValue();
		int64_t i = (int64_t)d;
		bool isInteger = d == i;

		if (isInteger)
		{
			jobject obj;

			//if returnType is long it will cast to long
			//if there is no return type specified it will cast to int
			//because default return type is null (ref type)
			if ((INT_MIN <= i) && (i <= INT_MAX) && (returnType == Type::Int || returnType == Type::Null))
			{
				obj = JType::NewInt(env, (jint)d);
			}
			else /*isLong*/
			{
				obj = JType::NewLong(env, (jlong)d);
			}

			JniLocalRef javaObject(obj);
			SetConvertedObject(env, index, javaObject);

			success = true;
		}
		else
		{
			jobject obj;

			//if returnType is double it will cast to double
			//if there is no return type specified it will cast to float
			//because default return type is null (ref type)
			if((FLT_MIN <= d) && (d <= FLT_MAX) && (returnType == Type::Float || returnType == Type::Null)) {
				obj = JType::NewFloat(env, (jfloat)d);
			}
			else {/*isDouble*/
				obj = JType::NewDouble(env, (jdouble)d);
			}

			JniLocalRef javaObject(obj);
			SetConvertedObject(env, index, javaObject);

			success = true;
		}
	}
	else if (arg->IsBoolean())
	{
		jboolean value = arg->BooleanValue();
		JniLocalRef javaObject(JType::NewBoolean(env, value));
		SetConvertedObject(env, index, javaObject);
		success = true;
	}
	else if (arg->IsBooleanObject())
	{
		auto boolObj = Local<BooleanObject>::Cast(arg);
		jboolean value = boolObj->BooleanValue() ? JNI_TRUE : JNI_FALSE;
		JniLocalRef javaObject(JType::NewBoolean(env, value));
		SetConvertedObject(env, index, javaObject);

		success = true;
	}
	else if (arg->IsString() || arg->IsStringObject())
	{
		JniLocalRef stringObject(ConvertToJavaString(arg));
		SetConvertedObject(env, index, stringObject);

		success = true;
	}
	else if (arg->IsObject())
	{
		auto objectWithHiddenID = arg->ToObject();

		auto hidden = objectWithHiddenID->GetHiddenValue(V8StringConstants::GetMarkedAsLong());
		if (!hidden.IsEmpty())
		{
			jlong value = 0;
//.........这里部分代码省略.........
开发者ID:slavchev,项目名称:android-runtime,代码行数:101,代码来源:JsArgToArrayConverter.cpp

示例15: GetParametersFromArray

Parameter* ODBC::GetParametersFromArray (Local<Array> values, int *paramCount) {
  DEBUG_PRINTF("ODBC::GetParametersFromArray\n");
  *paramCount = values->Length();
  
  Parameter* params = (Parameter *) malloc(*paramCount * sizeof(Parameter));

  for (int i = 0; i < *paramCount; i++) {
    Local<Value> value = values->Get(i);
    
    params[i].size          = 0;
    params[i].length        = SQL_NULL_DATA;
    params[i].buffer_length = 0;
    params[i].decimals      = 0;

    DEBUG_PRINTF("ODBC::GetParametersFromArray - &param[%i].length = %X\n",
                 i, &params[i].length);

    if (value->IsString()) {
      Local<String> string = value->ToString();
      int length = string->Length();
      
      params[i].c_type        = SQL_C_TCHAR;
#ifdef UNICODE
      params[i].type          = (length >= 8000) ? SQL_WLONGVARCHAR : SQL_WVARCHAR;
      params[i].buffer_length = (length * sizeof(uint16_t)) + sizeof(uint16_t);
#else
      params[i].type          = (length >= 8000) ? SQL_LONGVARCHAR : SQL_VARCHAR;
      params[i].buffer_length = string->Utf8Length() + 1;
#endif
      params[i].buffer        = malloc(params[i].buffer_length);
      params[i].size          = params[i].buffer_length;
      params[i].length        = SQL_NTS;//params[i].buffer_length;

#ifdef UNICODE
      string->Write((uint16_t *) params[i].buffer);
#else
      string->WriteUtf8((char *) params[i].buffer);
#endif

      DEBUG_PRINTF("ODBC::GetParametersFromArray - IsString(): params[%i] "
                   "c_type=%i type=%i buffer_length=%i size=%i length=%i "
                   "value=%s\n", i, params[i].c_type, params[i].type,
                   params[i].buffer_length, params[i].size, params[i].length, 
                   (char*) params[i].buffer);
    }
    else if (value->IsNull()) {
      params[i].c_type = SQL_C_DEFAULT;
      params[i].type   = SQL_VARCHAR;
      params[i].length = SQL_NULL_DATA;

      DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNull(): params[%i] "
                   "c_type=%i type=%i buffer_length=%i size=%i length=%i\n",
                   i, params[i].c_type, params[i].type,
                   params[i].buffer_length, params[i].size, params[i].length);
    }
    else if (value->IsInt32()) {
      int64_t  *number = new int64_t(value->IntegerValue());
      params[i].c_type = SQL_C_SBIGINT;
      params[i].type   = SQL_BIGINT;
      params[i].buffer = number;
      params[i].length = 0;
      
      DEBUG_PRINTF("ODBC::GetParametersFromArray - IsInt32(): params[%i] "
                   "c_type=%i type=%i buffer_length=%i size=%i length=%i "
                   "value=%lld\n", i, params[i].c_type, params[i].type,
                   params[i].buffer_length, params[i].size, params[i].length,
                   *number);
    }
    else if (value->IsNumber()) {
      double *number   = new double(value->NumberValue());
      
      params[i].c_type        = SQL_C_DOUBLE;
      params[i].type          = SQL_DECIMAL;
      params[i].buffer        = number;
      params[i].buffer_length = sizeof(double);
      params[i].length        = params[i].buffer_length;
      params[i].decimals      = 7;
      params[i].size          = sizeof(double);

      DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNumber(): params[%i] "
                  "c_type=%i type=%i buffer_length=%i size=%i length=%i "
		  "value=%f\n",
                  i, params[i].c_type, params[i].type,
                  params[i].buffer_length, params[i].size, params[i].length,
		  *number);
    }
    else if (value->IsBoolean()) {
      bool *boolean    = new bool(value->BooleanValue());
      params[i].c_type = SQL_C_BIT;
      params[i].type   = SQL_BIT;
      params[i].buffer = boolean;
      params[i].length = 0;
      
      DEBUG_PRINTF("ODBC::GetParametersFromArray - IsBoolean(): params[%i] "
                   "c_type=%i type=%i buffer_length=%i size=%i length=%i\n",
                   i, params[i].c_type, params[i].type,
                   params[i].buffer_length, params[i].size, params[i].length);
    }
  } 
  
//.........这里部分代码省略.........
开发者ID:theduderog,项目名称:node-odbc,代码行数:101,代码来源:odbc.cpp


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