本文整理汇总了C++中Local::IsNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::IsNull方法的具体用法?C++ Local::IsNull怎么用?C++ Local::IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::IsNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBOperationHelper_NonVO
void DBOperationHelper_NonVO(Handle<Object> spec, KeyOperation & op) {
HandleScope scope;
Local<Value> v;
Local<Object> o;
setKeysInOp(spec, op);
v = spec->Get(HELPER_ROW_BUFFER);
if(! v->IsNull()) {
o = v->ToObject();
op.row_buffer = V8BINDER_UNWRAP_BUFFER(o);
}
v = spec->Get(HELPER_ROW_RECORD);
if(! v->IsNull()) {
o = v->ToObject();
const Record * record = unwrapPointer<const Record *>(o);
op.row_record = record;
v = spec->Get(HELPER_BLOBS);
if(v->IsObject()) {
if(op.opcode == 1) {
op.nblobs = op.createBlobReadHandles(record);
} else {
op.nblobs = op.createBlobWriteHandles(v->ToObject(), record);
}
}
}
v = spec->Get(HELPER_LOCK_MODE);
if(! v->IsNull()) {
int intLockMode = v->Int32Value();
op.lmode = static_cast<NdbOperation::LockMode>(intLockMode);
}
v = spec->Get(HELPER_COLUMN_MASK);
if(! v->IsNull()) {
Array *maskArray = Array::Cast(*v);
for(unsigned int m = 0 ; m < maskArray->Length() ; m++) {
Local<Value> colId = maskArray->Get(m);
op.useColumn(colId->Int32Value());
}
}
DEBUG_PRINT("Non-VO %s -- mask: %u lobs: %d", op.getOperationName(),
op.u.maskvalue, op.nblobs);
}
示例2: setKeysInOp
void setKeysInOp(Handle<Object> spec, KeyOperation & op) {
Local<Value> v;
Local<Object> o;
v = spec->Get(HELPER_KEY_BUFFER);
if(! v->IsNull()) {
o = v->ToObject();
op.key_buffer = node::Buffer::Data(o);
}
v = spec->Get(HELPER_KEY_RECORD);
if(! v->IsNull()) {
o = v->ToObject();
op.key_record = unwrapPointer<const Record *>(o);
}
}
示例3: scope
JNIEXPORT void JNICALL
Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeSetWindow
(JNIEnv *env, jobject javaKrollWindow, jlong ptr, jobject javaWindow)
{
HandleScope scope(V8Runtime::v8_isolate);
titanium::JNIScope jniScope(env);
Local<Object> jsKrollWindow;
if (ptr != 0) {
titanium::Proxy* proxy = (titanium::Proxy*) ptr;
jsKrollWindow = proxy->handle(V8Runtime::v8_isolate);
} else {
jsKrollWindow = TypeConverter::javaObjectToJsValue(V8Runtime::v8_isolate, env, javaKrollWindow).As<Object>();
}
Local<Value> setWindowValue = jsKrollWindow->Get(STRING_NEW(V8Runtime::v8_isolate, "setWindow"));
if (!setWindowValue->IsFunction()) {
return;
}
Local<Function> setWindow = setWindowValue.As<Function>();
Local<Value> jsWindow = TypeConverter::javaObjectToJsValue(V8Runtime::v8_isolate, env, javaWindow);
TryCatch tryCatch(V8Runtime::v8_isolate);
if (!jsWindow->IsNull()) {
Local<Value> args[] = { jsWindow };
setWindow->Call(V8Runtime::v8_isolate->GetCurrentContext(), jsKrollWindow, 1, args);
}
if (tryCatch.HasCaught()) {
V8Util::openJSErrorDialog(V8Runtime::v8_isolate, tryCatch);
V8Util::reportException(V8Runtime::v8_isolate, tryCatch);
}
}
示例4: get
rtValue rtNodeContext::get(const char *name)
{
if(name == NULL)
{
rtLogError(" rtNodeContext::get() - no symbolic name for rtValue");
return rtValue();
}
Locker locker(mIsolate);
Isolate::Scope isolate_scope(mIsolate);
HandleScope handle_scope(mIsolate); // Create a stack-allocated handle scope.
// Get a Local context...
Local<Context> local_context = node::PersistentToLocal<Context>(mIsolate, mContext);
Context::Scope context_scope(local_context);
Handle<Object> global = local_context->Global();
// Get the object
Local<Value> object = global->Get( String::NewFromUtf8(mIsolate, name) );
if(object->IsUndefined() || object->IsNull() )
{
rtLogError("FATAL: '%s' is Undefined ", name);
return rtValue();
}
else
{
rtWrapperError error; // TODO - handle error
return js2rt(local_context, object, &error);
}
}
示例5: ThrowException
Handle<Value> Engine::New(Arguments const& args)
{
HandleScope scope;
if (!args.IsConstructCall()) {
return ThrowException(Exception::Error(String::New("Cannot call constructor as function, you need to use 'new' keyword")));
}
try {
if (args.Length() == 1) {
if (!args[0]->IsObject()) {
return ThrowException(Exception::TypeError(String::New("must provide an osrm.Options object")));
}
Local<Object> obj = args[0]->ToObject();
if (obj->IsNull() || obj->IsUndefined() || !Options::constructor->HasInstance(obj)) {
return ThrowException(Exception::TypeError(String::New("osrm.Options object expected for first argument")));
}
Options *opts = ObjectWrap::Unwrap<Options>(obj);
Engine* im = new Engine(opts);
im->Wrap(args.This());
return args.This();
} else {
return ThrowException(Exception::TypeError(String::New("please provide Engine width and height")));
}
} catch (std::exception const& ex) {
return ThrowException(Exception::Error(String::New(ex.what())));
}
return Undefined();
}
示例6: setter_enabled
void PushbotsModule::setter_enabled(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
LOGD(TAG, "set enabled");
HandleScope scope;
JNIEnv *env = titanium::JNIScope::getEnv();
if (!env) {
LOGE(TAG, "Failed to get environment, enabled wasn't set");
return;
}
static jmethodID methodID = NULL;
if (!methodID) {
methodID = env->GetMethodID(PushbotsModule::javaClass, "setEnabled", "(Ljava/lang/Boolean;)V");
if (!methodID) {
const char *error = "Couldn't find proxy method 'setEnabled' with signature '(Ljava/lang/Boolean;)V'";
LOGE(TAG, error);
}
}
titanium::Proxy* proxy = titanium::Proxy::unwrap(info.Holder());
if (!proxy) {
return;
}
jvalue jArguments[1];
bool isNew_0;
if (!value->IsNull()) {
Local<Value> arg_0 = value;
jArguments[0].l =
titanium::TypeConverter::jsValueToJavaObject(env, arg_0, &isNew_0);
} else {
jArguments[0].l = NULL;
}
jobject javaProxy = proxy->getJavaObject();
env->CallVoidMethodA(javaProxy, methodID, jArguments);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
if (isNew_0) {
env->DeleteLocalRef(jArguments[0].l);
}
if (env->ExceptionCheck()) {
titanium::JSException::fromJavaException();
env->ExceptionClear();
}
}
示例7: ThrowException
Handle<Value> ImageView::encode(const Arguments& args)
{
HandleScope scope;
ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
std::string format = "png";
palette_ptr palette;
// accept custom format
if (args.Length() > 1){
if (!args[0]->IsString())
return ThrowException(Exception::TypeError(
String::New("first arg, 'format' must be a string")));
format = TOSTR(args[0]);
}
// options hash
if (args.Length() >= 2) {
if (!args[1]->IsObject())
return ThrowException(Exception::TypeError(
String::New("optional second arg must be an options object")));
Local<Object> options = args[1]->ToObject();
if (options->Has(String::New("palette")))
{
Local<Value> format_opt = options->Get(String::New("palette"));
if (!format_opt->IsObject())
return ThrowException(Exception::TypeError(
String::New("'palette' must be an object")));
Local<Object> obj = format_opt->ToObject();
if (obj->IsNull() || obj->IsUndefined() || !Palette::constructor->HasInstance(obj))
return ThrowException(Exception::TypeError(String::New("mapnik.Palette expected as second arg")));
palette = ObjectWrap::Unwrap<Palette>(obj)->palette();
}
}
// ensure callback is a function
Local<Value> callback = args[args.Length()-1];
if (!args[args.Length()-1]->IsFunction())
return ThrowException(Exception::TypeError(
String::New("last argument must be a callback function")));
encode_image_baton_t *closure = new encode_image_baton_t();
closure->request.data = closure;
closure->im = im;
closure->image = im->this_;
closure->format = format;
closure->palette = palette;
closure->error = false;
closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
uv_queue_work(uv_default_loop(), &closure->request, EIO_Encode, EIO_AfterEncode);
//uv_ref(uv_default_loop());
im->Ref();
return Undefined();
}
示例8: justificationSetter
void FieldDefn::justificationSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This());
OGRJustification justification;
std::string str = TOSTR(value);
if(value->IsString()){
if(str == "Left") {
justification = OJLeft;
} else if (str == "Right") {
justification = OJRight;
} else if (str == "Undefined") {
justification = OJUndefined;
} else {
NODE_THROW("Unrecognized justification");
return;
}
} else if (value->IsNull() || value->IsUndefined()){
justification = OJUndefined;
} else {
NODE_THROW("justification must be a string or undefined");
return;
}
def->this_->SetJustify(justification);
}
示例9: Undefined
Handle<Value> TiAppPropertiesObject::_set(const Arguments& args, PropertyType type)
{
HandleScope scope;
Local<Value> key = args[0], value = args[1];
if (key->IsUndefined() || key->IsNull()) {
return Undefined();
}
// Remove property if value is set to null or undefined.
if (value->IsUndefined() || value->IsNull()) {
settings.remove(QString::fromUtf8(*String::Utf8Value(key)));
return Undefined();
}
// Serialize the property value to JSON.
Local<String> json = stringify(convertType(type, value));
// Update the application settings with the new property value.
settings.setValue(QString::fromUtf8(*String::Utf8Value(key)),
QString::fromUtf8(*String::Utf8Value(json)));
return Undefined();
}
示例10: NanObjectWrapHandle
Image::~Image() {
Local<Value> internalField = NanObjectWrapHandle(this)->GetInternalField(0);
if (internalField->IsNull()) return;
FIBITMAP *dib = static_cast<FIBITMAP*>(Local<External>::Cast(internalField)->Value());
FreeImage_Unload(dib);
}
示例11: setKeysInOp
void setKeysInOp(Handle<Object> spec, Operation & op) {
HandleScope scope;
Local<Value> v;
Local<Object> o;
v = spec->Get(HELPER_KEY_BUFFER);
if(! v->IsNull()) {
o = v->ToObject();
op.key_buffer = V8BINDER_UNWRAP_BUFFER(o);
}
v = spec->Get(HELPER_KEY_RECORD);
if(! v->IsNull()) {
o = v->ToObject();
op.key_record = unwrapPointer<const Record *>(o);
}
}
示例12: JSResult
long NativeWindow::JSResult(){
Local<Value> result = v8handle_->Get(String::NewSymbol("result"));
if (result->IsUndefined() || result->IsNull()) {
return 0;
} else {
v8handle_->Set(String::NewSymbol("result"), Undefined());
return result->Int32Value();
}
}
示例13:
bool V8Value::hasProperty(std::string propertyName)
{
HandleScope handleScope;
Local<Object> obj = value->ToObject();
Local<Value> val = obj->Get(String::New(propertyName.c_str()));
return !(val->IsNull() || val->IsUndefined()); // These are not 'true' values, that we can return in e.g. getPropertyString
// (we can't return 'Null' there - so this is for both undefined and null)
}
示例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();
}
示例15: Undefined
Handle<Value> MSRect::Project(const Arguments &args) {
MSRect *rect = ObjectWrap::Unwrap<MSRect>(args.This());
Local<Object> obj;
MSProjection *projIn;
MSProjection *projOut;
if (args.Length() != 2) {
THROW_ERROR(Error, "projecting a point requires two projection arguments");
}
if (!args[0]->IsObject()) {
THROW_ERROR(TypeError, "first argument to project must be Projection object");
}
obj = args[0]->ToObject();
if (obj->IsNull() || obj->IsUndefined() || !MSProjection::constructor->HasInstance(obj)) {
THROW_ERROR(TypeError, "first argument to project must be Projection object");
}
projIn = ObjectWrap::Unwrap<MSProjection>(obj);
if (!args[1]->IsObject()) {
THROW_ERROR(TypeError, "second argument to project must be Projection object");
}
obj = args[1]->ToObject();
if (obj->IsNull() || obj->IsUndefined() || !MSProjection::constructor->HasInstance(obj)) {
THROW_ERROR(TypeError, "first argument to project must be Projection object");
}
projOut = ObjectWrap::Unwrap<MSProjection>(obj);
msProjectRect(projIn->this_, projOut->this_, rect->this_);
return Undefined();
}