Implement Static Function Pointers

This commit is contained in:
Ricardo Luís Vaz Silva 2023-02-10 09:44:32 -03:00 committed by Christoph Oelckers
commit e3704605d8
23 changed files with 876 additions and 51 deletions

View file

@ -1348,3 +1348,35 @@ DEFINE_ACTION_FUNCTION_NATIVE(_QuatStruct, Inverse, QuatInverse)
QuatInverse(self->X, self->Y, self->Z, self->W, &quat);
ACTION_RETURN_QUAT(quat);
}
PFunction * FindFunctionPointer(PClass * cls, int fn_name)
{
auto fn = dyn_cast<PFunction>(cls->FindSymbol(ENamedName(fn_name), true));
return (fn && fn->GetImplicitArgs() == 0) ? fn : nullptr;
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, FindFunction, FindFunctionPointer)
{
PARAM_PROLOGUE;
PARAM_CLASS(cls, DObject);
PARAM_NAME(fn);
ACTION_RETURN_POINTER(FindFunctionPointer(cls, fn.GetIndex()));
}
/*
PFunction * FindMethodPointer(PClass * cls, int fn_name)
{
auto fn = dyn_cast<PFunction>(cls->FindSymbol(ENamedName(fn_name), true));
return (fn && fn->GetImplicitArgs() == 1) ? fn : nullptr;
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, FindMethod, FindMethodPointer)
{
PARAM_PROLOGUE;
PARAM_CLASS(cls, DObject);
PARAM_NAME(fn);
ACTION_RETURN_POINTER(FindMethodPointer(cls, fn.GetIndex()));
}
*/