tolua 3.0b issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

tolua 3.0b issue

DASWorks
Hi Everyone:

Is it me, or does the below typedef not parse with tolua 3.0b?  (It chokes on
the filename[64] field.)

typedef struct {
	short vRefNum;
	short refNum;
	unsigned char filename[64];
	unsigned char path[256];
}file_info;



david

Reply | Threaded
Open this post in threaded view
|

Re: tolua 3.0b issue

Waldemar Celes-3
> Is it me, or does the below typedef not parse with tolua 3.0b?  (It chokes on
> the filename[64] field.)
> 
> typedef struct {
>         short vRefNum;
>         short refNum;
>         unsigned char filename[64];
>         unsigned char path[256];
> }file_info;
> 

in the .pkg file,
you should use "unsigned char* filename" instead,
and tolua should run just fine.

note, however, that you cannot assign string values from Lua
in such a case. Assuming "fi" is a lua variable holding an object
of that kind, the code:

print(fi.filename)

would work fine, but

fi.filename = "file"

would be wrong. It would be equivalent to the C statment:

fi->filename = "file";

what is not correct, right?

to prevent this error in using the binding code,
you can set those fields as read-only:

typedef struct {
         short vRefNum;
         short refNum;
         const unsigned char* filename;
         const unsigned char* path;
}file_info;


hope this helps.

-- waldemar