Re: S.O.L.I.D. in UnrealScript
Posted: Thu Mar 29, 2018 6:01 pm
At C++ level, interfaces are not-so-simply a variation of multiple inheritance (single can be the case too), where you attach a new virtual function table.
Example at native level in Unreal Engine:
This is the native definition of Player:
The unrealscript version is supposed to mirror the native version variable-by-variable, otherwise the structs end up having different sizes.
You can see that the UScript version has two additional vars: vfOut, vfExec.
Those are the virtual function table pointers for FOutputDevice and FExec classes, which in this case can be considered 'interfaces'.
Example at native level in Unreal Engine:
Code: Select all
class Player extends Object
native noexport;
var native const int vfOut;
var native const int vfExec;
// The actor this player controls.
var transient const playerpawn Actor;
var transient const console Console;
//etc...
Code: Select all
class ENGINE_API UPlayer : public UObject, public FOutputDevice, public FExec
{
DECLARE_ABSTRACT_CLASS(UPlayer,UObject,CLASS_Transient|CLASS_Config,Engine)
// Objects.
APlayerPawn* Actor; // O=48
UConsole* Console;
//Etc...
You can see that the UScript version has two additional vars: vfOut, vfExec.
Those are the virtual function table pointers for FOutputDevice and FExec classes, which in this case can be considered 'interfaces'.