Set destructor = NULL in destroy func to prevent it being called twice
[luakit.git] / luah.c
blob231866a5be3666a885cc1240d17497981f708ff8
1 /*
2 * luah.c - Lua helper functions
4 * Copyright (C) 2010 Mason Larobina <mason.larobina@gmail.com>
5 * Copyright (C) 2008-2009 Julien Danjou <julien@danjou.info>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <gtk/gtk.h>
23 #include <stdlib.h>
24 #include <sys/wait.h>
25 #include "common/util.h"
26 #include "common/lualib.h"
27 #include "luakit.h"
28 #include "widget.h"
29 #include "luah.h"
31 void
32 luaH_modifier_table_push(lua_State *L, guint state) {
33 gint i = 1;
34 lua_newtable(L);
35 if (state & GDK_MODIFIER_MASK) {
37 #define MODKEY(key, name) \
38 if (state & GDK_##key##_MASK) { \
39 lua_pushstring(L, name); \
40 lua_rawseti(L, -2, i++); \
43 MODKEY(SHIFT, "Shift");
44 MODKEY(LOCK, "Lock");
45 MODKEY(CONTROL, "Control");
46 MODKEY(MOD1, "Mod1");
47 MODKEY(MOD2, "Mod2");
48 MODKEY(MOD3, "Mod3");
49 MODKEY(MOD4, "Mod4");
50 MODKEY(MOD5, "Mod5");
52 #undef MODKEY
57 void
58 luaH_keystr_push(lua_State *L, guint keyval)
60 gchar ucs[7];
61 guint ulen;
62 guint32 ukval = gdk_keyval_to_unicode(keyval);
64 /* check for printable unicode character */
65 if (g_unichar_isgraph(ukval)) {
66 ulen = g_unichar_to_utf8(ukval, ucs);
67 ucs[ulen] = 0;
68 lua_pushstring(L, ucs);
70 /* sent keysym for non-printable characters */
71 else
72 lua_pushstring(L, gdk_keyval_name(keyval));
75 /* UTF-8 aware string length computing.
76 * Returns the number of elements pushed on the stack. */
77 static gint
78 luaH_utf8_strlen(lua_State *L)
80 const gchar *cmd = luaL_checkstring(L, 1);
81 lua_pushnumber(L, (ssize_t) g_utf8_strlen(NONULL(cmd), -1));
82 return 1;
85 /* Overload standard Lua next function to use __next key on metatable.
86 * Returns the number of elements pushed on stack. */
87 static gint
88 luaHe_next(lua_State *L)
90 if(luaL_getmetafield(L, 1, "__next")) {
91 lua_insert(L, 1);
92 lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
93 return lua_gettop(L);
95 luaL_checktype(L, 1, LUA_TTABLE);
96 lua_settop(L, 2);
97 if(lua_next(L, 1))
98 return 2;
99 lua_pushnil(L);
100 return 1;
103 /* Overload lua_next() function by using __next metatable field to get
104 * next elements. `idx` is the index number of elements in stack.
105 * Returns 1 if more elements to come, 0 otherwise. */
106 gint
107 luaH_next(lua_State *L, gint idx)
109 if(luaL_getmetafield(L, idx, "__next")) {
110 /* if idx is relative, reduce it since we got __next */
111 if(idx < 0) idx--;
112 /* copy table and then move key */
113 lua_pushvalue(L, idx);
114 lua_pushvalue(L, -3);
115 lua_remove(L, -4);
116 lua_pcall(L, 2, 2, 0);
117 /* next returned nil, it's the end */
118 if(lua_isnil(L, -1)) {
119 /* remove nil */
120 lua_pop(L, 2);
121 return 0;
123 return 1;
125 else if(lua_istable(L, idx))
126 return lua_next(L, idx);
127 /* remove the key */
128 lua_pop(L, 1);
129 return 0;
132 /* Generic pairs function.
133 * Returns the number of elements pushed on stack. */
134 static gint
135 luaH_generic_pairs(lua_State *L)
137 lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
138 lua_pushvalue(L, 1); /* state, */
139 lua_pushnil(L); /* and initial value */
140 return 3;
143 /* Overload standard pairs function to use __pairs field of metatables.
144 * Returns the number of elements pushed on stack. */
145 static gint
146 luaHe_pairs(lua_State *L)
148 if(luaL_getmetafield(L, 1, "__pairs")) {
149 lua_insert(L, 1);
150 lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
151 return lua_gettop(L);
153 luaL_checktype(L, 1, LUA_TTABLE);
154 return luaH_generic_pairs(L);
157 static gint
158 luaH_ipairs_aux(lua_State *L)
160 gint i = luaL_checkint(L, 2) + 1;
161 luaL_checktype(L, 1, LUA_TTABLE);
162 lua_pushinteger(L, i);
163 lua_rawgeti(L, 1, i);
164 return (lua_isnil(L, -1)) ? 0 : 2;
167 /* Overload standard ipairs function to use __ipairs field of metatables.
168 * Returns the number of elements pushed on stack. */
169 static gint
170 luaHe_ipairs(lua_State *L)
172 if(luaL_getmetafield(L, 1, "__ipairs")) {
173 lua_insert(L, 1);
174 lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
175 return lua_gettop(L);
178 luaL_checktype(L, 1, LUA_TTABLE);
179 lua_pushvalue(L, lua_upvalueindex(1));
180 lua_pushvalue(L, 1);
181 lua_pushinteger(L, 0); /* and initial value */
182 return 3;
185 /* Enhanced type() function which recognize luakit objects.
186 * \param L The Lua VM state.
187 * \return The number of arguments pushed on the stack.
189 static gint
190 luaHe_type(lua_State *L)
192 luaL_checkany(L, 1);
193 lua_pushstring(L, luaH_typename(L, 1));
194 return 1;
198 /* Fix up and add handy standard lib functions */
199 static void
200 luaH_fixups(lua_State *L)
202 /* export string.wlen */
203 lua_getglobal(L, "string");
204 lua_pushcfunction(L, &luaH_utf8_strlen);
205 lua_setfield(L, -2, "wlen");
206 lua_pop(L, 1);
207 /* replace next */
208 lua_pushliteral(L, "next");
209 lua_pushcfunction(L, luaHe_next);
210 lua_settable(L, LUA_GLOBALSINDEX);
211 /* replace pairs */
212 lua_pushliteral(L, "pairs");
213 lua_pushcfunction(L, luaHe_next);
214 lua_pushcclosure(L, luaHe_pairs, 1); /* pairs get next as upvalue */
215 lua_settable(L, LUA_GLOBALSINDEX);
216 /* replace ipairs */
217 lua_pushliteral(L, "ipairs");
218 lua_pushcfunction(L, luaH_ipairs_aux);
219 lua_pushcclosure(L, luaHe_ipairs, 1);
220 lua_settable(L, LUA_GLOBALSINDEX);
221 /* replace type */
222 lua_pushliteral(L, "type");
223 lua_pushcfunction(L, luaHe_type);
224 lua_settable(L, LUA_GLOBALSINDEX);
227 /* Look for an item: table, function, etc.
228 * \param L The Lua VM state.
229 * \param item The pointer item.
231 gboolean
232 luaH_hasitem(lua_State *L, gconstpointer item)
234 lua_pushnil(L);
235 while(luaH_next(L, -2)) {
236 if(lua_topointer(L, -1) == item) {
237 /* remove value and key */
238 lua_pop(L, 2);
239 return TRUE;
241 if(lua_istable(L, -1))
242 if(luaH_hasitem(L, item)) {
243 /* remove key and value */
244 lua_pop(L, 2);
245 return TRUE;
247 /* remove value */
248 lua_pop(L, 1);
250 return FALSE;
253 /* Browse a table pushed on top of the index, and put all its table and
254 * sub-table ginto an array.
255 * \param L The Lua VM state.
256 * \param elems The elements array.
257 * \return False if we encounter an elements already in list.
259 static gboolean
260 luaH_isloop_check(lua_State *L, GPtrArray *elems)
262 if(lua_istable(L, -1)) {
263 gconstpointer object = lua_topointer(L, -1);
265 /* Check that the object table is not already in the list */
266 for(guint i = 0; i < elems->len; i++)
267 if(elems->pdata[i] == object)
268 return FALSE;
270 /* push the table in the elements list */
271 g_ptr_array_add(elems, (gpointer) object);
273 /* look every object in the "table" */
274 lua_pushnil(L);
275 while(luaH_next(L, -2)) {
276 if(!luaH_isloop_check(L, elems)) {
277 /* remove key and value */
278 lua_pop(L, 2);
279 return FALSE;
281 /* remove value, keep key for next iteration */
282 lua_pop(L, 1);
285 return TRUE;
288 /* Check if a table is a loop. When using tables as direct acyclic digram,
289 * this is useful.
290 * \param L The Lua VM state.
291 * \param idx The index of the table in the stack
292 * \return True if the table loops.
294 gboolean
295 luaH_isloop(lua_State *L, gint idx)
297 /* elems is an elements array that we will fill with all array we
298 * encounter while browsing the tables */
299 GPtrArray *elems = g_ptr_array_new();
301 /* push table on top */
302 lua_pushvalue(L, idx);
304 gboolean ret = luaH_isloop_check(L, elems);
306 /* remove pushed table */
307 lua_pop(L, 1);
309 g_ptr_array_free(elems, TRUE);
311 return !ret;
314 /* Returns a string from X selection.
315 * \param L The Lua VM state.
316 * \return The number of elements pushed on stack (1).
318 static gint
319 luaH_luakit_get_selection(lua_State *L)
321 int n = lua_gettop(L);
322 GdkAtom atom = GDK_SELECTION_PRIMARY;
324 if (n) {
325 const gchar *arg = luaL_checkstring(L, 1);
326 /* Follow xclip(1) behavior: check only the first character of argument */
327 switch (arg[0]) {
328 case 'p':
329 break;
330 case 's':
331 atom = GDK_SELECTION_SECONDARY;
332 break;
333 case 'c':
334 atom = GDK_SELECTION_CLIPBOARD;
335 break;
336 default:
337 luaL_argerror(L, 1, "should be 'primary', 'secondary' or 'clipboard'");
338 break;
341 GtkClipboard *selection = gtk_clipboard_get(atom);
342 gchar *text = gtk_clipboard_wait_for_text(selection);
343 lua_pushstring(L, text);
344 g_free(text);
345 return 1;
348 /* Sets an X selection.
349 * \param L The Lua VM state.
350 * \return The number of elements pushed on stack (0).
352 static gint
353 luaH_luakit_set_selection(lua_State *L)
355 int n = lua_gettop(L);
356 GdkAtom atom = GDK_SELECTION_PRIMARY;
358 if (0 == n)
359 luaL_error(L, "missing argument, string expected");
360 const gchar *text = luaL_checkstring(L, 1);
361 if (1 < n)
363 const gchar *arg = luaL_checkstring(L, 2);
364 /* Follow xclip(1) behavior: check only the first character of argument */
365 switch (arg[0]) {
366 case 'p':
367 break;
368 case 's':
369 atom = GDK_SELECTION_SECONDARY;
370 break;
371 case 'c':
372 atom = GDK_SELECTION_CLIPBOARD;
373 break;
374 default:
375 luaL_argerror(L, 1, "should be 'primary', 'secondary' or 'clipboard'");
376 break;
379 GtkClipboard *selection = gtk_clipboard_get(atom);
380 glong len = g_utf8_strlen (text, -1);
381 gtk_clipboard_set_text(selection, text, len);
382 return 0;
385 static gint
386 luaH_luakit_get_special_dir(lua_State *L)
388 size_t len;
389 const gchar *name = luaL_checklstring(L, 1, &len);
390 luakit_token_t token = l_tokenize(name, len);
391 GUserDirectory atom;
392 /* match token with G_USER_DIR_* atom */
393 switch(token) {
394 case L_TK_DESKTOP: atom = G_USER_DIRECTORY_DESKTOP; break;
395 case L_TK_DOCUMENTS: atom = G_USER_DIRECTORY_DOCUMENTS; break;
396 case L_TK_DOWNLOAD: atom = G_USER_DIRECTORY_DOWNLOAD; break;
397 case L_TK_MUSIC: atom = G_USER_DIRECTORY_MUSIC; break;
398 case L_TK_PICTURES: atom = G_USER_DIRECTORY_PICTURES; break;
399 case L_TK_PUBLIC_SHARE: atom = G_USER_DIRECTORY_PUBLIC_SHARE; break;
400 case L_TK_TEMPLATES: atom = G_USER_DIRECTORY_TEMPLATES; break;
401 case L_TK_VIDEOS: atom = G_USER_DIRECTORY_VIDEOS; break;
402 default:
403 warn("unknown atom G_USER_DIRECTORY_%s", name);
404 luaL_argerror(L, 1, "invalid G_USER_DIRECTORY_* atom");
405 return 0;
407 lua_pushstring(L, g_get_user_special_dir(atom));
408 return 1;
411 /* Spawns a command synchonously.
412 * \param L The Lua VM state.
413 * \return The number of elements pushed on stack (3).
415 static gint
416 luaH_luakit_spawn_sync(lua_State *L)
418 GError *e = NULL;
419 gchar *stdout = NULL;
420 gchar *stderr = NULL;
421 gint rv;
422 __sighandler_t chldhandler;
424 const gchar *command = luaL_checkstring(L, 1);
426 /* Note: we have to temporarily clear the SIGCHLD handler. Otherwise
427 * g_spawn_sync wouldn't be able to read subprocess' return value. */
428 if (SIG_ERR == (chldhandler = signal(SIGCHLD, SIG_DFL)))
429 fatal("Can't clear SIGCHLD handler");
430 g_spawn_command_line_sync(command, &stdout, &stderr, &rv, &e);
431 if(signal(SIGCHLD, chldhandler) == SIG_ERR)
432 fatal("Can't restore SIGCHLD handler");
434 if(e)
436 lua_pushstring(L, e->message);
437 g_clear_error(&e);
438 lua_error(L);
440 lua_pushinteger(L, WEXITSTATUS(rv));
441 lua_pushstring(L, stdout);
442 lua_pushstring(L, stderr);
443 g_free(stdout);
444 g_free(stderr);
445 return 3;
448 /* Spawns a command.
449 * \param L The Lua VM state.
450 * \return The number of elements pushed on stack (0).
452 static gint
453 luaH_luakit_spawn(lua_State *L)
455 GError *e = NULL;
456 const gchar *command = luaL_checkstring(L, 1);
457 g_spawn_command_line_async(command, &e);
458 if(e)
460 lua_pushstring(L, e->message);
461 g_clear_error(&e);
462 lua_error(L);
464 return 0;
467 /* luakit global table.
468 * \param L The Lua VM state.
469 * \return The number of elements pushed on stack.
470 * \luastack
471 * \lfield font The default font.
472 * \lfield font_height The default font height.
473 * \lfield conffile The configuration file which has been loaded.
475 static gint
476 luaH_luakit_index(lua_State *L)
478 if(luaH_usemetatable(L, 1, 2))
479 return 1;
481 size_t len;
482 widget_t *w;
483 const gchar *prop = luaL_checklstring(L, 2, &len);
484 luakit_token_t token = l_tokenize(prop, len);
486 switch(token)
488 case L_TK_WINDOWS:
489 lua_newtable(L);
490 for (guint i = 0; i < globalconf.windows->len; i++) {
491 w = globalconf.windows->pdata[i];
492 luaH_object_push(L, w->ref);
493 lua_rawseti(L, -2, i+1);
495 return 1;
497 case L_TK_GET_SELECTION:
498 lua_pushcfunction(L, luaH_luakit_get_selection);
499 return 1;
501 case L_TK_SET_SELECTION:
502 lua_pushcfunction(L, luaH_luakit_set_selection);
503 return 1;
505 case L_TK_INSTALL_PATH:
506 lua_pushliteral(L, LUAKIT_INSTALL_PATH);
507 return 1;
509 case L_TK_CONFIG_DIR:
510 lua_pushstring(L, globalconf.config_dir);
511 return 1;
513 case L_TK_DATA_DIR:
514 lua_pushstring(L, globalconf.data_dir);
515 return 1;
517 case L_TK_CACHE_DIR:
518 lua_pushstring(L, globalconf.cache_dir);
519 return 1;
521 case L_TK_VERBOSE:
522 lua_pushboolean(L, globalconf.verbose);
523 return 1;
525 case L_TK_GET_SPECIAL_DIR:
526 lua_pushcfunction(L, luaH_luakit_get_special_dir);
527 return 1;
529 case L_TK_SPAWN:
530 lua_pushcfunction(L, luaH_luakit_spawn);
531 return 1;
533 case L_TK_SPAWN_SYNC:
534 lua_pushcfunction(L, luaH_luakit_spawn_sync);
535 return 1;
537 default:
538 break;
540 return 0;
543 /* Newindex function for the luakit global table.
544 * \param L The Lua VM state.
545 * \return The number of elements pushed on stack.
547 static gint
548 luaH_luakit_newindex(lua_State *L)
550 if(luaH_usemetatable(L, 1, 2))
551 return 1;
553 size_t len;
554 const gchar *buf = luaL_checklstring(L, 2, &len);
556 debug("Luakit newindex %s", buf);
558 return 0;
561 /* Add a global signal.
562 * Returns the number of elements pushed on stack.
563 * \luastack
564 * \lparam A string with the event name.
565 * \lparam The function to call.
567 static gint
568 luaH_luakit_add_signal(lua_State *L)
570 const gchar *name = luaL_checkstring(L, 1);
571 luaH_checkfunction(L, 2);
572 signal_add(globalconf.signals, name, luaH_object_ref(L, 2));
573 return 0;
576 /* Remove a global signal.
577 * \param L The Lua VM state.
578 * \return The number of elements pushed on stack.
579 * \luastack
580 * \lparam A string with the event name.
581 * \lparam The function to call.
583 static gint
584 luaH_luakit_remove_signal(lua_State *L)
586 const gchar *name = luaL_checkstring(L, 1);
587 luaH_checkfunction(L, 2);
588 gpointer func = (gpointer) lua_topointer(L, 2);
589 signal_remove(globalconf.signals, name, func);
590 luaH_object_unref(L, (void *) func);
591 return 0;
594 /* Emit a global signal.
595 * \param L The Lua VM state.
596 * \return The number of elements pushed on stack.
597 * \luastack
598 * \lparam A string with the event name.
599 * \lparam The function to call.
601 static gint
602 luaH_luakit_emit_signal(lua_State *L)
604 signal_object_emit(L, globalconf.signals, luaL_checkstring(L, 1), lua_gettop(L) - 1);
605 return 0;
608 static gint
609 luaH_panic(lua_State *L)
611 warn("unprotected error in call to Lua API (%s)", lua_tostring(L, -1));
612 return 0;
615 static gint
616 luaH_quit(lua_State *L)
618 (void) L;
619 gtk_main_quit();
620 return 0;
623 static gint
624 luaH_dofunction_on_error(lua_State *L)
626 /* duplicate string error */
627 lua_pushvalue(L, -1);
628 /* emit error signal */
629 signal_object_emit(L, globalconf.signals, "debug::error", 1);
631 if(!luaL_dostring(L, "return debug.traceback(\"error while running function\", 3)"))
633 /* Move traceback before error */
634 lua_insert(L, -2);
635 /* Insert sentence */
636 lua_pushliteral(L, "\nerror: ");
637 /* Move it before error */
638 lua_insert(L, -2);
639 lua_concat(L, 3);
641 return 1;
644 void
645 luaH_init(void)
647 lua_State *L;
649 static const struct luaL_reg luakit_lib[] = {
650 { "quit", luaH_quit },
651 { "add_signal", luaH_luakit_add_signal },
652 { "remove_signal", luaH_luakit_remove_signal },
653 { "emit_signal", luaH_luakit_emit_signal },
654 { "__index", luaH_luakit_index },
655 { "__newindex", luaH_luakit_newindex },
656 { NULL, NULL }
659 /* Lua VM init */
660 L = globalconf.L = luaL_newstate();
662 /* Set panic fuction */
663 lua_atpanic(L, luaH_panic);
665 /* Set error handling function */
666 lualib_dofunction_on_error = luaH_dofunction_on_error;
668 luaL_openlibs(L);
670 luaH_fixups(L);
672 luaH_object_setup(L);
674 /* Export luakit lib */
675 luaH_openlib(L, "luakit", luakit_lib, luakit_lib);
677 /* Export widget */
678 widget_class_setup(L);
680 /* add Lua search paths */
681 lua_getglobal(L, "package");
682 if(LUA_TTABLE != lua_type(L, 1)) {
683 warn("package is not a table");
684 return;
686 lua_getfield(L, 1, "path");
687 if(LUA_TSTRING != lua_type(L, 2)) {
688 warn("package.path is not a string");
689 lua_pop(L, 1);
690 return;
693 /* compile list of package search paths */
694 GPtrArray *paths = g_ptr_array_new_with_free_func(g_free);
696 #if DEVELOPMENT_PATHS
697 /* allows for testing luakit in the project directory */
698 g_ptr_array_add(paths, g_strdup("./lib"));
699 #endif
701 /* add users config dir (see: XDG_CONFIG_DIR) */
702 g_ptr_array_add(paths, g_build_filename(globalconf.config_dir, "lib", NULL));
704 /* add system config dirs (see: XDG_CONFIG_DIRS) */
705 const gchar* const *config_dirs = g_get_system_config_dirs();
706 for (; *config_dirs; config_dirs++)
707 g_ptr_array_add(paths, g_build_filename(*config_dirs, "luakit", "lib", NULL));
709 /* add luakit install path */
710 g_ptr_array_add(paths, g_build_filename(LUAKIT_INSTALL_PATH, "lib", NULL));
712 for (gpointer *path = paths->pdata; *path; path++) {
713 lua_pushliteral(L, ";");
714 lua_pushstring(L, *path);
715 lua_pushliteral(L, "/?.lua");
716 lua_concat(L, 3);
718 lua_pushliteral(L, ";");
719 lua_pushstring(L, *path);
720 lua_pushliteral(L, "/?/init.lua");
721 lua_concat(L, 3);
723 /* concat with package.path */
724 lua_concat(L, 3);
727 g_ptr_array_free(paths, TRUE);
729 /* package.path = "concatenated string" */
730 lua_setfield(L, 1, "path");
733 gboolean
734 luaH_loadrc(const gchar *confpath, gboolean run)
736 debug("Loading rc: %s", confpath);
737 lua_State *L = globalconf.L;
738 if(!luaL_loadfile(L, confpath)) {
739 if(run) {
740 if(lua_pcall(L, 0, LUA_MULTRET, 0)) {
741 g_fprintf(stderr, "%s\n", lua_tostring(L, -1));
742 } else
743 return TRUE;
744 } else
745 lua_pop(L, 1);
746 return TRUE;
747 } else
748 g_fprintf(stderr, "%s\n", lua_tostring(L, -1));
749 return FALSE;
752 /* Load a configuration file. */
753 gboolean
754 luaH_parserc(const gchar *confpath, gboolean run)
756 const gchar* const *config_dirs = NULL;
757 gboolean ret = FALSE;
758 GPtrArray *paths = NULL;
760 /* try to load, return if it's ok */
761 if(confpath) {
762 if(luaH_loadrc(confpath, run))
763 ret = TRUE;
764 goto bailout;
767 /* compile list of config search paths */
768 paths = g_ptr_array_new_with_free_func(g_free);
770 #if DEVELOPMENT_PATHS
771 /* allows for testing luakit in the project directory */
772 g_ptr_array_add(paths, g_strdup("./rc.lua"));
773 #endif
775 /* search users config dir (see: XDG_CONFIG_HOME) */
776 g_ptr_array_add(paths, g_build_filename(globalconf.config_dir, "rc.lua", NULL));
778 /* search system config dirs (see: XDG_CONFIG_DIRS) */
779 config_dirs = g_get_system_config_dirs();
780 for(; *config_dirs; config_dirs++)
781 g_ptr_array_add(paths, g_build_filename(*config_dirs, "luakit", "rc.lua", NULL));
783 for (gpointer *path = paths->pdata; *path; path++) {
784 if (file_exists(*path)) {
785 if(luaH_loadrc(*path, run)) {
786 globalconf.confpath = g_strdup(*path);
787 ret = TRUE;
788 goto bailout;
789 } else if(!run)
790 goto bailout;
794 bailout:
796 if (paths) g_ptr_array_free(paths, TRUE);
797 return ret;
800 gint
801 luaH_class_index_miss_property(lua_State *L, lua_object_t *obj)
803 (void) obj;
804 signal_object_emit(L, globalconf.signals, "debug::index::miss", 2);
805 return 0;
808 gint
809 luaH_class_newindex_miss_property(lua_State *L, lua_object_t *obj)
811 (void) obj;
812 signal_object_emit(L, globalconf.signals, "debug::newindex::miss", 3);
813 return 0;
816 // vim: ft=c:et:sw=4:ts=8:sts=4:tw=80