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


C++ SharedKObject::isNull方法代码示例

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


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

示例1: _SetContextMenu

	void UIBinding::_SetContextMenu(const ValueList& args, SharedValue result)
	{
		args.VerifyException("setContextMenu", "o|0");
		SharedKObject argObj = args.GetObject(0, NULL);
		AutoMenu menu = NULL;

		if (!argObj.isNull())
		{
			menu = argObj.cast<Menu>();
		}
		this->SetContextMenu(menu);
	}
开发者ID:leongersing,项目名称:titanium_desktop,代码行数:12,代码来源:ui_binding.cpp

示例2: RubyKObjectMethodMissing

	// A :method_missing method for finding KObject properties in Ruby
	static VALUE RubyKObjectMethodMissing(int argc, VALUE *argv, VALUE self)
	{
		SharedValue* dval = NULL;
		Data_Get_Struct(self, SharedValue, dval);
		SharedKObject object = (*dval)->ToObject();

		// TODO: We should raise an exception instead
		if (object.isNull())
			return Qnil;

		// This is the same error that ruby throws
		if (argc == 0 || !SYMBOL_P(argv[0]))
		{
			rb_raise(rb_eArgError, "no id given");
		}

		// We need to determine the method that was invoked:
		// store the method name and arguments in separate variables
		VALUE r_name, args;
		rb_scan_args(argc, argv, "1*", &r_name, &args);
		const char* name = rb_id2name(SYM2ID(r_name));

		// Check if this is an assignment
		SharedValue value = object->Get(name);
		if (name[strlen(name) - 1] == '=' && argc > 1)
		{
			char* mod_name = strdup(name);
			mod_name[strlen(mod_name) - 1] = '\0';
			value = RubyUtils::ToKrollValue(argv[1]);
			object->Set(mod_name, value);
			free(mod_name);
			return argv[1];
		}
		else if (value->IsUndefined()) // raise a method missing error
		{
			VALUE selfString = rb_obj_as_string(self);
			rb_raise(rb_eNoMethodError, "undefined method `%s' for %s",
				name, RubyUtils::ToString(selfString));
		}
		else if (value->IsMethod()) // actually call a method
		{
			return RubyUtils::GenericKMethodCall(value->ToMethod(), args);
		}
		else // Plain old access
		{
			return RubyUtils::ToRubyValue(value);
		}
	}
开发者ID:maccman,项目名称:kroll,代码行数:49,代码来源:ruby_utils.cpp

示例3: _SetMenu

	void UIBinding::_SetMenu(const ValueList& args, SharedValue result)
	{
		args.VerifyException("setMenu", "o|0");
		SharedKObject argObj = args.GetObject(0, NULL);
		AutoMenu menu = NULL;

		if (!argObj.isNull())
		{
			menu = argObj.cast<Menu>();
		}

		this->SetMenu(menu); // platform-specific impl

		// Notify all windows that the app menu has changed.
		std::vector<AutoUserWindow>::iterator i = openWindows.begin();
		while (i != openWindows.end()) {
			(*i++)->AppMenuChanged();
		}
	}
开发者ID:leongersing,项目名称:titanium_desktop,代码行数:19,代码来源:ui_binding.cpp

示例4: EvaluateUserScript

	void MonkeyBinding::EvaluateUserScript(
		SharedKObject event, std::string& url,
		SharedKObject windowObject, std::string& scriptSource)
	{
		static Logger *logger = Logger::Get("Monkey");
		// I got a castle in brooklyn, that's where i dwell
		// Word, brother.

		if (!windowObject->Get("eval")->IsMethod())
		{
			logger->Error("Found a window object without an "
				"eval function (%s) -- aborting", url.c_str());
			return;
		}

		SharedKObject target = event->GetObject("target");
		if (!windowObject->Get(GLOBAL_NS_VARNAME)->IsObject() &&
			!target.isNull() && target->Get("insertAPI")->IsMethod())
		{
			logger->Info("Forcing Titanium API into: %s\n", url.c_str());
			target->CallNS("insertAPI", Value::NewObject(windowObject));
		}

		SharedKMethod evalFunction = windowObject->GetMethod("eval");
		logger->Info("Loading userscript for %s\n", url.c_str());
		try
		{
			evalFunction->Call(Value::NewString(scriptSource));
		}
		catch (ValueException &ex)
		{
			SharedString ss = ex.DisplayString();
			int line = -1;
			if (ex.GetValue()->IsObject() &&
				ex.GetValue()->ToObject()->Get("line")->IsNumber())
			{
				line = ex.GetValue()->ToObject()->Get("line")->ToInt();
			}
			logger->Error(
				"Exception generated evaluating user script for %s "
				"(line %i): %s", url.c_str(), line, ss->c_str());
		}
	}
开发者ID:jonnymind,项目名称:titanium_desktop,代码行数:43,代码来源:monkey_binding.cpp

示例5: RubyKObjectMethod

	// A :method method for pulling methods off of KObjects in Ruby
	static VALUE RubyKObjectMethod(int argc, VALUE *argv, VALUE self)
	{
		SharedValue* dval = NULL;
		Data_Get_Struct(self, SharedValue, dval);
		SharedKObject object = (*dval)->ToObject();

		// TODO: We should raise an exception instead
		if (object.isNull())
			return Qnil;
		if (argc < 1)
			return Qnil;

		VALUE meth_name = argv[0];
		const char* name = rb_id2name(SYM2ID(meth_name));
		SharedValue v = object->Get(name);
		if (v->IsMethod())
		{
			return RubyUtils::ToRubyValue(v);
		}
		else
		{
			return Qnil;
		}
	}
开发者ID:maccman,项目名称:kroll,代码行数:25,代码来源:ruby_utils.cpp

示例6: FireEvent

void UserWindow::FireEvent(UserWindowEvent event_type, SharedKObject event)
{
	std::string name;
	switch (event_type)
	{
		case FOCUSED:
		{
			name = "focused";
			break;
		}
		case UNFOCUSED:
		{
			name = "unfocused";
			break;
		}
		case OPEN:
		{
			name = "open";
			break;
		}
		case OPENED:
		{
			name = "opened";
			break;
		}
		case CLOSE:
		{
			name = "close";
			break;
		}
		case CLOSED:
		{
			name = "closed";
			break;
		}
		case HIDDEN:
		{
			name = "hidden";
			break;
		}
		case SHOWN:
		{
			name = "shown";
			break;
		}
		case FULLSCREENED:
		{
			name = "fullscreened";
			break;
		}
		case UNFULLSCREENED:
		{
			name = "unfullscreened";
			break;
		}
		case MAXIMIZED:
		{
			name = "maximized";
			break;
		}
		case MINIMIZED:
		{
			name = "minimized";
			break;
		}
		case RESIZED:
		{
			name = "resized";
			break;
		}
		case MOVED:
		{
			name = "moved";
			break;
		}
		case INIT:
		{
			name = "page.init";
			break;
		}
		case LOAD:
		{
			name = "page.load";
			break;
		}
		case CREATE:
		{
			name = "create";
			break;
		}
	}

	std::string en = std::string("ti.UI.window.") + name;
	if (event.isNull())
	{
		event = new StaticBoundObject();
	}

	event->Set("window", Value::NewObject(this->shared_this));
	this->api->Call(en.c_str(), Value::NewObject(event));
//.........这里部分代码省略.........
开发者ID:pctj101,项目名称:titanium,代码行数:101,代码来源:user_window.cpp


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