SWIG considers C's enum as userdata. (I checked the source it generated. Perhaps a bug?). Then, I need to create userdata inside the Lua scripts itself... Any good ways?
1 Answer
Then, I need to create userdata inside the Lua scripts itself.
No. You want to create one of the enumerator values within Lua. You do that pretty much as you would in C: use the enumerator's name. This is an object that has the value of the enumerator. However SWIG's Lua component decides to marshal this is irrelevant; just use the name in your Lua code.
2 Comments
ekd123
Well, but I do not define the enum myself. I'm using lgi to access the value of Gtk.PositionType.RIGHT. It's actually an integer. I tried to define it, but it's still treated as integer. I think that's because SWIG can't find the definition of GtkPositionType, so it thinks it's a userdata. I have no idea how to make it do the right thing. SWIG can't even understand the header of Gtk.
ekd123
Okay, I wrote the definition in the .i file myself. It seems to consider it as a number correctly.. I realized that the biggest problem is that SWIG can't understand headers of GTK, or even headers written with GObject.