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


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

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


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

示例1: 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();
    }
}
开发者ID:jice1001,项目名称:server,代码行数:51,代码来源:Msg_Struct.cpp

示例2: setVectorY

void vectorTemplate::setVectorY(Local<String> property, Local<Value> value, const AccessorInfo &info){
	Local<External> data = Local<External>::Cast(info.Data());
	vector<double> *vect = reinterpret_cast<vector<double> *>(data->Value());
	if(value->IsNumber()){
		vect->y = value->ToNumber()->Value();
	}
}
开发者ID:boxyoman,项目名称:jsbots,代码行数:7,代码来源:vectorTemplate.cpp

示例3: ThrowException

	Handle<Value> Texture::On(const Arguments &args)
	{
		HandleScope scope;
		Local<Value> Event;
		Local<Value> Options;
		Local<Value> Callback;
		ClutterActor *instance = ObjectWrap::Unwrap<Texture>(args.This())->_actor;
#if 0
		/* Check arguments */
		if (args.Length() == 2) {
			Event = args[0];
			Callback = args[1];
		} else if (args.Length() == 3) {
			Event = args[0];
			Options = args[1];
			Callback = args[2];
		} else
			return args.This();

		if (!Event->IsNumber()) {
			return ThrowException(Exception::TypeError(
				String::New("first argument must be integer")));
		}

		if (!Callback->IsFunction()) {
			return ThrowException(Exception::TypeError(
				String::New("Second argument must be a callback function")));
		}
#endif
		Actor::On(args);

		return args.This();
	}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:33,代码来源:texture.cpp

示例4: setSharedRAM

/* Set the shared PRU RAM to an input array
 *	Takes an integer array as input, writes it to PRU shared memory
 *	Not much error checking here, don't pass in large arrays or seg faults will happen
 *	TODO: error checking and allow user to select range to set
 */
Handle<Value> setSharedRAM(const Arguments& args) {
	HandleScope scope;
	
	//Check we have a single argument
	if (args.Length() != 1) {
		ThrowException(Exception::TypeError(String::New("Wrong number of arguments")));
		return scope.Close(Undefined());
	}
	
	//Check that it's an array
	if (!args[0]->IsArray()) {
		ThrowException(Exception::TypeError(String::New("Argument must be array")));
		return scope.Close(Undefined());
	}
	
	//Get array
	Local<Array> a = Array::Cast(*args[0]);
	
	//Iterate over array
	for (unsigned int i = 0; i<a->Length(); i++) {
		//Get element and check it's numeric
		Local<Value> element = a->Get(i);
		if (!element->IsNumber()) {
			ThrowException(Exception::TypeError(String::New("Array must be integer")));
			return scope.Close(Undefined());
		}
		
		//Set corresponding memory bytes
		sharedMem_int[OFFSET_SHAREDRAM + i] = (unsigned int) element->NumberValue();
	}
	
	//Return nothing
	return scope.Close(Undefined());
};
开发者ID:NathanGillis,项目名称:node-pru,代码行数:39,代码来源:pru.cpp

示例5: TryConvertToJavaLong

bool ArgConverter::TryConvertToJavaLong(const Local<Value>& value, jlong& javaLong)
{
	bool success = false;

	if (!value.IsEmpty())
	{
		if (value->IsNumber() || value->IsNumberObject())
		{
			javaLong = (jlong)value->IntegerValue();
			success = true;
		}
		else if (value->IsObject())
		{
			auto obj = Local<Object>::Cast(value);
			auto isJavaLongValue = obj->GetHiddenValue(V8StringConstants::GetJavaLong());
			if (!isJavaLongValue.IsEmpty() && isJavaLongValue->BooleanValue())
			{
				javaLong = (jlong)ConvertToJavaLong(value);
				success = true;
			}
		}
	}

	return success;
}
开发者ID:slavchev,项目名称:android-runtime,代码行数:25,代码来源:ArgConverter.cpp

示例6: NODE_THROW

