Exemplo n.º 1
0
void writeMethodReflectionCode(const CppMethod * cppMethod, BuilderWriter * writer, CodeBlock * codeBlock,
										   const std::string & methodName)
{
	size_t arity = cppMethod->getArity();
	bool hasDefaultValue = (arity > 0 && cppMethod->paramHasDefaultValue(arity - 1));

	std::string s;

	if(cppMethod->isOverloaded()) {
		s = Poco::format("%s(\"%s\", (%s)(&%s%s))",
			writer->getReflectionAction("_method"),
			methodName,
			cppMethod->getTextOfPointeredType(),
			getReflectionScope(cppMethod),
			methodName,
			string(hasDefaultValue ? "" : ";")
		);
	}
	else {
		s = Poco::format("%s(\"%s\", &%s%s)",
			writer->getReflectionAction("_method"),
			methodName,
			getReflectionScope(cppMethod),
			methodName,
			string(hasDefaultValue ? "" : ";")
		);
	}
	codeBlock->appendLine(s);

	if(hasDefaultValue) {
		writeMethodDefaultParameterReflection(cppMethod, codeBlock->appendBlock(cbsIndent));
		codeBlock->appendLine(";");
	}
}
Exemplo n.º 2
0
void writeMethodReflectionCode(const CppMethod * cppMethod, BuilderWriter * writer, CodeBlock * codeBlock,
										   const string & methodName)
{
	size_t arity = cppMethod->getArity();
	bool hasDefaultValue = (arity > 0 && cppMethod->paramHasDefaultValue(arity - 1));

	string s, t;

	s = Poco::format("%s(\"%s\"",
		writer->getReflectionAction("_method"),
		methodName);
	t = Poco::format("&%s%s)%s",
		getReflectionScope(cppMethod, false),
		methodName,
		getInvokablePolicyText(cppMethod, true)
	);
	if(cppMethod->isOverloaded()) {
		if(cppMethod->isArityUnique()) {
			s = Poco::format("%s, cpgf::selectFunctionByArity%d(%s)", s, (int)(cppMethod->getArity()), t);
		}
		else {
			if(cppMethod->hasTemplateDependentParam()) {
				getLogger().warn(
					Poco::format("Function %s is overloaded and has template dependent argument, meta data can't be generated.\n",
					cppMethod->getTextOfPointeredType(true))
				);
//				return;
			}
			s = Poco::format("%s, (%s)(%s)", s, cppMethod->getTextOfPointeredType(true), t);
		}
	}
	else {
		s = Poco::format("%s, %s", s, t);
	}

	if(! hasDefaultValue) {
		s.append(";");
	}
	codeBlock->appendLine(s);

	if(hasDefaultValue) {
		writeMethodDefaultParameterReflection(cppMethod, codeBlock->appendBlock(cbsIndent));
		codeBlock->appendLine(";");
	}
}