|
|
Go to the documentation of this file.
29#ifndef FAUDES_MUTE_LUA
33 "and", "break", "do", "else", "elseif", "end", "false",
34 "for", "function", "if", "in", "local", "nil", "not", "or",
35 "repeat", "return", "then", "true", "until", "while", NULL
40 std::string::const_iterator sit=str.begin();
41 if(sit==str.end()) return false;
42 if(!(isalpha(*sit) || *sit== '_')) return false;
43 for(++sit; sit!=str.end(); ++sit)
44 if(!(isalnum(*sit) || *sit== '_')) return true;
49static void faudes_rl_dmadd(std::list< std::string > & mlist, const std::string& prefix, const std::string& str, const std::string& suffix) {
52 for( unsigned int i=0;i<suffix.size();i++)
58 comp=prefix + str + suffix;
61 mlist.push_back(comp);
66 mlist.push_back(*mlist.begin());
67 mlist.push_back(comp);
70 std::string& match=*mlist.begin();
71 std::string::iterator mit, cit;
74 while(mit!=match.end() && cit!=comp.end()) {
80 match.erase(mit,match.end());
82 mlist.push_back(comp);
90 if(!lua_getmetatable(L, -1))
91 { lua_pop(L, 1); return 0; }
94 lua_pushstring(L, "__index");
98 if(lua_isnil(L,-1) || lua_rawequal(L, -1, -2))
99 { lua_pop(L, 1); return 0; }
108 if(!lua_getmetatable(L, -1))
109 { lua_pop(L, 1); lua_newtable(L); return; }
112 lua_pushstring(L, ".fn");
115 if(!lua_istable(L, -1))
116 { lua_pop(L, 1); lua_newtable(L); return; }
124 if(!lua_getmetatable(L, -1))
125 { lua_pop(L, 1); lua_newtable(L); return; }
128 lua_pushstring(L, ".get");
131 if(!lua_istable(L, -1))
132 { lua_pop(L, 1); lua_newtable(L); return; }
143 if(lua_istable(L,-1)) {
146 if(lua_next(L, -2)) {
170 if(lua_istable(L, -1)) {
171 lua_pushlstring(L, s, n);
173 if(!lua_isnil(L, -1))
174 {lua_replace(L, -2); return 1;}
188 std::list< std::string > mlist;
189 const char* text= word.c_str();
195 size_t i, n, dot, loop;
198 bool used_swig_get= false;
201 if (!(text[0] == '\0' || isalpha(text[0]) || text[0] == '_')) return mlist;
204 savetop = lua_gettop(L);
208 lua_pushglobaltable(L);
209 for(n = ( size_t)(end-start), i = dot = 0, colon=-1; i < n; i++) {
210 if(text[i] == '.' || text[i] == ':') {
212 { lua_settop(L, savetop); return mlist; }
214 if(text[i] == ':') colon=dot;
221 if(!strncmp(s, text, n)) faudes_rl_dmadd(mlist, "", std::string(s), " ");
226 if(lua_istable(L, -1))
227 if((loop == 0 || 1 ) ) {
228 for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
229 if (lua_type(L, -2) == LUA_TSTRING) {
230 s = lua_tostring(L, -2);
233 (*s != '_' || text[dot] == '_')) {
234 std::string suf = " ";
235 switch (lua_type(L, -1)) {
236 case LUA_TTABLE: suf = ":."; break;
237 case LUA_TFUNCTION: if(!used_swig_get) suf = "("; break;
239 if (lua_getmetatable(L, -1)) { lua_pop(L, 1); suf = ":."; }
248 } while (++loop < 20);
251 lua_settop(L, savetop);
static int faudes_rl_getmetaindex(lua_State *L)
static std::list< std::string > faudes_rl_complete(lua_State *L, const std::string &word)
static int faudes_rl_getfield(lua_State *L, const char *s, size_t n)
static void faudes_rl_getmetafn(lua_State *L)
static int faudes_rl_getmeta(lua_State *L, bool has_colon)
static const char *const faudes_rl_keywords[]
static void faudes_rl_dmadd(std::list< std::string > &mlist, const std::string &prefix, const std::string &str, const std::string &suffix)
static bool faudes_rl_valididentifier(const std::string &str)
static void faudes_rl_getmetaget(lua_State *L)
libFAUDES 2.34d
--- 2026.03.11
--- c++ api documentaion by doxygen
|