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


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

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


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

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

示例2: RectJsToC


//.........这里部分代码省略.........
	//		],
	//		"return":{
	//			"type":"void",
	//			"text":"函数没有返回值。"
	//		}
	//	},
	//	{
	//		"type":"function",
	//		"name":"setSize",
	//		"text":"设置矩形的大小,这个函数通过调整 right 和 bottom 来调整矩形的大小。",
	//		"param":[
	//			{
	//				"type":"integer",
	//				"name":"[width]",
	//				"text":"矩形新的宽度,如果此值为 undefined,矩形的宽度不变。"
	//			},
	//			{
	//				"type":"integer",
	//				"name":"[height]",
	//				"text":"矩形新的高度,如果此值为 undefined,矩形的高度不变。"
	//			}
	//		],
	//		"return":{
	//			"type":"void",
	//			"text":"这个函数没有返回值。"
	//		}
	//	},
	//	{
	//		"type":"function",
	//		"name":"getSize",
	//		"text":"获取矩形的大小。",
	//		"param":[
	//		],
	//		"return":{
	//			"type":"Size",
	//			"text":"返回一个 Size 对象。"
	//		}
	//	},
	//	{
	//		"type":"function",
	//		"name":"positive",
	//		"text":"通过交换 left 和 right 或者 top 和 bottom 的值来保证,left 总是小于等于 right,top 总是小于等于 bottom。",
	//		"param":[
	//		],
	//		"return":{
	//			"type":"void",
	//			"text":"这个函数没有返回值。"
	//		}
	//	},
	//	{
	//		"type":"function",
	//		"name":"setValue(left,top,right,bottom)",
	//		"text":"设置矩形的 4 个属性,这个函数直接设置,不做任何检测。",
	//		"param":[
	//			{
	//				"type":"integer",
	//				"name":"left",
	//				"text":"要设置的 left 属性值。"
	//			},
	//			{
	//				"type":"integer",
	//				"name":"top",
	//				"text":"要设置的 top 属性值。"
	//			},
	//			{
	//				"type":"integer",
	//				"name":"right",
	//				"text":"要设置的 right 属性值。"
	//			},
	//			{
	//				"type":"integer",
	//				"name":"bottom",
	//				"text":"要设置的 bottom 属性值。"
	//			}
	//		],
	//		"return":{
	//			"type":"void",
	//			"text":"这个函数没有返回值。"
	//		}
	//	}
	//	]
	//}//*
	bool RectJsToC(v8::Handle<Value> value,cs::Rect* r){
		HandleScope store;
		if(!value->IsObject()) return false;
		Local<Object> vObj = value->ToObject();
		Local<Value> vl = vObj->Get(String::New("left"));
		if(vl->IsUndefined()) return false;
		Local<Value> vt = vObj->Get(String::New("top"));
		if(vt->IsUndefined()) return false;
		Local<Value> vr = vObj->Get(String::New("right"));
		if(vr->IsUndefined()) return false;
		Local<Value> vb = vObj->Get(String::New("bottom"));
		if(vb->IsUndefined()) return false;
		r->left = vl->Int32Value();
		r->top = vt->Int32Value();
		r->right = vr->Int32Value();
		r->bottom = vb->Int32Value();
		return true;
	}
开发者ID:pgmsoul,项目名称:GitLib,代码行数:101,代码来源:v8base.cpp

示例3:

Handle<Value> nj::ScriptEncapsulated::NewInstance(const Arguments& args)
{
   HandleScope scope;
   const unsigned argc = 1;
   Handle<v8::Value> argv[argc] = { args[0] };
   Local<Object> instance = constructor->NewInstance(argc,argv);

   if(instance.IsEmpty() || instance->IsUndefined()) return scope.Close(Undefined());
   return scope.Close(instance);
}
开发者ID:qooleot,项目名称:node-julia,代码行数:10,代码来源:ScriptEncapsulated-v10.cpp

示例4:

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)
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:10,代码来源:script_engine_v8.cpp

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

示例6: readJsFile

