From 8ce6266e6bb5a834a05ec42743dfccbdd4a653ae Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 7 Jan 2014 17:36:54 -0800 Subject: [PATCH] feat(library/kernel_bindings): add new predicates for kernel objects in the Lua API Signed-off-by: Leonardo de Moura --- src/library/kernel_bindings.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/library/kernel_bindings.cpp b/src/library/kernel_bindings.cpp index 2f7a5da74..9a2054387 100644 --- a/src/library/kernel_bindings.cpp +++ b/src/library/kernel_bindings.cpp @@ -1337,6 +1337,16 @@ OBJECT_PRED(is_var_decl) OBJECT_PRED(is_builtin) OBJECT_PRED(is_builtin_set) +#define OBJECT_EXTRA_PRED(P) \ +static int object_ ## P(lua_State * L) { \ + lua_pushboolean(L, P(to_object(L, 1))); \ + return 1; \ +} + +OBJECT_EXTRA_PRED(is_begin_import) +OBJECT_EXTRA_PRED(is_begin_builtin_import) +OBJECT_EXTRA_PRED(is_end_import) + static int object_in_builtin_set(lua_State * L) { lua_pushboolean(L, to_object(L, 1).in_builtin_set(to_expr(L, 2))); return 1; @@ -1371,6 +1381,9 @@ static const struct luaL_Reg object_m[] = { {"is_builtin", safe_function}, {"is_builtin_set", safe_function}, {"in_builtin_set", safe_function}, + {"is_begin_import", safe_function}, + {"is_begin_builtin_import", safe_function}, + {"is_end_import", safe_function}, {0, 0} };