Datatypes in the .swi files
John Tytgat
John.Tytgat at aaug.net
Tue Jul 28 21:21:38 BST 2009
In message <6b70bc7650.Jan-Jaap at iyonix.c2i.net>
Jan-Jaap van der Geer <jjvdgeer at inbox.com> wrote:
> Hello,
>
> I am modifying DefMod to generate bindings for the Vala programming
> language. While doing that I found some entries that I find
> surprising. Does anyone have an idea about if these are actually
> correct?
>
> CONST
> Wimp_NoFonts = .Ref Byte: -1, //for Wimp_LoadTemplate
>
> Shouldn't that be .Ref .Byte or even .Ref .Data?
One of the two yes. Although I don't think it will make a difference
in the produced header or object files. Nevertheless, I've updated
DefMod2 so that it now issues a warning when a type gets used which is
one of the built-in types but without leading dot.
And I fixed all cases where that new warning was triggered.
Whether .Data would be better than .Byte, I really don't know as I don't
understand the relevant difference between those. Could someone
enlighten us ? Otherwise it is better to get rid of one of those types
for clarity reasons.
> [...]
> This one I find strange as well:
>
> SWI WimpClaimFreeMemory_Alloc =
> ( NUMBER 0x400EE,
> ENTRY
> ( R0 # 1 "Claims the whole of the Wimp's free memory pool for the
> calling task - Deprecated under Risc OS 3.7+",
> R1 = .Int: size
> ),
> EXIT
> ( R0?,
> R1 = .Int: size_out,
> R2! = .Ref Void: blk
> ^^^^
> ) );
>
> I would have changed the .Ref Void there to .Ref .Byte but of
> course that would change the datatype for WimpClaimFreeMemory_Alloc
> (may not a big problem for a deprecated SWI?)
".Ref Void" is used at several places in the OSLib .swi files and it is
not clear to me why that gets choosen instead of ".Ref .Byte" or
".Ref .Data".
Actually it is a bit confusing because in defmod.y we have a rule for
".void" lex word so one would think this should be ".Ref .Void", i.e.
"void" being one of the built-in types as well but that's not working
(well) nor even intended as far as I can see (my Yacc powers are not
that great so I might have missed something obvious).
> As far as I understand, datatypes that do not start with a dot are
> datatypes that should be defined elsewhere.
Yes, by one of the produced OSLib header files.
The ones with leading dot are built-in types and are defined by either C
(like 'char', 'int', 'short', etc), either by oslib/types.h (the latter
defines 'bits', 'osbool', 'byte' and 'asm_routine').
The "Void" one is the non-fitting one, it is a C type but not an OSLib
built-in type.
> Byte and Void are not.
The type names get lowercased and 'byte' is defined in oslib/types.h
and 'void' is a native C type.
Hope this helps a bit,
John.
--
John Tytgat, in his comfy chair at home BASS
John.Tytgat at aaug.net ARM powered, RISC OS driven
More information about the oslib-user
mailing list