本文整理汇总了C++中DynamicArray::get_length方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::get_length方法的具体用法?C++ DynamicArray::get_length怎么用?C++ DynamicArray::get_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::get_length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallMethod
/** Call a method of a VCL object or a constructor of a VCL type.
* The methods are considered in order and the first that matches the arguments
* will be used.
* \param Type: The type to construct if the method is a constructor; NULL otherwise.
* \param Instance: The VCL object of the method; NULL if it is a constructor
* \param Methods: The methods to consider
* \param Args: Arguments that will be passed to the method.
* \return The result of the called method or the newly constructed object if it
* is a constructor.
*/
TValue CallMethod(TRttiType *Type, TObject *Instance, DynamicArray<TRttiMethod*> &Methods, PyObject *Args)
{
unsigned MethodCount = Methods.get_length();
TRttiType *Parent = Methods[0]->Parent;
for(unsigned I = 0; I < MethodCount; I++)
{
TRttiMethod *Method = Methods[I];
if(Instance == NULL) //If looking for constructor
if(Method->Parent != Parent)
break; //Only look for constructors defined in the last class with constructors
DynamicArray<TRttiParameter*> ParameterTypes = Method->GetParameters();
std::vector<TValue> Parameters;
int ParamCount = PyTuple_Size(Args);
if(ParamCount != ParameterTypes.Length)
if(MethodCount == 1)
throw EPyVclError(Method->Name + "() takes exactly " + ParameterTypes.get_length() + " arguments (" + ParamCount + " given)");
else
continue;
try
{
TupleToValues(Args, Parameters, ParameterTypes);
}
catch(Exception &E)
{
if(MethodCount == 1)
throw;
continue;
}
if(Method->IsConstructor)
{
if(Type == NULL)
throw EPyVclError("Cannot call constructor");
return Method->Invoke(Type->AsInstance->MetaclassType, Parameters.size() == 0 ? NULL : &Parameters[0], Parameters.size()-1);
}
else if(Method->IsClassMethod || Method->IsStatic)
return Method->Invoke(Instance->ClassType(), Parameters.size() == 0 ? NULL : &Parameters[0], Parameters.size()-1);
else
return Method->Invoke(Instance, Parameters.size() == 0 ? NULL : &Parameters[0], Parameters.size()-1);
}
throw EPyVclError("No suitable overload found for the function " + Methods[0]->Name);
}