Results 1 to 5 of 5

Thread: Pascalscript type conversions example

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default Pascalscript type conversions example

    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.

    Code:
    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
    Last edited by slushpuppy; 05-10-2012 at 12:02 PM.

  2. #2
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    You might like to know that strings in pascal aren't null-terminated as opposed to C strings.
    I made a new script, check it out!.

  3. #3
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    A bit offtopic but:
    c Code:
    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.
    Working on: Tithe Farmer

  4. #4
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    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

  5. #5
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    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
    Hup Holland Hup!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •