[Gambas-user] Question about Object.Size and object symbol enumeration
tobias
tobiasboe1 at ...20...
Mon Jan 16 18:04:16 CET 2012
hi,
Jussi Lahtinen wrote:
> Hi!
> Seems like function Object.SizeOf() always returns numbers dividable by 8.
> Is this because objects are allocated as 64 bit chunks in 64 bit OS, or is
> this bug?
>
> I used following code:
>
> Dim hTesting As New CTest
>
> Print Object.SizeOf(hTesting)
>
>
> CTest contains only public test variables like:
> Public Test As Byte
> Public Test2 As Byte
>
>
> Other question.
> Is it possible to enumerate constants from object?
> I have big exported class which contains only constants,
> and I would like to handle them automatically in another program.
>
i think, i'm not the man to answer your first question (maybe it is some
alignment/padding thing).
but for the second question: Class.Symbols and Class[sSymbol] will do it:
DIM sSym AS String
DIM hCls AS Class
' let hObj be the instance of your big exported class (btw, you don't
' need to have an instance for this, i think...)
hCls = Object.Class(hObj)
FOR EACH sSym IN Classes[hCls.Name].Symbols
IF hCls[sSym].Kind = Class.Constant THEN
PRINT "constant: "; sSym; " = "; hCls[sSym].Value
ENDIF
NEXT
regards,
tobi
More information about the User
mailing list