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


C++ MethodBind::get_argument_count方法代码示例

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


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

示例1: get_api_hash

uint64_t ClassDB::get_api_hash(APIType p_api) {

	OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED

	uint64_t hash = hash_djb2_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG));

	List<StringName> names;

	const StringName *k = NULL;

	while ((k = classes.next(k))) {

		names.push_back(*k);
	}
	//must be alphabetically sorted for hash to compute
	names.sort_custom<StringName::AlphCompare>();

	for (List<StringName>::Element *E = names.front(); E; E = E->next()) {

		ClassInfo *t = classes.getptr(E->get());
		ERR_FAIL_COND_V(!t, 0);
		if (t->api != p_api || !t->exposed)
			continue;
		hash = hash_djb2_one_64(t->name.hash(), hash);
		hash = hash_djb2_one_64(t->inherits.hash(), hash);

		{ //methods

			List<StringName> snames;

			k = NULL;

			while ((k = t->method_map.next(k))) {

				snames.push_back(*k);
			}

			snames.sort_custom<StringName::AlphCompare>();

			for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {

				MethodBind *mb = t->method_map[F->get()];
				hash = hash_djb2_one_64(mb->get_name().hash(), hash);
				hash = hash_djb2_one_64(mb->get_argument_count(), hash);
				hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return

				for (int i = 0; i < mb->get_argument_count(); i++) {
					const PropertyInfo info = mb->get_argument_info(i);
					hash = hash_djb2_one_64(info.type, hash);
					hash = hash_djb2_one_64(info.name.hash(), hash);
					hash = hash_djb2_one_64(info.hint, hash);
					hash = hash_djb2_one_64(info.hint_string.hash(), hash);
				}

				hash = hash_djb2_one_64(mb->get_default_argument_count(), hash);

				for (int i = 0; i < mb->get_default_argument_count(); i++) {
					//hash should not change, i hope for tis
					Variant da = mb->get_default_argument(i);
					hash = hash_djb2_one_64(da.hash(), hash);
				}

				hash = hash_djb2_one_64(mb->get_hint_flags(), hash);
			}
		}

		{ //constants

			List<StringName> snames;

			k = NULL;

			while ((k = t->constant_map.next(k))) {

				snames.push_back(*k);
			}

			snames.sort_custom<StringName::AlphCompare>();

			for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {

				hash = hash_djb2_one_64(F->get().hash(), hash);
				hash = hash_djb2_one_64(t->constant_map[F->get()], hash);
			}
		}

		{ //signals

			List<StringName> snames;

			k = NULL;

			while ((k = t->signal_map.next(k))) {

				snames.push_back(*k);
			}

			snames.sort_custom<StringName::AlphCompare>();

//.........这里部分代码省略.........
开发者ID:KellyThomas,项目名称:godot,代码行数:101,代码来源:class_db.cpp

示例2: get_method_list

void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) {

	OBJTYPE_RLOCK;

	ClassInfo *type = classes.getptr(p_class);

	while (type) {

		if (type->disabled) {

			if (p_no_inheritance)
				break;

			type = type->inherits_ptr;
			continue;
		}

#ifdef DEBUG_METHODS_ENABLED

		for (List<MethodInfo>::Element *E = type->virtual_methods.front(); E; E = E->next()) {

			p_methods->push_back(E->get());
		}

		for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) {

			MethodBind *method = type->method_map.get(E->get());
			MethodInfo minfo;
			minfo.name = E->get();
			minfo.id = method->get_method_id();

			if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name))
				continue;

			for (int i = 0; i < method->get_argument_count(); i++) {

				//Variant::Type t=method->get_argument_type(i);

				minfo.arguments.push_back(method->get_argument_info(i));
			}

			minfo.return_val = method->get_return_info();
			minfo.flags = method->get_hint_flags();

			for (int i = 0; i < method->get_argument_count(); i++) {
				if (method->has_default_argument(i))
					minfo.default_arguments.push_back(method->get_default_argument(i));
			}

			p_methods->push_back(minfo);
		}

#else

		const StringName *K = NULL;

		while ((K = type->method_map.next(K))) {

			MethodBind *m = type->method_map[*K];
			MethodInfo mi;
			mi.name = m->get_name();
			p_methods->push_back(mi);
		}

#endif

		if (p_no_inheritance)
			break;

		type = type->inherits_ptr;
	}
}
开发者ID:KellyThomas,项目名称:godot,代码行数:72,代码来源:class_db.cpp

示例3: _find_type_arguments

static void _find_type_arguments(const GDParser::Node*p_node,int p_line,const StringName& p_method,const GDCompletionIdentifier& id, int p_argidx, Set<String>& result, String& arghint) {


	if (id.type==Variant::OBJECT && id.obj_type!=StringName()) {


		MethodBind *m = ObjectTypeDB::get_method(id.obj_type,p_method);
		if (!m)
			return;

		if (p_method.operator String()=="connect") {


			if (p_argidx==0) {
				List<MethodInfo> sigs;
				ObjectTypeDB::get_signal_list(id.obj_type,&sigs);
				for (List<MethodInfo>::Element *E=sigs.front();E;E=E->next()) {
					result.insert("\""+E->get().name+"\"");
				}
			}
			/*if (p_argidx==2) {

				ERR_FAIL_COND(p_node->type!=GDParser::Node::TYPE_OPERATOR);
				const GDParser::OperatorNode *op=static_cast<const GDParser::OperatorNode *>(p_node);
				if (op->arguments.size()>)

			}*/
		} else {

			Object *obj=id.value;
			if (obj) {
				List<String> options;
				obj->get_argument_options(p_method,p_argidx,&options);
				for(List<String>::Element *E=options.front();E;E=E->next()) {

					result.insert(E->get());
				}
			}

		}

		arghint = _get_visual_datatype(m->get_argument_info(-1),false)+" "+p_method.operator String()+String("(");

		for(int i=0;i<m->get_argument_count();i++) {
			if (i>0)
				arghint+=", ";
			else
				arghint+=" ";

			if (i==p_argidx) {
				arghint+=String::chr(0xFFFF);
			}
			String n = m->get_argument_info(i).name;
			int dp = n.find(":");
			if (dp!=-1)
				n=n.substr(0,dp);
			arghint+=_get_visual_datatype(m->get_argument_info(i))+" "+n;
			int deffrom = m->get_argument_count()-m->get_default_argument_count();


			if (i>=deffrom) {
				int defidx = i-deffrom;

				if (defidx>=0 && defidx<m->get_default_argument_count()) {
					Variant v= m->get_default_argument(i);
					arghint+="="+v.get_construct_string();
				}
			}

			if (i==p_argidx) {
				arghint+=String::chr(0xFFFF);
			}

		}
		if (m->get_argument_count()>0)
			arghint+=" ";


		arghint+=")";

	}
}
开发者ID:ForsakenNGS,项目名称:godot,代码行数:82,代码来源:gd_editor.cpp


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