[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] Question on CStruct
From: |
Thomas Girard |
Subject: |
[Help-smalltalk] Question on CStruct |
Date: |
Sun, 09 Dec 2012 22:57:58 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.11) Gecko/20121123 Icedove/10.0.11 |
Hello,
Can we use instance variables in CStruct?
The following snippet is working as expected:
> CStruct subclass: Sequence [
> <declaration: #( (#maximum #uLong)
> (#length #uLong)
> (#buffer (#ptr #CObject))
> (#release #uChar) )>
>
> | arrayType |
>
> arrayType [
> ^arrayType
> ]
>
> arrayType: aType [
> arrayType := aType
> ]
> ]
>
> Eval [
> |s|
> s := Sequence new.
> s arrayType: CBoolean.
> s arrayType inspect.
> ]
But embedding this CStruct with instance variable into another CStruct
does *not* work:
> CStruct subclass: EmbeddedSequence [
> <declaration: #( (#days #uShort)
> (#intervals #{Sequence}) )>
> ]
>
> Eval [
> |eq|
> eq := EmbeddedSequence new.
> eq intervals arrayType: CBoolean.
> eq intervals arrayType inspect.
> ]
because we get an UndefinedObject for arrayType. Somehow it seems the
instance variable arrayType cannot be reached.
I would expect either gst to reject the former snippet if instance
variable in CStruct is not allowed, or to correctly return what was
sent in the second snippet. Am I missing something?
Thanks,
Regards,
Thomas
- [Help-smalltalk] Question on CStruct,
Thomas Girard <=