SRL Archive - FAQ

How does Simba export Pascal classes?


Brandon

2014-01-20 17:49:07

How does Simba export classes? Like actual pascal classes, not records?

I tried simulating it like this:


string Exports[] = {
"Print", "Procedure D.Print();", //calling D.Print will call `void Print()` function below..
};

string Types[] = {
"D", "record B: Integer; end;" //D is a record holding an integer, B..
};


Export void Print()
{
std::cout<<"HEY!!!";
}

This works just fine. In lape I do:

var
Test: D;
begin
Test.Print();
end.

and it works. Actually didn't expect it to work but it works.. I just don't want to export "Lape records".. I want to know how to export pascal classes.

Now how does Simba actually do this? I want to know because mine doesn't work in PS (only lape because of Lape's record->function syntax) yet somehow Simba is able to export TMufasaBitmap to PS and all that fancy stuff..

Any ideas?

Dgby714

2014-01-20 18:32:48

From: IRC
00:30:51 <@Dgby714> ggzz, TMyType = type Pointer;
00:31:36 <@Dgby714> ggzz: Type methods pass the variable refrence as the first paramter
00:32:29 <ggzz> dgby, lost me
00:32:47 <ggzz> thread dgby, post example?
00:34:20 <@Dgby714> ggzz: Tho self should be the c++ version of said type, tho currently all of our emulated classes are just pointers to the class object


string Exports[] = {
"Print", "Procedure TMyType.Print();", //calling MyType.Print will call 'void Print(void *self)` function below [Print(MyType)]..
};

string Types[] = {
"TMyType", "type TObject;"
};


Export void Print(void *self)
{
std::cout<<"HEY!!!";
}


Only works in Lape!

masterBB

2014-01-21 16:31:42

I also want to know how class exports work in ps. Interesting.

slacky

2014-01-21 16:46:25

Sign me up for wanting to know! :)

Tho, I have a hunch saying it currently can't be done.

Dgby714

2014-01-22 05:36:58

It cannot be done in PS from plugins currently. (and prob never will be)

But if you'd like to know, you register the method declarations with the parser and compiler at compile time, then register the pointers to the method names at runtime.