equal
deleted
inserted
replaced
130 else |
130 else |
131 luaL_addstring (&B, "false"); |
131 luaL_addstring (&B, "false"); |
132 } else if (type == LUA_TNIL) |
132 } else if (type == LUA_TNIL) |
133 luaL_addstring (&B, "nil"); |
133 luaL_addstring (&B, "nil"); |
134 else { |
134 else { |
135 char xbuf[9]; |
135 char xbuf[32]; |
136 luaL_addstring (&B, luaL_typename (L, i)); |
136 luaL_addstring (&B, luaL_typename (L, i)); |
137 luaL_addstring (&B, ": 0x"); |
137 luaL_addstring (&B, ": 0x"); |
138 snprintf (&xbuf[0], 9, "%08x", (int) lua_topointer (L, i)); |
138 snprintf (&xbuf[0], 32, "%p", lua_topointer (L, i)); |
139 luaL_addlstring (&B, xbuf, 8); // XXX |
139 luaL_addlstring (&B, xbuf, 8); // XXX |
140 } |
140 } |
141 } |
141 } |
142 luaL_pushresult (&B); |
142 luaL_pushresult (&B); |
143 |
143 |
978 } |
978 } |
979 } else |
979 } else |
980 cid = compl_new_category (); |
980 cid = compl_new_category (); |
981 |
981 |
982 if (cid) { |
982 if (cid) { |
983 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) cid); |
983 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) ((gsize) cid)); |
984 lua_pushinteger (L, cid); |
984 lua_pushinteger (L, cid); |
985 } else |
985 } else |
986 lua_pushnil (L); |
986 lua_pushnil (L); |
987 |
987 |
988 return 1; |
988 return 1; |
993 /// A: integer (category id) |
993 /// A: integer (category id) |
994 static int lua_main_del_category (lua_State *L) |
994 static int lua_main_del_category (lua_State *L) |
995 { |
995 { |
996 guint cid = luaL_checkinteger (L, 1); |
996 guint cid = luaL_checkinteger (L, 1); |
997 compl_del_category (cid); |
997 compl_del_category (cid); |
998 lua_added_categories = g_slist_remove (lua_added_categories, (gpointer) cid); |
998 lua_added_categories = g_slist_remove (lua_added_categories, (gpointer) ((gsize) cid)); |
999 return 0; |
999 return 0; |
1000 } |
1000 } |
1001 |
1001 |
1002 /// main.add_completion |
1002 /// main.add_completion |
1003 /// Adds word to a completion list. |
1003 /// Adds word to a completion list. |
1044 |
1044 |
1045 if (top > 3) { // Completions provided |
1045 if (top > 3) { // Completions provided |
1046 if (lua_type (L, 4) == LUA_TTABLE) { |
1046 if (lua_type (L, 4) == LUA_TTABLE) { |
1047 cid = compl_new_category (); |
1047 cid = compl_new_category (); |
1048 if (cid) { |
1048 if (cid) { |
1049 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) cid); |
1049 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) ((gsize) cid)); |
1050 lua_pushnil (L); |
1050 lua_pushnil (L); |
1051 while (lua_next (L, 4)) { |
1051 while (lua_next (L, 4)) { |
1052 char *word = to_utf8 (luaL_checkstring (L, -1)); |
1052 char *word = to_utf8 (luaL_checkstring (L, -1)); |
1053 compl_add_category_word (cid, word); |
1053 compl_add_category_word (cid, word); |
1054 lua_pop (L, 1); |
1054 lua_pop (L, 1); |
1154 static GSList *lua_timers = NULL; |
1154 static GSList *lua_timers = NULL; |
1155 |
1155 |
1156 static void lua_timer_callback_destroy (lua_timer_callback_t *cb) |
1156 static void lua_timer_callback_destroy (lua_timer_callback_t *cb) |
1157 { |
1157 { |
1158 luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
1158 luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
1159 lua_timers = g_slist_remove (lua_timers, (gpointer) cb->source); |
1159 lua_timers = g_slist_remove (lua_timers, (gpointer) ((gsize) cb->source)); |
1160 luaL_free (cb->L, cb); |
1160 luaL_free (cb->L, cb); |
1161 } |
1161 } |
1162 |
1162 |
1163 /// timer function |
1163 /// timer function |
1164 /// Function, that will be called periodically until it returns false. |
1164 /// Function, that will be called periodically until it returns false. |
1191 cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); |
1191 cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); |
1192 cb->L = L; |
1192 cb->L = L; |
1193 |
1193 |
1194 source = g_timeout_add_seconds_full (MLUA_SOURCE_PRIORITY, interval, (GSourceFunc) lua_timer_callback, cb, (GDestroyNotify) lua_timer_callback_destroy); |
1194 source = g_timeout_add_seconds_full (MLUA_SOURCE_PRIORITY, interval, (GSourceFunc) lua_timer_callback, cb, (GDestroyNotify) lua_timer_callback_destroy); |
1195 cb->source = source; |
1195 cb->source = source; |
1196 lua_timers = g_slist_prepend (lua_timers, (gpointer) source); |
1196 lua_timers = g_slist_prepend (lua_timers, (gpointer) ((gsize) source)); |
1197 |
1197 |
1198 return 0; |
1198 return 0; |
1199 } |
1199 } |
1200 |
1200 |
1201 // BACKGROUND PIPE READING |
1201 // BACKGROUND PIPE READING |
1213 |
1213 |
1214 static void lua_bgread_callback_destroy (lua_bgread_callback_t *cb) |
1214 static void lua_bgread_callback_destroy (lua_bgread_callback_t *cb) |
1215 { |
1215 { |
1216 luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
1216 luaL_unref (cb->L, LUA_REGISTRYINDEX, cb->reference); |
1217 pclose (cb->fd); // Not necessary? |
1217 pclose (cb->fd); // Not necessary? |
1218 lua_bgreads = g_slist_remove (lua_bgreads, (gpointer) cb->source); |
1218 lua_bgreads = g_slist_remove (lua_bgreads, (gpointer) ((gsize) cb->source)); |
1219 luaL_free (cb->L, cb); |
1219 luaL_free (cb->L, cb); |
1220 } |
1220 } |
1221 |
1221 |
1222 /// background reading function |
1222 /// background reading function |
1223 /// Function, that processes output from pipe in asynchroneous way. |
1223 /// Function, that processes output from pipe in asynchroneous way. |
1297 cb->L = L; |
1297 cb->L = L; |
1298 cb->fd = fd; |
1298 cb->fd = fd; |
1299 |
1299 |
1300 source = g_io_add_watch_full (channel, MLUA_SOURCE_PRIORITY, G_IO_IN|G_IO_HUP|G_IO_ERR, (GIOFunc) lua_bgread_callback, cb, (GDestroyNotify) lua_bgread_callback_destroy); |
1300 source = g_io_add_watch_full (channel, MLUA_SOURCE_PRIORITY, G_IO_IN|G_IO_HUP|G_IO_ERR, (GIOFunc) lua_bgread_callback, cb, (GDestroyNotify) lua_bgread_callback_destroy); |
1301 cb->source = source; |
1301 cb->source = source; |
1302 lua_bgreads = g_slist_prepend (lua_bgreads, (gpointer) source); |
1302 lua_bgreads = g_slist_prepend (lua_bgreads, (gpointer) ((gsize) source)); |
1303 |
1303 |
1304 // unref? |
1304 // unref? |
1305 |
1305 |
1306 return 0; |
1306 return 0; |
1307 } |
1307 } |
1737 int cid = compl_new_category (); |
1737 int cid = compl_new_category (); |
1738 |
1738 |
1739 if (cid) { |
1739 if (cid) { |
1740 const string2enum_t *word = lua_yesno; |
1740 const string2enum_t *word = lua_yesno; |
1741 lua_completion_type[MLUA_YESNO_POS].value = cid; |
1741 lua_completion_type[MLUA_YESNO_POS].value = cid; |
1742 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) cid); |
1742 lua_added_categories = g_slist_prepend (lua_added_categories, (gpointer) ((gsize) cid)); |
1743 while (word->string) { |
1743 while (word->string) { |
1744 compl_add_category_word (cid, word->string); |
1744 compl_add_category_word (cid, word->string); |
1745 ++word; |
1745 ++word; |
1746 } |
1746 } |
1747 } |
1747 } |