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


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

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


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

示例1: PropertySetter

void MSMap::PropertySetter (Local<String> property, Local<Value> value, const AccessorInfo& info) {
  MSMap *map = ObjectWrap::Unwrap<MSMap>(info.Holder());
  v8::String::AsciiValue n(property);
  if (strcmp(*n, "width") == 0) {
    map->this_->width = value->Int32Value();
  } else if (strcmp(*n, "height") == 0) {
    map->this_->height = value->Int32Value();
  } else if (strcmp(*n, "maxsize") == 0) {
    map->this_->maxsize = value->Int32Value();
  } else if (strcmp(*n, "units") == 0) {
    int32_t units = value->Int32Value();
    if (units >= MS_INCHES && units <= MS_NAUTICALMILES) {
      map->this_->units = (MS_UNITS) units;
    }
  } else if (strcmp(*n, "resolution") == 0) {
    map->this_->resolution = value->NumberValue();
  } else if (strcmp(*n, "defresolution") == 0) {
    map->this_->defresolution = value->NumberValue();
  } else if (strcmp(*n, "name") == 0) {
    REPLACE_STRING(map->this_->name, value);
  } else if (strcmp(*n, "imagetype") == 0) {
    REPLACE_STRING(map->this_->imagetype, value);
  } else if (strcmp(*n, "shapepath") == 0) {
    REPLACE_STRING(map->this_->shapepath, value);
  } else if (strcmp(*n, "projection") == 0) {
    v8::String::AsciiValue _v_(value->ToString());
    msLoadProjectionString(&(map->this_->projection), *_v_);
  } else if (strcmp(*n, "mappath") == 0) {
    REPLACE_STRING(map->this_->mappath, value);
  }
}
开发者ID:MarkHauenstein,项目名称:node-mapserver,代码行数:31,代码来源:ms_map.cpp

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

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

示例4: PropertySetter

void MSRect::PropertySetter (Local<String> property, Local<Value> value, const AccessorInfo& info) {
  MSRect *rect = ObjectWrap::Unwrap<MSRect>(info.Holder());
  v8::String::AsciiValue n(property);
  double t;

  if (strcmp(*n, "minx") == 0) {
    rect->this_->minx = value->NumberValue();
  } else if (strcmp(*n, "miny") == 0) {
    rect->this_->miny = value->NumberValue();
  } else if (strcmp(*n, "maxx") == 0) {
    rect->this_->maxx = value->NumberValue();
  } else if (strcmp(*n, "maxy") == 0) {
    rect->this_->maxy = value->NumberValue();
  }
}
开发者ID:MarkHauenstein,项目名称:node-mapserver,代码行数:15,代码来源:ms_rect.cpp

示例5: ThrowException

/* static  */
Handle<Value> MemoryObject::getMemObjectInfo(const Arguments& args)
{
    HandleScope scope;

    MemoryObject *mo = ObjectWrap::Unwrap<MemoryObject>(args.This());
    Local<Value> v = args[0];
    cl_mem_info param_name = v->NumberValue();
    size_t param_value_size_ret = 0;
    char param_value[1024];

    cl_int ret = MemoryObjectWrapper::memoryObjectInfoHelper(mo->getMemoryObjectWrapper(),
							     param_name,
							     sizeof(param_value),
							     param_value,
							     &param_value_size_ret);

    if (ret != CL_SUCCESS) {
	WEBCL_COND_RETURN_THROW(CL_INVALID_VALUE);
	WEBCL_COND_RETURN_THROW(CL_INVALID_MEM_OBJECT);
	WEBCL_COND_RETURN_THROW(CL_OUT_OF_RESOURCES);
	WEBCL_COND_RETURN_THROW(CL_OUT_OF_HOST_MEMORY);
	return ThrowException(Exception::Error(String::New("UNKNOWN ERROR")));
    }

    switch (param_name) {
    case CL_MEM_TYPE:
    case CL_MEM_FLAGS:
    case CL_MEM_REFERENCE_COUNT:
    case CL_MEM_MAP_COUNT:
	return scope.Close(Integer::NewFromUnsigned(*(cl_uint*)param_value));
    case CL_MEM_SIZE:
    case CL_MEM_OFFSET:
	return scope.Close(Number::New(*(size_t*)param_value));
    case CL_MEM_ASSOCIATED_MEMOBJECT: {
	cl_mem mem = *((cl_mem*)param_value);
	MemoryObjectWrapper *mw = new MemoryObjectWrapper(mem);
	return scope.Close(MemoryObject::New(mw)->handle_);
    }
    case CL_MEM_HOST_PTR: {
	char *ptr = *((char**)param_value);
	param_name = CL_MEM_SIZE;
	ret = MemoryObjectWrapper::memoryObjectInfoHelper(mo->getMemoryObjectWrapper(),
							  param_name,
							  sizeof(param_value),
							  param_value,
							  &param_value_size_ret);
	if (ret != CL_SUCCESS) {
	    WEBCL_COND_RETURN_THROW(CL_INVALID_VALUE);
	    WEBCL_COND_RETURN_THROW(CL_INVALID_MEM_OBJECT);
	    WEBCL_COND_RETURN_THROW(CL_OUT_OF_RESOURCES);
	    WEBCL_COND_RETURN_THROW(CL_OUT_OF_HOST_MEMORY);
	    return ThrowException(Exception::Error(String::New("UNKNOWN ERROR")));
	}
	size_t nbytes = *(size_t*)param_value;
	return scope.Close(node::Buffer::New(ptr, nbytes)->handle_);
    }
    default:
	return ThrowException(Exception::Error(String::New("UNKNOWN param_name")));
    }
}
开发者ID:alfaha,项目名称:node-webcl,代码行数:61,代码来源:memoryobject.cpp

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

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