Handle<Value> TiRootObject::_require(void* userContext, TiObject* caller, const Arguments& args)
{
	HandleScope scope;
	Local<Object> globalObject = TitaniumRuntime::getContenxt()->Global();

	Handle<Value> nativeModule = TiModuleRegistry::GetModule(QString(*String::Utf8Value(args[0]->ToString())));
	if(!nativeModule->IsUndefined())
	{
		return scope.Close(nativeModule);
	}
	QString fileName = Ti::TiHelper::QStringFromValue(args[0]).append(".js");
	QString filePath = Ti::TiHelper::getAssetPath(fileName).prepend("app/native/");
	Local<Value> existingModule = globalObject->GetHiddenValue(Ti::TiHelper::ValueFromQString(fileName)->ToString());
	if(!existingModule.IsEmpty() && !existingModule->IsUndefined())
	{
		return scope.Close(existingModule);
	}

	QString js = readJsFile(filePath);
	if(js.isEmpty()) {
		ThrowException(String::New(
								QString("Module not found ").append(fileName).toLocal8Bit().constData()
						));
		return scope.Close(Undefined());
	}
	js.prepend("(function(){"
			"var __vars = {};"
			"__vars.exports = {};"
			"__vars.module = {exports:__vars.exports};"
			"var module = __vars.module;"
			"var exports = __vars.exports;");
	js.append("\nreturn __vars.module.exports;"
			"})();");


	Handle<Script> script = Script::Compile(Ti::TiHelper::ValueFromQString(js)->ToString() , Ti::TiHelper::ValueFromQString(fileName));
	TryCatch tryCatch;
	if (script.IsEmpty())
	{
    	Ti::TiErrorScreen::ShowWithTryCatch(tryCatch);
		return scope.Close(Undefined());
	}
	Persistent<Value> result = Persistent<Value>::New(script->Run());
	result.MarkIndependent();
	if (result.IsEmpty())
	{
    	Ti::TiErrorScreen::ShowWithTryCatch(tryCatch);
		return scope.Close(Undefined());
	}
	globalObject->SetHiddenValue(Ti::TiHelper::ValueFromQString(fileName)->ToString(), result);
	return scope.Close(result);
}
开发者ID:pec1985,项目名称:titanium_mobile_blackberry,代码行数:52,代码来源:TiRootObject.cpp

示例7: 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();
}
开发者ID:MarkHauenstein,项目名称:node-mapserver,代码行数:38,代码来源:ms_rect.cpp

示例8: val

/*-----------------------------------------------------------------------------
 * Get the current logger instance (will be created if it doesn't exist)
 *
 * var logger = tervela.getLogger({loggerOptions});
 *
 * loggerOptions = {
 *     filename       : [log file name],                        (string, optional)
 *     tagname        : [tag for log messages in file],         (string, optional (default: "TVA"[pid]))
 * };
 */
Handle<Value> GetLogger(const Arguments& args)
{
  HandleScope scope;
  static Local<Value> _logger;
  static bool _isCreated = false;

  if (!_isCreated)
  {
    // Ready arguments
    char* filename = NULL;
    char* tagname = NULL;

    if (args.Length() >= 1)
    {
      PARAM_REQ_OBJECT(0, args);          // options
      Local<Object> options = Local<Object>::Cast(args[0]);
      std::vector<std::string> optionNames = cvv8::CastFromJS<std::vector<std::string> >(options->GetPropertyNames());
      for (size_t i = 0; i < optionNames.size(); i++)
      {
        char* optionName = (char*)(optionNames[i].c_str());
        Local<Value> optionValue = options->Get(String::NewSymbol(optionName));

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

        if (tva_str_casecmp(optionName, "filename") == 0)
        {
          String::AsciiValue val(optionValue->ToString());
          filename = strdup(*val);
        }
        else if (tva_str_casecmp(optionName, "tagname") == 0)
        {
          String::AsciiValue val(optionValue->ToString());
          tagname = strdup(*val);
        }
      }
    }

    _logger = Local<Value>::New(Logger::NewInstance(filename, tagname));
    _isCreated = true;

    if (filename) free(filename);
    if (tagname) free(tagname);
  }

  return scope.Close(_logger);
}
开发者ID:hgokhale,项目名称:tvanode,代码行数:59,代码来源:Tervela.cpp

