Slang - self primitive: parameters:
Brad Fuller
brad at sonaural.com
Wed Dec 14 18:52:01 UTC 2005
Andreas Raab wrote:
> 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:
>
> primitiveGetText
> | 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.
Thanks Andreas. I appreciate your help and the more examples I have, the
better I'll understand Slang....the hard way usually results in the easy
way later on. :-)
brad
More information about the Vm-dev
mailing list