示例8: SetCoeff

void WrappedPoly::SetCoeff(Local<String> property, Local<Value> value, const PropertyCallbackInfo<void>& info) {
    WrappedPoly* obj = ObjectWrap::Unwrap<WrappedPoly>(info.This());
    
    v8::String::Utf8Value s(property);
    std::string str(*s);
    
    if ( str == "a") {
        obj->a_ = value->NumberValue();
    }
    else if (str == "b") {
        obj->b_ = value->NumberValue();
    }
    else if (str == "c") {
        obj->c_ = value->NumberValue();
    }
}
开发者ID:116356754,项目名称:nodecpp-demo,代码行数:16,代码来源:polynomial.cpp

示例9: SetX

void Point::SetX( Local< String > prop, Local< Value > value, const PropertyCallbackInfo< void > &info ) {
	// Enter new scope
	HandleScope scope;

	// Get wrapped object
	Local< Object > self = info.Holder();
	Local< External > wrap = Local< External >::Cast( self->GetInternalField( 0 ) );

	// Set internal value
	static_cast< Point* >( wrap->Value() )->SetX( value->NumberValue() );
}
开发者ID:TheCodeInside,项目名称:v8-example,代码行数:11,代码来源:point.cpp

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

示例11: ThrowException

/*! Get the name of an audio device with a given ID number */
v8::Handle<v8::Value> Audio::AudioEngine::getDeviceName( const v8::Arguments& args ) {
	HandleScope scope;

	if( !args[0]->IsNumber() ) {
		return scope.Close( ThrowException(Exception::TypeError(String::New("getDeviceName() requires a device index"))) );
	}

	Local<Number> deviceIndex = Local<Number>::Cast( args[0] );

	const PaDeviceInfo* pDeviceInfo = Pa_GetDeviceInfo( (PaDeviceIndex)deviceIndex->NumberValue() );

	return scope.Close( String::New(pDeviceInfo->name) );
} // end AudioEngine::GetDeviceName()
开发者ID:alex-milanov,项目名称:node-core-audio,代码行数:14,代码来源:AudioEngine.cpp

示例12: getDateTime

