Slang - self primitive: parameters:

Andreas Raab andreas.raab at
Wed Dec 14 03:23:26 UTC 2005

Brad Fuller wrote:
> I've been fooling with this all day.. getting frustrating!

If you get frustrated enough and decide to (instead of tricking 
SmartSyntaxPlugin into doing the right thing) do the hard way, here is how:

    | text sz oop ptr |
    self export: true.
    self var: #text type: 'char*'.
    self var: #ptr type: 'char*'.
    text := self cCode: 'GetText()'.
    sz := self strlen: sz.
    "Create new String object of appropriate size"
    oop := interpreterProxy
              instantiateClass: interpreterProxy classString
              indexableSize: sz.
    "Copy data"
    ptr := interpreterProxy firstIndexableField: oop.
    self cCode:'memcpy(ptr, text, sz)'.
    "Return oop"
    interpreterProxy pop: interpreterProxy methodArgumentCount+1.
    interpreterProxy push: oop.

   - Andreas

More information about the Vm-dev mailing list