@@ -22,20 +22,20 @@ DESPITE BEING 100% COVERED BY TESTS, THIS LIBRARY IS NOT CONSIDERED PRODUCTION R
2222
2323### Instalation
2424Like all Oui librarys, the LuaCEmbed addopt the ideia of single file lib, so you just need to copy the ** LuaCEmbed.h** file
25- into your project, and compile with gcc/clang
25+ into your project, and compile with gcc/clang
2626
2727~~~ c
2828#include " LuaCEmbed.h"
2929LuaCEmbedNamespace lua_n;
3030
3131int main (int argc, char * argv[ ] ){
32-
32+
3333 lua_n = newLuaCEmbedNamespace();
3434 LuaCEmbed * l = lua_n.newLuaEvaluation();
3535 lua_n.evaluate(l,"r = 30");
3636 long calc = lua_n.get_evaluation_long(l,"r + 20");
3737 printf("result %ld",calc);
38-
38+
3939 if(lua_n.has_errors(l)){
4040 printf("error: %s\n",lua_n.get_error_message(l));
4141 }
@@ -55,9 +55,9 @@ result 50
5555
5656### Runting Native functions
5757<h3 style =" color :red ;" >
58- NEVER CALL THE FUNCTION 'load_native_libs' IF YOU DON TRUST IN THE USER
58+ NEVER CALL THE FUNCTION 'load_native_libs' IF YOU DON TRUST IN THE USER
5959</h3 >
60- You can load native lua functions by the usage of ** load_native_libs** function
60+ You can load native lua functions by the usage of ** load_native_libs** function
6161
6262
6363~~~ c
@@ -121,26 +121,27 @@ LuaCEmbedResponse *sub_cfunc(LuaCEmbed *args){
121121 double result = first_num - second_num;
122122 return lua_n.response.send_double(result);
123123}
124+
124125int luaopen_my_lib(lua_State * state){
125126 lua_n = newLuaCEmbedNamespace();
126- //functions will be only assescible by the required reciver
127127 LuaCEmbed * l = lua_n.newLuaLib(state);
128128 lua_n.add_callback(l,"add",add_cfunc);
129129 lua_n.add_callback(l,"sub",sub_cfunc);
130130
131- return lua_n.perform(l);
132-
131+ return lua_n.send_self_as_lib(l);
133132}
133+
134+
134135~~~
135136Compile the code with:
136137~~~shell
137- gcc -Wall -shared -fpic -o my_lib.so main.c
138+ gcc -Wall -shared -fpic -o my_lib.so main.c
138139~~~
139140
140141
141142than you can call into your lua code
142143
143- ~~~ lua
144+ ~~~ lua
144145
145146local lib = require (" my_lib" )
146147
@@ -152,7 +153,7 @@ print("y",y)
152153~~~
153154### Lib Props
154155you can determine library props into your lib:
155- ~~~ c
156+ ~~~ c
156157
157158
158159#include " LuaCEmbed.h"
@@ -181,7 +182,7 @@ int luaopen_my_lib(lua_State *state){
181182
182183testing with lua:
183184
184- ~~~lua
185+ ~~~lua
185186
186187lib = require("my_lib")
187188print("long_prop",lib.long_prop)
@@ -1010,7 +1011,7 @@ int main(int argc, char *argv[]){
10101011 printf("error: %s\n",lua_n.get_error_message(l));
10111012 }
10121013 printf("resullt :%ld\n",result);
1013-
1014+
10141015 lua_n.free(l);
10151016
10161017 return 0;
@@ -1051,7 +1052,7 @@ int main(int argc, char *argv[]){
10511052 printf("error: %s\n",lua_n.get_error_message(l));
10521053 }
10531054 printf("resullt :%lf\n",result);
1054-
1055+
10551056 lua_n.free(l);
10561057
10571058 return 0;
@@ -1092,7 +1093,7 @@ int main(int argc, char *argv[]){
10921093 printf("error: %s\n",lua_n.get_error_message(l));
10931094 }
10941095 printf("resullt :%s\n",result);
1095-
1096+
10961097 lua_n.free(l);
10971098
10981099 return 0;
@@ -1133,7 +1134,7 @@ int main(int argc, char *argv[]){
11331134 printf("error: %s\n",lua_n.get_error_message(l));
11341135 }
11351136 printf("resullt :%d\n",result);
1136-
1137+
11371138 lua_n.free(l);
11381139
11391140 return 0;
@@ -1178,7 +1179,7 @@ int main(int argc, char *argv[]){
11781179 }
11791180
11801181 printf("value of created.a = %s\n",a);
1181-
1182+
11821183 lua_n.free(l);
11831184
11841185 return 0;
@@ -1380,7 +1381,7 @@ LuaCEmbedResponse * show_table(LuaCEmbed *args){
13801381
13811382 printf("------------------------------------------\n");
13821383 }
1383-
1384+
13841385 return NULL;
13851386
13861387}
@@ -2262,4 +2263,3 @@ It will produce
22622263result of r.a internal text
22632264
22642265~~~
2265-
0 commit comments