Beispiel #1
0
			static void CollectTypeDescriptors(WfCustomType* td, SortedList<ITypeDescriptor*>& tds)
			{
				vint baseCount = td->GetBaseTypeDescriptorCount();
				for (vint i = 0; i < baseCount; i++)
				{
					auto baseType = td->GetBaseTypeDescriptor(i);
					CollectTypeDescriptors(baseType, tds);
				}

				vint methodGroupCount = td->GetMethodGroupCount();
				for (vint i = 0; i < methodGroupCount; i++)
				{
					auto group = td->GetMethodGroup(i);
					vint methodCount = group->GetMethodCount();
					for (vint j = 0; j < methodCount; j++)
					{
						auto method = group->GetMethod(j);
						CollectTypeDescriptors(method, tds);
					}
				}

				vint propertyCount = td->GetPropertyCount();
				for (vint i = 0; i < propertyCount; i++)
				{
					CollectTypeDescriptors(td->GetProperty(i), tds);
				}

				vint eventCount = td->GetEventCount();
				for (vint i = 0; i < eventCount; i++)
				{
					CollectTypeDescriptors(td->GetEvent(i), tds);
				}
			}
Beispiel #2
0
				static void IO(Reader& reader, IMethodInfo*& value)
				{
					ITypeDescriptor* type = 0;
					WString name;
					List<WString> parameters;
					reader << type << name << parameters;
					auto group =
						name == L"#ctor" ? type->GetConstructorGroup() :
						type->GetMethodGroupByName(name, false);
					CHECK_ERROR(group, L"Failed to load method.");

					value = 0;
					vint count = group->GetMethodCount();
					for (vint i = 0; i < count; i++)
					{
						auto method = group->GetMethod(i);
						if (method->GetParameterCount() == parameters.Count())
						{
							bool found = true;
							for (vint j = 0; j < parameters.Count(); j++)
							{
								if (method->GetParameter(j)->GetName() != parameters[j])
								{
									found = false;
									break;
								}
							}

							if (found)
							{
								CHECK_ERROR(!value, L"Failed to load method.");
								value = method;
							}
						}
					}
					CHECK_ERROR(value, L"Failed to load method.");
				}
Beispiel #3
0
Variant DynamicObject::pget_MethodCount(void)
{
    return anytovariant(GetMethodCount());
}
Beispiel #4
0
void ScriptEngine::generateReference()
{
	if (!m_engine)
		return;

	std::ofstream out("AngelScript reference.txt");

	out << "*** Globals ***" << std::endl << std::endl;
	int nb = m_engine->GetGlobalFunctionCount();
	for (int i = 0; i < nb; ++i)
	{
		auto func = m_engine->GetGlobalFunctionByIndex(i);
		out << "\t" << func->GetDeclaration(true, false, true) << std::endl;
	}

	out << std::endl << "*** Types ***" << std::endl << std::endl;
	nb = m_engine->GetObjectTypeCount();
	for (int i = 0; i < nb; ++i)
	{
		auto info = m_engine->GetObjectTypeByIndex(i);
		out << " * " << info->GetName() << std::endl;

		int nb2 = info->GetPropertyCount();
		for (int j = 0; j < nb2; ++j)
		{
			const char* name;
			int typeId;
			bool isPrivate, isProtected, isReference;
			auto prop = info->GetProperty(j, &name, &typeId, &isPrivate, &isProtected, nullptr, &isReference);
			out << "\t";

			if (isProtected)
				out << "protected ";
			if (isPrivate)
				out << "private ";
			out << m_engine->GetTypeDeclaration(typeId);
			if (isReference)
				out << "&";
			out << " ";
			out << name << std::endl;
		}
		if (nb2 != 0)
			out << std::endl;

		nb2 = info->GetBehaviourCount();
		bool hasBehaviour = false;
		for (int j = 0; j < nb2; ++j)
		{
			asEBehaviours behaviour;
			auto func = info->GetBehaviourByIndex(j, &behaviour);
			if (behaviour == asBEHAVE_CONSTRUCT || behaviour == asBEHAVE_DESTRUCT)
			{
				hasBehaviour = true;
				out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
			}
		}
		if (hasBehaviour)
			out << std::endl;

		nb2 = info->GetFactoryCount();
		for (int j = 0; j < nb2; ++j)
		{
			auto func = info->GetFactoryByIndex(j);
			out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
		}
		if (nb2 != 0)
			out << std::endl;

		nb2 = info->GetMethodCount();
		for (int j = 0; j < nb2; ++j)
		{
			auto func = info->GetMethodByIndex(j);
			out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
		}

		out << std::endl;
	}
}