示例9: srsSetter

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

	OGRSpatialReference *srs = NULL;
	if (SpatialReference::constructor->HasInstance(value)) {
		SpatialReference *srs_obj = ObjectWrap::Unwrap<SpatialReference>(value->ToObject());
		srs = srs_obj->get();
	} else if (!value->IsNull() && !value->IsUndefined()) {
		NODE_THROW("srs must be SpatialReference object");
		return;
	}

	geom->this_->assignSpatialReference(srs);
}
开发者ID:xkwangy,项目名称:node-gdal,代码行数:16,代码来源:gdal_geometry.cpp

示例10: ThrowException

Handle<Value> Image::setGrayScaleToAlpha(const Arguments& args)
{
    HandleScope scope;

    Image* im = ObjectWrap::Unwrap<Image>(args.This());
    if (args.Length() == 0) {
        im->this_->set_grayscale_to_alpha();
    } else {
        if (!args[0]->IsObject())
            return ThrowException(Exception::TypeError(
                                      String::New("optional second arg must be a mapnik.Color")));

        Local<Object> obj = args[0]->ToObject();

        if (obj->IsNull() || obj->IsUndefined() || !Color::constructor->HasInstance(obj))
            return ThrowException(Exception::TypeError(String::New("mapnik.Color expected as second arg")));

        Color * color = ObjectWrap::Unwrap<Color>(obj);

        mapnik::image_data_32 & data = im->this_->data();
        for (unsigned int y = 0; y < data.height(); ++y)
        {
            unsigned int* row_from = data.getRow(y);
            for (unsigned int x = 0; x < data.width(); ++x)
            {
                unsigned rgba = row_from[x];
                // TODO - big endian support
                unsigned r = rgba & 0xff;
                unsigned g = (rgba >> 8 ) & 0xff;
                unsigned b = (rgba >> 16) & 0xff;

                // magic numbers for grayscale
                unsigned a = (int)((r * .3) + (g * .59) + (b * .11));

                row_from[x] = (a << 24) |
                    (color->get()->blue() << 16) |
                    (color->get()->green() << 8) |
                    (color->get()->red()) ;
            }
        }
    }

    return Undefined();
}
开发者ID:tannewt,项目名称:node-mapnik,代码行数:44,代码来源:mapnik_image.cpp

示例11: filename

void V8Util::reportException(TryCatch &tryCatch, bool showLine)
{
	HandleScope scope;
	Handle<Message> message = tryCatch.Message();

	if (nameSymbol.IsEmpty()) {
		nameSymbol = SYMBOL_LITERAL("name");
		messageSymbol = SYMBOL_LITERAL("message");
	}

	if (showLine) {
		Handle<Message> message = tryCatch.Message();
		if (!message.IsEmpty()) {
			String::Utf8Value filename(message->GetScriptResourceName());
			String::Utf8Value msg(message->Get());
			int linenum = message->GetLineNumber();
			LOGE(EXC_TAG, "Exception occurred at %s:%i: %s", *filename, linenum, *msg);
		}
	}

	Local<Value> stackTrace = tryCatch.StackTrace();
	String::Utf8Value trace(tryCatch.StackTrace());

	if (trace.length() > 0 && !stackTrace->IsUndefined()) {
		LOGD(EXC_TAG, *trace);
	} else {
		Local<Value> exception = tryCatch.Exception();
		if (exception->IsObject()) {
			Handle<Object> exceptionObj = exception->ToObject();
			Handle<Value> message = exceptionObj->Get(messageSymbol);
			Handle<Value> name = exceptionObj->Get(nameSymbol);

			if (!message->IsUndefined() && !name->IsUndefined()) {
				String::Utf8Value nameValue(name);
				String::Utf8Value messageValue(message);
				LOGE(EXC_TAG, "%s: %s", *nameValue, *messageValue);
			}
		} else {
			String::Utf8Value error(exception);
			LOGE(EXC_TAG, *error);
		}
	}
}
开发者ID:1rp,项目名称:titanium_mobile,代码行数:43,代码来源:V8Util.cpp

示例12: set_prop

