Innerfuse Pascal Script
Back to Libraries

ifpsclass.html

types TIFPSClassWrapper = class
This class contains the declarations for individual classes.

constructor Create(Classes: TIFPSClasses; Cl: TClass; InheritsFrom: TIFPSClassWrapper);
Create an instance of the TIFPSClassWrapper. You never have to do this. Use TIFPSClasses.AddClass function instead.

property Classes: TIFPSClasses read FClasses;
Contains the TIFPSClasses this class is linked to.

property TheClass: TClass read FCl;
Contains the current class type

function AddFunction(Ptr: Pointer; const Decl: string): Boolean;
Add a function declaration to the function list. Decl should contain the full function declaration. If the function is virtual, it must be declared in that class.

function AddProperty(const Name, FType: string): Boolean;
Add a property declaration to the class.

property TheClassName: string read FClassName;
Contains the class name of the class. This is always equal to real class name, except when it's TObject. TObject will be calling DelphiTObject.

property ClassNameHash: Cardinal read FClassNameHash;
Contains the class name hash. This is needed for internal processing.


TIFPSClasses = class
This class maintains a list of all individual classes.

constructor Create;
Creates an instance of TIFPSClassses.

function FindClass(const Name: string): TIFPSClassWrapper;
Find a class in the classes list.

function AddClass(FClass: TClass; InheritsFrom: TIFPSClassWrapper): TIFPSClassWrapper;
Registers a new class in the classes list. FClass should be the real class. InheritsFrom should be the TIFPSClassWrapper that this class inherits from.


Functions:
procedure RegisterEClasses(ScriptEngine: TIFPasScript; FCl: TIFPSClasses);
Register all classes that are registered with TIFPSClasses.

function AddClassToScriptEngine(ScriptEngine: TIfPasScript; FClass: TObject; const ClassName, VarName: string): Boolean;
Add a class variable to the script engine. FClass should be the Object the class points to. ClassName should be the class the variable should be and varname should be the name of the new variable.

Using the classes library
Create a variable of type TIFPSClasses.
Use the stdimport unit and register at least TObject (SIRegisterTObject).

To add your own classes use TIFPSClasses.AddClass function.

var
   MyClasses: TIFPSClasses;
initialization
  ...
  MyClasses := TIFPSClasses.Create;
  
  with MyClasses.AddClass(TMyClass, MyClasses.FindClass('DelphiTObject')) do
  begin
    AddFunction(@TMyClasses.Test, 'procedure test(s: string)');
  end;
  ...
finalization
  ...
  MyClasses.Free;
  ...
end.

Copyright (c) 2001 by Carlo Kok
last update: 24-11-01