Handle<Value> Dataset::setGeoTransform(const Arguments& args)
{
	Dataset *ds = ObjectWrap::Unwrap<Dataset>(args.This());
	if(!ds->this_) return NODE_THROW("Dataset object has already been destroyed");

	Handle<Array> transform;
	NODE_ARG_ARRAY(0, "transform", transform);

	if (transform->Length() != 6) {
		return NODE_THROW("Transform array must have 6 elements")
	}

	double buffer[6];
	for (int i = 0; i < 6; i++) {
		Local<Value> val = transform->Get(i);
		if (!val->IsNumber()) {
			return NODE_THROW("Transform array must only contain numbers");
		}
		buffer[i] = val->NumberValue();
	}

	CPLErr err = ds->this_->SetGeoTransform(buffer);
	if (err) return NODE_THROW_CPLERR(err);

	return Undefined();
}
开发者ID:diorahman,项目名称:node-gdal,代码行数:26,代码来源:gdal_dataset.cpp

示例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);
}
开发者ID:w1nk,项目名称:node-mongodb,代码行数:35,代码来源:bson.cpp

示例8: SetState

void UiWindow::SetState(Local<String> property, Local<Value> value, const PropertyCallbackInfo<void>& info) {
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);
    UiWindow* _this = Unwrap<UiWindow>(info.This());
    if (value->IsNumber()) {
        WINDOW_STATE state = (WINDOW_STATE)value->Int32Value();
        _this->SetState(state);
    }
}
开发者ID:NextGenIntelligence,项目名称:io-ui,代码行数:9,代码来源:ui-window.cpp

示例9: FetchModeSetter

void ODBCResult::FetchModeSetter(Local<String> property, Local<Value> value, const AccessorInfo &info) {
  HandleScope scope;

  ODBCResult *obj = ObjectWrap::Unwrap<ODBCResult>(info.Holder());
  
  if (value->IsNumber()) {
    obj->m_fetchMode = value->Int32Value();
  }
}
开发者ID:hcsoft,项目名称:nodewebhis,代码行数:9,代码来源:odbc_result.cpp

示例10: SpacingSetter

	void BoxLayout::SpacingSetter(Local<String> name, Local<Value> value, const AccessorInfo& info)
	{
		HandleScope scope;

		if (value->IsNumber()) {
			ClutterActor *instance = ObjectWrap::Unwrap<BoxLayout>(info.This())->_actor;

			mx_box_layout_set_spacing(MX_BOX_LAYOUT(instance), value->ToInteger()->Value());
		}
	}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:10,代码来源:box_layout.cpp

示例11: FilterQualitySetter

	void Texture::FilterQualitySetter(Local<String> name, Local<Value> value, const AccessorInfo& info)
	{
		HandleScope scope;

		if (value->IsNumber()) {
			ClutterActor *instance = ObjectWrap::Unwrap<Actor>(info.This())->_actor;

			clutter_texture_set_filter_quality(CLUTTER_TEXTURE(instance), (ClutterTextureQuality)value->ToInteger()->Value());
		}
	}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:10,代码来源:texture.cpp

示例12: ScaleModeSetter

	void Image::ScaleModeSetter(Local<String> name, Local<Value> value, const AccessorInfo& info)
	{
		HandleScope scope;

		if (value->IsNumber()) {
			ClutterActor *instance = ObjectWrap::Unwrap<Image>(info.This())->_actor;

			mx_image_set_scale_mode(MX_IMAGE(instance), (MxImageScaleMode)value->ToInteger()->Value());
		}
	}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:10,代码来源:image.cpp

示例13: ColumnSpacingSetter

	void Table::ColumnSpacingSetter(Local<String> name, Local<Value> value, const AccessorInfo& info)
	{
		HandleScope scope;

		if (value->IsNumber()) {
			ClutterActor *instance = ObjectWrap::Unwrap<Table>(info.This())->_actor;

			mx_table_set_column_spacing(MX_TABLE(instance), value->ToInteger()->Value());
		}
	}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:10,代码来源:table.cpp

示例14: 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();
}
开发者ID:booo,项目名称:node-mapnik,代码行数:54,代码来源:mapnik_feature.cpp

示例15: zSetter

void Point::zSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
	Point *geom = ObjectWrap::Unwrap<Point>(info.This());

	if (!value->IsNumber()) {
		NODE_THROW("z must be a number");
		return;
	}
	double z = value->NumberValue();

	((OGRPoint* )geom->this_)->setZ(z);
}
开发者ID:jarped,项目名称:node-gdal,代码行数:12,代码来源:gdal_point.cpp


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