int TiUtils::getDateTime(Handle<Value> value, QDateTime& dt)
{
    if ((value.IsEmpty()) || (!value->IsDate()))
    {
        return NATIVE_ERROR_INVALID_ARG;
    }

    unsigned int year = 0, month = 0, day = 0;
    Local<Object> object = Object::Cast(*value);

    // Get year from date
    Local<Value> getYear_prop = (object->Get(String::New("getFullYear")));
    if (getYear_prop->IsFunction())
    {
        Local<Function> getYear_func = Function::Cast(*getYear_prop);
        Local<Value> yearValue = getYear_func->Call(object, 0, NULL);
        year = yearValue->NumberValue();
    }

    // Get month from date
    Local<Value> getMonth_prop = (object->Get(String::New("getMonth")));
    if (getMonth_prop->IsFunction())
    {
        Local<Function> getMonth_func = Function::Cast(*getMonth_prop);
        Local<Value> monthValue = getMonth_func->Call(object, 0, NULL);
        month = monthValue->NumberValue();
    }

    // Get day property
    Local<Value> getDay_prop = (object->Get(String::New("getDate")));
    if (getDay_prop->IsFunction())
    {
        Local<Function> getDay_func = Function::Cast(*getDay_prop);
        Local<Value> dayValue = getDay_func->Call(object, 0, NULL);
        day = dayValue->NumberValue();
    }
    dt.setDate(QDate(year, month, day));
    return NATIVE_ERROR_OK;
}
开发者ID:HazemKhaled,项目名称:titanium_mobile_blackberry,代码行数:39,代码来源:TiUtils.cpp

示例13: SetOpacity

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

示例14: ThrowException

/* static */
Handle<Value> KernelObject::getKernelWorkGroupInfo(const Arguments& args)
{
    HandleScope scope;
    KernelObject *kernelObject = ObjectWrap::Unwrap<KernelObject>(args.This());
    Device *device = ObjectWrap::Unwrap<Device>(args[0]->ToObject());
    Local<Value> v = args[1];
    cl_kernel_work_group_info param_name = v->NumberValue();
    size_t param_value_size_ret = 0;
    char param_value[1024];
    cl_int ret = KernelWrapper::kernelWorkGroupInfoHelper(kernelObject->getKernelWrapper(),
							  device->getDeviceWrapper(),
							  param_name,
							  sizeof(param_value),
							  param_value,
							  &param_value_size_ret);
    if (ret != CL_SUCCESS) {
	WEBCL_COND_RETURN_THROW(CL_INVALID_DEVICE);
	WEBCL_COND_RETURN_THROW(CL_INVALID_VALUE);
	WEBCL_COND_RETURN_THROW(CL_INVALID_KERNEL);
	WEBCL_COND_RETURN_THROW(CL_OUT_OF_RESOURCES);
	WEBCL_COND_RETURN_THROW(CL_OUT_OF_HOST_MEMORY);
	return ThrowException(Exception::Error(String::New("UNKNOWN ERROR")));
    }

    switch (param_name) {
    case CL_KERNEL_WORK_GROUP_SIZE:
    case CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE:
	return scope.Close(Number::New(*(size_t*)param_value));
    case CL_KERNEL_LOCAL_MEM_SIZE:
    case CL_KERNEL_PRIVATE_MEM_SIZE:
	return scope.Close(Number::New(*(cl_ulong*)param_value));
    case CL_KERNEL_COMPILE_WORK_GROUP_SIZE: {
	Local<Array> sizeArray = Array::New(3);
	for (size_t i=0; i<3; i++) {
	    size_t s = ((size_t*)param_value)[i];
	    sizeArray->Set(i, Number::New(s));
	}
	return scope.Close(sizeArray);
    }
    default:
	return ThrowException(Exception::Error(String::New("UNKNOWN param_name")));
    }
}
开发者ID:alfaha,项目名称:node-webcl,代码行数:44,代码来源:kernelobject.cpp

示例15: ThrowException

/*! Changes the output device */
v8::Handle<v8::Value> Audio::AudioEngine::SetOutputDevice( const v8::Arguments& args ) {
	HandleScope scope;

	// Validate the output args
	if( !args[0]->IsNumber() ) {
		return ThrowException( Exception::TypeError(String::New("setOutputDevice() requires a device index")) );
	}

	Local<Number> deviceIndex = Local<Number>::Cast( args[0] );

	AudioEngine* engine = AudioEngine::Unwrap<AudioEngine>( args.This() );

	// Set the new output device
	engine->m_outputParameters.device = deviceIndex->NumberValue();

	// Restart the audio stream
	engine->restartStream( engine );

	return scope.Close( Undefined() );
} // end AudioEngine::SetOutputDevice()
开发者ID:creativeprogramming,项目名称:node-core-audio,代码行数:21,代码来源:AudioEngine.cpp


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