void Image::set_prop(Local<String> property,
                     Local<Value> value,
                     const AccessorInfo& info)
{
    HandleScope scope;
    Image* im = node::ObjectWrap::Unwrap<Image>(info.Holder());
    std::string a = TOSTR(property);
    if (a == "background") {
        if (!value->IsObject())
            ThrowException(Exception::TypeError(
                               String::New("mapnik.Color expected")));

        Local<Object> obj = value->ToObject();
        if (obj->IsNull() || obj->IsUndefined() || !Color::constructor->HasInstance(obj))
            ThrowException(Exception::TypeError(String::New("mapnik.Color expected")));
        Color *c = node::ObjectWrap::Unwrap<Color>(obj);
        im->get()->set_background(*c->get());
    }
}
开发者ID:calvinmetcalf,项目名称:node-mapnik,代码行数:19,代码来源:mapnik_image.cpp

示例13: runSync

Handle<Value> Engine::run(Arguments const& args)
{
    HandleScope scope;

    if (args.Length() == 1) {
        return runSync(args);
    }

    if (args.Length() < 1) {
        ThrowException(String::New("first argument must be a osrm.Query"));
    }

    if (!args[0]->IsObject()) {
        return ThrowException(String::New("first argument must be a osrm.Query object"));
    }

    Local<Object> obj = args[0]->ToObject();
    if (obj->IsNull() || obj->IsUndefined() || !Query::constructor->HasInstance(obj)) {
        ThrowException(Exception::TypeError(String::New("osrm.Query object expected for first argument")));
    }

    // 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")));
    }

    Query * query = ObjectWrap::Unwrap<Query>(obj);
    Engine * machine = ObjectWrap::Unwrap<Engine>(args.This());
    run_query_baton_t *closure = new run_query_baton_t();
    closure->request.data = closure;
    closure->machine = machine;
    closure->query = query;
    closure->error = false;
    closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
    uv_queue_work(uv_default_loop(), &closure->request, AsyncRun, (uv_after_work_cb)AfterRun);
    closure->machine->_ref();
    closure->query->_ref();
    return Undefined();
}
开发者ID:jfirebaugh,项目名称:node-OSRM,代码行数:41,代码来源:engine.hpp

示例14: getView

Ti::TiValue Ti::TiViewProxy::add(Ti::TiValue value)
{
	if(value.isProxy())
	{
		Ti::TiViewProxy *childProxy = static_cast<Ti::TiViewProxy*>(value.toProxy());
		childProxy->clearWeak();
		_childViewsProxies.append(childProxy);
		Ti::TiView* childView = childProxy->getView();
		Ti::TiView* thisView = getView();
		thisView->add(childView);
		childProxy->_parentProxy = this;
	}
	else
	{
        TiObject* addObj = TiObject::getTiObjectFromJsObject(value.toJSValue());
        TiUIBase* uiObj = (TiUIBase*) addObj;
        NativeObject* childNO = uiObj->getNativeObject();
        getView()->addOldObject(childNO);

       Local<Value> children = _jsObject->Get(String::New("children"));
       Local<Array> array;
       if(children.IsEmpty() || children->IsUndefined())
       {
    	   array = Array::New();
    	   _jsObject->Set(String::New("children"), array);
       }
       else
       {
    	   array = Local<Array>::Cast(children);
       }
       array->Set(array->Length(), value.toJSValue());
       childNO->release();

	}

	Ti::TiValue val;
	val.setUndefined();
	return val;
}
开发者ID:Buder,项目名称:titanium_mobile_blackberry,代码行数:39,代码来源:Ti_ViewProxy.cpp

示例15: ThrowException

Handle<Value> Engine::runSync(Arguments const& args)
{
    HandleScope scope;

    if (args.Length() < 1) {
        ThrowException(Exception::TypeError(String::New("first argument must be a osrm.Query")));
    }

    if (!args[0]->IsObject()) {
        return ThrowException(Exception::TypeError(String::New("first argument must be a osrm.Query object")));
    }

    Local<Object> obj = args[0]->ToObject();
    if (obj->IsNull() || obj->IsUndefined() || !Query::constructor->HasInstance(obj)) {
        return ThrowException(Exception::TypeError(String::New("osrm.Query object expected for first argument")));
    }
    Query *query = ObjectWrap::Unwrap<Query>(obj);
    Engine* machine = ObjectWrap::Unwrap<Engine>(args.This());
    http::Reply osrm_reply;
    machine->this_->RunQuery(*query->get(), osrm_reply);
    return scope.Close(String::New(osrm_reply.content.c_str()));
}
开发者ID:jfirebaugh,项目名称:node-OSRM,代码行数:22,代码来源:engine.hpp


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