Lua - limiting available functions

Started by
11 comments, last by Wormy Hellcar 20 years, 5 months ago
Hmm, I feel a bit silly.
I''m using lua and tolua 5.0 now for a few reasons.
The memory leak *is* fixed in 5.0. It was 3am when I did the test so that''s my excuse


According to tolua 5.0 it does support overloading the == operator and according to lua 5.0 it supports the eq metatable method. However in practise this doesn''t seem to be the case.
If I overload both the == and + operators only the + one is actually called by lua. Infact with the == operator the tolua generated code isn''t even called.
Tolua binds these with

tolua_function(tolua_S,".eq",tolua_ai_obj_operator_eq00);
tolua_function(tolua_S,".add",tolua_ai_obj_operator_add00);

So from what I can tell it''s a lua problem.

There''s also a small bug with adding the const modifier to the package file as it still thinks that ''self'' should be just an "obj" instead of a "const obj".
There''s also a problem with returning a const object.
It tries to do
void* ret = new const obj(...);
Both minor annoyances.


The other ''problem'' is to do with the close function. According to the creator of tolua it''s not meant to generate a close function because of the way it exports the features to a module and it can be easily overwritten.
The problem is that I can''t work out how to do this.


I guess I''m down to three minor problems/annoyances. If I could get them sorted it''d be great. But even with them things are still looking good.


There are two other things that I''d like to do.
Be able to force lua_dofile() to only work on compiled files and also work out how to force it so it doesn''t allow things outside functions like C. Then I could define my own entry point for different scripts as well as ease of passing variables.

I think I could probably do the first but I have no idea about the second, not that it''s vital however.
I used to be indecisive, but now I''m not so sure.
Advertisement
It boggles my mind that everyone seems to use toLua for their interfacing, and they jump through so many hoops to do so. Just do it yourself.

"Sneftel is correct, if rather vulgar." --Flarelocke
quote:Original post by Sneftel
It boggles my mind that everyone seems to use toLua for their interfacing, and they jump through so many hoops to do so. Just do it yourself.


Heh. Yeah. Right now, tolua works pretty simply and is "sufficient" for my needs, as I am keeping the interface simple and I can automate the re-processing of my binding code in my makefiles. As soon as I have to start jumping through hoops, or doing anything inconvenient, I''ll start doing more things by hand. But for the most part, I tend to adhere to the Rule of Generation.


Josh
vertexnormal AT linuxmail DOT org

Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.

This topic is closed to new replies.

Advertisement