Permalink
Browse files

Merged in Pull request

  • Loading branch information...
2 parents 48bd795 + 51316dd commit f9c09ad2cf7c8cd77b334c6dcfec449dc1b80866 Daniel Holden committed Jan 2, 2013
View
@@ -43,7 +43,6 @@ else ifeq ($(findstring Darwin,$(PLATFORM)),Darwin)
STATIC_LIB_SUFFIX:=.a
else ifeq ($(findstring MINGW,$(PLATFORM)),MINGW)
LUA_INCLUDE_DIR?= -I./lua52/include
- LUA_LIBRARY_DIR?= -L./lua52
LUA_LIBRARY?= -llua52
LAC_LDFLAGS+= -L.
LAC_LIBS+= -lmingw32
View
@@ -1,7 +1,7 @@
Lua AutoC
=========
-Version 0.8
+Version 0.85
Introduction
------------
@@ -115,14 +115,14 @@ typedef struct {
int x, y;
} pair;
-static int luaA_push_pair(lua_State* L, void* c_in) {
+static int luaA_push_pair(lua_State* L, luaA_Type t, const void* c_in) {
pair p = *(pair*)c_in;
lua_pushinteger(L, p.x);
lua_pushinteger(L, p.y);
return 2;
}
-static void luaA_to_pair(lua_State* L, void* c_out, int index) {
+static void luaA_to_pair(lua_State* L, luaA_Type t, void* c_out, int index) {
pair* p = (pair*)c_out;
p->y = lua_tointeger(L, index);
p->x = lua_tointeger(L, index-1);
@@ -320,7 +320,7 @@ static void print_int_list(int* list, int num_ints) {
typedef int* int_list;
static int list_space[512];
-static void luaA_to_int_list(lau_State* L, void* c_out, int index) {
+static void luaA_to_int_list(lau_State* L, luaA_Type t, void* c_out, int index) {
for(int i = 1; i <= luaL_getn(L, index); i++) {
lua_pushinteger(L, i);
lua_gettable(L, index-1);
@@ -334,7 +334,7 @@ luaA_conversion_to(int_list, luaA_to_int_list);
luaA_function_void(print_int_list, 2, int_list, int);
```
-As you can probably see, automatic wrapping and type conversion becomes hard when memory management and pointers are involved. I'm looking at ways to improve this, perhaps with the ability to register 'before' and 'after' methods for certain functions or conversions.
+As you can probably see, automatic wrapping and type conversion becomes hard when memory management and pointers are involved.
FAQ
---
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -9,14 +9,14 @@ typedef struct {
int x, y;
} pair;
-static int luaA_push_pair(lua_State* L, void* c_in) {
+static int luaA_push_pair(lua_State* L, luaA_Type t, const void* c_in) {
pair p = *(pair*)c_in;
lua_pushinteger(L, p.x);
lua_pushinteger(L, p.y);
return 2;
}
-static void luaA_to_pair(lua_State* L, void* c_out, int index) {
+static void luaA_to_pair(lua_State* L, luaA_Type t, void* c_out, int index) {
pair* p = (pair*)c_out;
p->y = lua_tointeger(L, index);
p->x = lua_tointeger(L, index-1);
View
@@ -26,7 +26,6 @@ static int birdie_newindex(lua_State* L) {
const char* membername = lua_tostring(L, -2);
birdie* self = get_instance_ptr(L);
luaA_struct_to_member_name(L, membername, self, membername, -1);
- //luaA_struct_to_member_name(L, birdie, self, membername, -1);
return 0;
}
View
@@ -30,13 +30,18 @@ void luaA_type_close(void);
typedef int luaA_Type;
#define LUAA_INVALID_TYPE -1
+typedef int (*luaA_Pushfunc)(lua_State*, luaA_Type, const void*);
+typedef void (*luaA_Tofunc)(lua_State*, luaA_Type, void*, int);
+
#define luaA_type_id(type) luaA_type_add(#type, sizeof(type))
luaA_Type luaA_type_add(const char* type, size_t size);
luaA_Type luaA_type_find(const char* type);
const char* luaA_type_name(luaA_Type id);
size_t luaA_type_size(luaA_Type id);
+bool luaA_type_has_push_func(luaA_Type id);
+bool luaA_type_has_to_func(luaA_Type id);
/*
@@ -51,9 +56,6 @@ void luaA_stack_close(void);
int luaA_push_typeid(lua_State* L, luaA_Type type_id,const void* c_in);
void luaA_to_typeid(lua_State* L, luaA_Type type_id, void* c_out, int index);
-typedef int (*luaA_Pushfunc)(lua_State*,const void*);
-typedef void (*luaA_Tofunc)(lua_State*, void*, int);
-
#define luaA_conversion(type, push_func, to_func) luaA_conversion_typeid(luaA_type_id(type), push_func, to_func);
#define luaA_conversion_push(type, func) luaA_conversion_push_typeid(luaA_type_id(type), func)
#define luaA_conversion_to(type, func) luaA_conversion_to_typeid(luaA_type_id(type), func)
@@ -64,39 +66,39 @@ void luaA_conversion_to_typeid(luaA_Type type_id, luaA_Tofunc func);
/* native type stack functions */
-int luaA_push_char(lua_State* L,const void* c_in);
-void luaA_to_char(lua_State* L, void* c_out, int index);
-int luaA_push_signed_char(lua_State* L,const void* c_in);
-void luaA_to_signed_char(lua_State* L, void* c_out, int index);
-int luaA_push_unsigned_char(lua_State* L,const void* c_in);
-void luaA_to_unsigned_char(lua_State* L, void* c_out, int index);
-int luaA_push_short(lua_State* L,const void* c_in);
-void luaA_to_short(lua_State* L, void* c_out, int index);
-int luaA_push_unsigned_short(lua_State* L,const void* c_in);
-void luaA_to_unsigned_short(lua_State* L, void* c_out, int index);
-int luaA_push_int(lua_State* L,const void* c_in);
-void luaA_to_int(lua_State* L, void* c_out, int index);
-int luaA_push_unsigned_int(lua_State* L,const void* c_in);
-void luaA_to_unsigned_int(lua_State* L, void* c_out, int index);
-int luaA_push_long(lua_State* L,const void* c_in);
-void luaA_to_long(lua_State* L, void* c_out, int index);
-int luaA_push_unsigned_long(lua_State* L,const void* c_in);
-void luaA_to_unsigned_long(lua_State* L, void* c_out, int index);
-int luaA_push_long_long(lua_State* L,const void* c_in);
-void luaA_to_long_long(lua_State* L, void* c_out, int index);
-int luaA_push_unsigned_long_long(lua_State* L,const void* c_in);
-void luaA_to_unsigned_long_long(lua_State* L, void* c_out, int index);
-int luaA_push_float(lua_State* L,const void* c_in);
-void luaA_to_float(lua_State* L, void* c_out, int index);
-int luaA_push_double(lua_State* L,const void* c_in);
-void luaA_to_double(lua_State* L, void* c_out, int index);
-int luaA_push_long_double(lua_State* L,const void* c_in);
-void luaA_to_long_double(lua_State* L, void* c_out, int index);
-int luaA_push_char_ptr(lua_State* L,const void* c_in);
-void luaA_to_char_ptr(lua_State* L, void* c_out, int index);
-int luaA_push_const_char_ptr(lua_State* L,const void* c_in);
-void luaA_to_const_char_ptr(lua_State* L, void* c_out, int index);
-int luaA_push_void(lua_State* L,const void* c_in);
+int luaA_push_char(lua_State* L,luaA_Type, const void* c_in);
+void luaA_to_char(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_signed_char(lua_State* L,luaA_Type, const void* c_in);
+void luaA_to_signed_char(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_unsigned_char(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_unsigned_char(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_short(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_short(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_unsigned_short(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_unsigned_short(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_int(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_int(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_unsigned_int(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_unsigned_int(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_long(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_long(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_unsigned_long(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_unsigned_long(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_long_long(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_long_long(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_unsigned_long_long(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_unsigned_long_long(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_float(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_float(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_double(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_double(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_long_double(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_long_double(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_char_ptr(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_char_ptr(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_const_char_ptr(lua_State* L, luaA_Type, const void* c_in);
+void luaA_to_const_char_ptr(lua_State* L, luaA_Type, void* c_out, int index);
+int luaA_push_void(lua_State* L, luaA_Type, const void* c_in);
/*
@@ -108,21 +110,27 @@ void luaA_struct_close(void);
/* push and inspect struct members */
#define luaA_struct_push_member(L, type, cstruct, member) luaA_struct_push_member_offset_typeid(L, luaA_type_id(type), cstruct, offsetof(type, member))
#define luaA_struct_push_member_name(L, type, cstruct, member) luaA_struct_push_member_name_typeid(L, luaA_type_id(type), cstruct, member)
+int luaA_struct_push_member_offset_typeid(lua_State* L, luaA_Type type,const void* cstruct, size_t offset);
+int luaA_struct_push_member_name_typeid(lua_State* L, luaA_Type type,const void* cstruct, const char* member);
#define luaA_struct_to_member(L, type, cstruct, member, index) luaA_struct_to_member_offset_typeid(L, luaA_type_id(type), cstruct, offsetof(type, member), index)
#define luaA_struct_to_member_name(L, type, cstruct, member, index) luaA_struct_to_member_name_typeid(L, luaA_type_id(type), cstruct, member, index)
+void luaA_struct_to_member_offset_typeid(lua_State* L, luaA_Type type, void* cstruct, size_t offset, int index);
+void luaA_struct_to_member_name_typeid(lua_State* L, luaA_Type type, void* cstruct, const char* member, int index);
#define luaA_struct_has_member(L, type, member) luaA_struct_has_member_offset_typeid(L, luaA_type_id(type), offsetof(type, member))
#define luaA_struct_has_member_name(L, type, member) luaA_struct_has_member_name_typeid(L, luaA_type_id(type), member)
+bool luaA_struct_has_member_offset_typeid(lua_State* L, luaA_Type type, size_t offset);
+bool luaA_struct_has_member_name_typeid(lua_State* L, luaA_Type type, const char* member);
-int luaA_struct_push_member_offset_typeid(lua_State* L, luaA_Type type, const void* cstruct, size_t offset);
-int luaA_struct_push_member_name_typeid(lua_State* L, luaA_Type type, const void* cstruct, const char* member);
-
-void luaA_struct_to_member_offset_typeid(lua_State* L, luaA_Type type, void* cstruct, size_t offset, int index);
-void luaA_struct_to_member_name_typeid(lua_State* L, luaA_Type type, void* cstruct, const char* member, int index);
+#define LUAA_INVALID_MEMBER_NAME NULL
+#define luaA_struct_next_member_name(L, type, member) luaA_struct_next_member_name_typeid(L, luaA_type_id(type), member)
+const char* luaA_struct_next_member_name_typeid(lua_State* L, luaA_Type type, const char* member);
-bool luaA_struct_has_member_offset_typeid(lua_State* L, luaA_Type type, size_t offset);
-bool luaA_struct_has_member_name_typeid(lua_State* L, luaA_Type type, const char* member);
+#define luaA_struct_typeof_member(L, type, member) luaA_struct_typeof_member_offset_typeid(L, luaA_type_id(type), offsetof(type, member))
+#define luaA_struct_typeof_member_name(L, type, member) luaA_struct_typeof_member_name_typeid(L, luaA_type_id(type), member)
+luaA_Type luaA_struct_typeof_member_offset_typeid(lua_State* L, luaA_Type type, size_t offset);
+luaA_Type luaA_struct_typeof_member_name_typeid(lua_State* L, luaA_Type type, const char* member);
/* register structs */
#define luaA_struct(L, type) luaA_struct_typeid(L, luaA_type_id(type))
View
@@ -135,7 +135,7 @@ int luaA_call_name(lua_State* L, const char* func_name) {
return 0;
}
-void luaA_function_typeid(lua_State* L, void* src_func, luaA_Func auto_func, char* name, luaA_Type ret_t, int num_args, ...) {
+void luaA_function_typeid(lua_State* L, void* src_func, luaA_Func auto_func, const char* name, luaA_Type ret_t, int num_args, ...) {
if (num_args >= MAX_ARG_NUM) {
lua_pushfstring(L, "luaA_func_add: Function has %i arguments - maximum supported is %i!", num_args, MAX_ARG_NUM);
Oops, something went wrong.

0 comments on commit f9c09ad

Please sign in to comment.