SRL Archive - Research & Development Lounge

Pascalscript type conversions example


slushpuppy

2012-05-10 05:59:28

I did a few conversions to aid plugin, in other languages, developments for simba. I would be updating this list with other useful functions found in PS.

typedef struct {
int x,y;
} SIMBA_TPoint;
/* Unpacked records E.g. int example(SIMBA_TPoint * ptr) */

typedef struct {
char * data;
} SIMBA_string;
/* E.g. int example(SIMBA_string str) */

typedef struct {
int high;
union {
SIMBA_TPoint * atpa;
int * integer;
SIMBA_string * string;
} ;
} SIMBA_Array;
/* E.g. int example(SIMBA_Array array) {
array.atpa
array.integer
array.string
} */





References:
http://villavu.com/forum/showthread.php?t=39677
http://villavu.com/forum/showthread.php?t=64880

Credits:
Dgby, and Wizzup for answering my questions

Markus

2012-05-10 07:44:00

You might like to know that strings in pascal aren't null-terminated as opposed to C strings.

masterBB

2012-05-10 07:46:49

A bit offtopic but:

typedef struct {
int x,y;
} SIMBA_TPoint;
/* Unpacked records E.g. int example(SIMBA_TPoint * ptr) */

typedef struct {
char * data;
} SIMBA_string;
/* E.g. int example(SIMBA_string str) */

typedef struct {
int high;
union {
SIMBA_TPoint * atpa;
int * integer;
SIMBA_string * string;
} ;
} SIMBA_Array;
/* E.g. int example(SIMBA_Array array) {
array.atpa
array.integer
array.string
} */

Using [.highlight=c] tags make your code looks so much better.

slushpuppy

2012-05-10 08:00:32

From: Markus
You might like to know that strings in pascal aren't null-terminated as opposed to C strings.

I checked the heap and it appears strings are indeed NUL terminated, however if something is indeed wrong, please publish your findings

nielsie95

2012-05-10 08:23:45

Yes, they should be null-terminated (that is why conversion to PChar is so easy in Delphi/FPC). You should wright a testing plugin to test/demonstrate these conversions. Should be pretty useful indeed :)