diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/edje/src/lib/edje_lua2.c | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to 'libraries/edje/src/lib/edje_lua2.c')
-rw-r--r-- | libraries/edje/src/lib/edje_lua2.c | 269 |
1 files changed, 253 insertions, 16 deletions
diff --git a/libraries/edje/src/lib/edje_lua2.c b/libraries/edje/src/lib/edje_lua2.c index 2318af9..1d167e9 100644 --- a/libraries/edje/src/lib/edje_lua2.c +++ b/libraries/edje/src/lib/edje_lua2.c | |||
@@ -376,7 +376,7 @@ _elua_gc(lua_State *L) // Stack usage [-0, +0, e] | |||
376 | // nil ~ | 376 | // nil ~ |
377 | 377 | ||
378 | static char * | 378 | static char * |
379 | _elua_push_name(lua_State *L, char *q, int index) // Stack usage [-0, +1, e or m] | 379 | _elua_push_name(lua_State *L, char *q, int idx) // Stack usage [-0, +1, e or m] |
380 | { | 380 | { |
381 | char *p = q; | 381 | char *p = q; |
382 | char temp = '\0'; | 382 | char temp = '\0'; |
@@ -387,8 +387,8 @@ _elua_push_name(lua_State *L, char *q, int index) // Stack usage [-0, +1, e or | |||
387 | q++; | 387 | q++; |
388 | temp = *q; | 388 | temp = *q; |
389 | *q = '\0'; | 389 | *q = '\0'; |
390 | if (index > 0) | 390 | if (idx > 0) |
391 | lua_getfield(L, index, p); // Stack usage [-0, +1, e] | 391 | lua_getfield(L, idx, p); // Stack usage [-0, +1, e] |
392 | else | 392 | else |
393 | lua_pushstring(L, p); // Stack usage [-0, +1, m] | 393 | lua_pushstring(L, p); // Stack usage [-0, +1, m] |
394 | *q = temp; | 394 | *q = temp; |
@@ -614,6 +614,7 @@ static int _elua_echo(lua_State *L); | |||
614 | static int _elua_date(lua_State *L); | 614 | static int _elua_date(lua_State *L); |
615 | static int _elua_looptime(lua_State *L); | 615 | static int _elua_looptime(lua_State *L); |
616 | static int _elua_seconds(lua_State *L); | 616 | static int _elua_seconds(lua_State *L); |
617 | static int _elua_version(lua_State *L); | ||
617 | 618 | ||
618 | static int _elua_objgeom(lua_State *L); | 619 | static int _elua_objgeom(lua_State *L); |
619 | static int _elua_objpos(lua_State *L); | 620 | static int _elua_objpos(lua_State *L); |
@@ -649,6 +650,7 @@ static const struct luaL_reg _elua_edje_funcs [] = | |||
649 | {"date", _elua_date}, // get date in a table | 650 | {"date", _elua_date}, // get date in a table |
650 | {"looptime", _elua_looptime}, // get loop time | 651 | {"looptime", _elua_looptime}, // get loop time |
651 | {"seconds", _elua_seconds}, // get seconds | 652 | {"seconds", _elua_seconds}, // get seconds |
653 | {"version", _elua_version}, // edje version | ||
652 | 654 | ||
653 | // query edje - size, pos | 655 | // query edje - size, pos |
654 | {"geom", _elua_objgeom}, // get while edje object geometry in canvas | 656 | {"geom", _elua_objgeom}, // get while edje object geometry in canvas |
@@ -801,6 +803,25 @@ _elua_seconds(lua_State *L) // Stack usage [-0, +1, -] | |||
801 | return 1; | 803 | return 1; |
802 | } | 804 | } |
803 | 805 | ||
806 | /** | ||
807 | @page luaref | ||
808 | @subsubsection edje_version edje:version() | ||
809 | |||
810 | Retrieves the current edje version number. | ||
811 | |||
812 | @returns A table with these fields: | ||
813 | - integer major: The edje version major number. | ||
814 | - integer minor: The edje version minor number. | ||
815 | |||
816 | @since 1.2.0 | ||
817 | */ | ||
818 | static int | ||
819 | _elua_version(lua_State *L) // Stack usage [-4, +5, em] | ||
820 | { | ||
821 | _elua_ret(L, "%major %minor", EDJE_VERSION_MAJOR, EDJE_VERSION_MINOR); // Stack usage [-4, +5, em] | ||
822 | return 1; | ||
823 | } | ||
824 | |||
804 | //------------- | 825 | //------------- |
805 | /** | 826 | /** |
806 | @page luaref | 827 | @page luaref |
@@ -2936,7 +2957,9 @@ static int _elua_line_xy(lua_State *L) // Stack usage [ | |||
2936 | 2957 | ||
2937 | The lua evas map class includes functions for dealing with evas map objects. | 2958 | The lua evas map class includes functions for dealing with evas map objects. |
2938 | The evas map objects must have been previously created by lua using the lua | 2959 | The evas map objects must have been previously created by lua using the lua |
2939 | map object creation function edje:map(). | 2960 | map object creation function edje:map(). The evas map system is complex, rather |
2961 | than repeat the copious documentation here, please refer to the evas map | ||
2962 | documentation. It has pictures and everything. B-) | ||
2940 | 2963 | ||
2941 | In the following, "map_object" is a place holder for any lua variable that | 2964 | In the following, "map_object" is a place holder for any lua variable that |
2942 | holds a reference to an evas map object. | 2965 | holds a reference to an evas map object. |
@@ -2980,8 +3003,18 @@ static const struct luaL_reg _elua_evas_map_funcs [] = | |||
2980 | 3003 | ||
2981 | /** | 3004 | /** |
2982 | @page luaref | 3005 | @page luaref |
2983 | @subsubsection map_alpha map_object:alpha() | 3006 | @subsubsection map_alpha map_object:alpha(alpha) |
3007 | |||
3008 | Get (and optionally set) the maps alpha mode. | ||
3009 | |||
3010 | Wraps evas_map_alpha_set(). | ||
2984 | 3011 | ||
3012 | @param alpha The alpha mode. | ||
3013 | |||
3014 | Note that the argument is optional, without it this function just queries the | ||
3015 | current value. | ||
3016 | |||
3017 | @return A boolean reflecting the alpha mode. | ||
2985 | 3018 | ||
2986 | @since 1.1.0 | 3019 | @since 1.1.0 |
2987 | */ | 3020 | */ |
@@ -3008,6 +3041,11 @@ _elua_map_alpha(lua_State *L) // Stack usage [ | |||
3008 | @page luaref | 3041 | @page luaref |
3009 | @subsubsection map_clockwise map_object:clockwise() | 3042 | @subsubsection map_clockwise map_object:clockwise() |
3010 | 3043 | ||
3044 | Get the maps clockwise state. | ||
3045 | |||
3046 | Wraps evas_map_util_clockwise_get(). | ||
3047 | |||
3048 | @return A boolean reflecting if the map is clockwise or not. | ||
3011 | 3049 | ||
3012 | @since 1.1.0 | 3050 | @since 1.1.0 |
3013 | */ | 3051 | */ |
@@ -3025,8 +3063,30 @@ _elua_map_clockwise(lua_State *L) // Stack usage [ | |||
3025 | 3063 | ||
3026 | /** | 3064 | /** |
3027 | @page luaref | 3065 | @page luaref |
3028 | @subsubsection map_colour map_object:colour() | 3066 | @subsubsection map_colour map_object:colour(index, r, g, b, a) |
3029 | 3067 | ||
3068 | Gets or sets colour information for the map. There are two variations, with or | ||
3069 | without the index. With the index parameter it gets (and optionally sets) the | ||
3070 | colour of the point the index refers to, without it sets the colour for the | ||
3071 | entire map. | ||
3072 | |||
3073 | Wraps evas_map_point_color_set() or evas_map_util_points_color_set() | ||
3074 | |||
3075 | @param index Which point to change the colour of. | ||
3076 | @param r The new red value. | ||
3077 | @param g The new green value. | ||
3078 | @param b The new blue value. | ||
3079 | @param a The new alpha value. | ||
3080 | |||
3081 | Note that the arguments are optional, without them this function just queries | ||
3082 | the current values. The colour arguments can be separate values, or named | ||
3083 | fields in a table. | ||
3084 | |||
3085 | @return A table with these fields: | ||
3086 | - integer r: The red value. | ||
3087 | - integer g: The green value. | ||
3088 | - integer b: The blue value. | ||
3089 | - integer a: The alpha value. | ||
3030 | 3090 | ||
3031 | @since 1.1.0 | 3091 | @since 1.1.0 |
3032 | */ | 3092 | */ |
@@ -3073,8 +3133,24 @@ _elua_map_colour(lua_State *L) // Stack usage [ | |||
3073 | 3133 | ||
3074 | /** | 3134 | /** |
3075 | @page luaref | 3135 | @page luaref |
3076 | @subsubsection map_coord map_object:coord() | 3136 | @subsubsection map_coord map_object:coord(index, x, y, z) |
3137 | |||
3138 | Gets (and optionally sets) the 3D coordinates of a point on the map. | ||
3139 | |||
3140 | Wraps evas_map_point_coord_set(). | ||
3141 | |||
3142 | @param x The x coordinate of the point. | ||
3143 | @param y The y coordinate of the point. | ||
3144 | @param z The z coordinate of the point. | ||
3145 | |||
3146 | Note that the arguments are optional, without them this function just queries | ||
3147 | the current values. The coordinate arguments can be separate values, or named | ||
3148 | fields in a table. | ||
3077 | 3149 | ||
3150 | @return A table with these fields: | ||
3151 | - integer x: The x coordinate of the point. | ||
3152 | - integer y: The y coordinate of the point. | ||
3153 | - integer z: The z coordinate of the point. | ||
3078 | 3154 | ||
3079 | @since 1.1.0 | 3155 | @since 1.1.0 |
3080 | */ | 3156 | */ |
@@ -3104,8 +3180,21 @@ _elua_map_coord(lua_State *L) // Stack usage [ | |||
3104 | 3180 | ||
3105 | /** | 3181 | /** |
3106 | @page luaref | 3182 | @page luaref |
3107 | @subsubsection map_lighting map_object:lighting() | 3183 | @subsubsection map_lighting map_object:lighting(x, y, z, r, g, b, ar, ag, ab) |
3184 | |||
3185 | Set the 3D lights for the map. The three triplets can be tables. | ||
3108 | 3186 | ||
3187 | Wraps evas_map_util_3d_lighting(). | ||
3188 | |||
3189 | @param x The x coordinate of the light point. | ||
3190 | @param y The y coordinate of the light point. | ||
3191 | @param z The z coordinate of the light point. | ||
3192 | @param r The new red value of the light point. | ||
3193 | @param g The new green value of the light point. | ||
3194 | @param b The new blue value of the light point. | ||
3195 | @param ar The new red value of the ambient light. | ||
3196 | @param ag The new green value of the ambient light. | ||
3197 | @param ab The new blue value of the ambient light. | ||
3109 | 3198 | ||
3110 | @since 1.1.0 | 3199 | @since 1.1.0 |
3111 | */ | 3200 | */ |
@@ -3133,8 +3222,18 @@ _elua_map_lighting(lua_State *L) // Stack usage [ | |||
3133 | 3222 | ||
3134 | /** | 3223 | /** |
3135 | @page luaref | 3224 | @page luaref |
3136 | @subsubsection map_perspective map_object:perspective() | 3225 | @subsubsection map_perspective map_object:perspective(x, y, z, f) |
3226 | |||
3227 | Apply a perspective transform to the map. | ||
3228 | |||
3229 | Wraps evas_map_util_3d_perspective(). | ||
3137 | 3230 | ||
3231 | The arguments can be separate values, or named fields in a table. | ||
3232 | |||
3233 | @param x The perspective distance X coordinate | ||
3234 | @param y The perspective distance Y coordinate | ||
3235 | @param z The "0" z plane value | ||
3236 | @param f The focal distance | ||
3138 | 3237 | ||
3139 | @since 1.1.0 | 3238 | @since 1.1.0 |
3140 | */ | 3239 | */ |
@@ -3156,8 +3255,28 @@ _elua_map_perspective(lua_State *L) // Stack usage [ | |||
3156 | 3255 | ||
3157 | /** | 3256 | /** |
3158 | @page luaref | 3257 | @page luaref |
3159 | @subsubsection map_populate map_object:populate() | 3258 | @subsubsection map_populate map_object:populate(...) |
3259 | |||
3260 | Populate the points in a map, in one of three different methods. | ||
3261 | |||
3262 | 1) Wraps evas_map_util_points_populate_from_object(). | ||
3263 | |||
3264 | @param source An evas object to copy points from. | ||
3265 | |||
3266 | 2) Wraps evas_map_util_paints_populate_from_object_full(). | ||
3267 | |||
3268 | @param source An evas object to copy points from. | ||
3269 | @param z Common Z coordinate hint for all four points. | ||
3160 | 3270 | ||
3271 | 3) Wraps evas_map_util_points_populate_from_geometry(). | ||
3272 | |||
3273 | The first four arguments can be separate values, or named fields in a table. | ||
3274 | |||
3275 | @param x Point X coordinate | ||
3276 | @param y Point Y coordinate | ||
3277 | @param w Width to use to calculate second and third points. | ||
3278 | @param h Height to use to calculate third and fourth points. | ||
3279 | @param z Common Z coordinate hint for all four points. | ||
3161 | 3280 | ||
3162 | @since 1.1.0 | 3281 | @since 1.1.0 |
3163 | */ | 3282 | */ |
@@ -3210,8 +3329,17 @@ _elua_map_populate(lua_State *L) // Stack usage [ | |||
3210 | 3329 | ||
3211 | /** | 3330 | /** |
3212 | @page luaref | 3331 | @page luaref |
3213 | @subsubsection map_rotate map_object:rotate() | 3332 | @subsubsection map_rotate map_object:rotate(degrees, x, y) |
3333 | |||
3334 | Rotate the maps coordinates in 2D. | ||
3214 | 3335 | ||
3336 | Wraps evas_map_util_rotate(). | ||
3337 | |||
3338 | The coordinates can be separate values, or named fields in a table. | ||
3339 | |||
3340 | @param degrees Amount of degrees from 0.0 to 360.0 to rotate. | ||
3341 | @param x Rotation's centre horizontal position. | ||
3342 | @param y Rotation's centre vertical position. | ||
3215 | 3343 | ||
3216 | @since 1.1.0 | 3344 | @since 1.1.0 |
3217 | */ | 3345 | */ |
@@ -3238,8 +3366,21 @@ _elua_map_rotate(lua_State *L) // Stack usage [ | |||
3238 | 3366 | ||
3239 | /** | 3367 | /** |
3240 | @page luaref | 3368 | @page luaref |
3241 | @subsubsection map_rotate3d map_object:rotate3d() | 3369 | @subsubsection map_rotate3d map_object:rotate3d(dx, dy, dz, x, y, z) |
3370 | |||
3371 | Rotate the maps coordinates in 3D. | ||
3242 | 3372 | ||
3373 | Wraps evas_map_util_3d_rotate(). | ||
3374 | |||
3375 | The coordinates can be separate values, or named fields in a table. The same | ||
3376 | with the rotation. | ||
3377 | |||
3378 | @param dx Amount of degrees from 0.0 to 360.0 to rotate around X axis. | ||
3379 | @param dy Amount of degrees from 0.0 to 360.0 to rotate around Y axis. | ||
3380 | @param dz Amount of degrees from 0.0 to 360.0 to rotate around Z axis. | ||
3381 | @param x Rotation's centre horizontal position. | ||
3382 | @param y Rotation's centre vertical position. | ||
3383 | @param z Rotation's centre vertical position. | ||
3243 | 3384 | ||
3244 | @since 1.1.0 | 3385 | @since 1.1.0 |
3245 | */ | 3386 | */ |
@@ -3265,8 +3406,18 @@ _elua_map_rotate3d(lua_State *L) // Stack usage [ | |||
3265 | 3406 | ||
3266 | /** | 3407 | /** |
3267 | @page luaref | 3408 | @page luaref |
3268 | @subsubsection map_smooth map_object:smooth() | 3409 | @subsubsection map_smooth map_object:smooth(smooth) |
3410 | |||
3411 | Get (and optionally set) the maps smooth mode. | ||
3412 | |||
3413 | Wraps evas_map_smooth_set(). | ||
3414 | |||
3415 | @param smooth The smooth mode. | ||
3416 | |||
3417 | Note that the argument is optional, without it this function just queries the | ||
3418 | current value. | ||
3269 | 3419 | ||
3420 | @return A boolean reflecting the smooth mode. | ||
3270 | 3421 | ||
3271 | @since 1.1.0 | 3422 | @since 1.1.0 |
3272 | */ | 3423 | */ |
@@ -3291,8 +3442,23 @@ _elua_map_smooth(lua_State *L) // Stack usage [ | |||
3291 | 3442 | ||
3292 | /** | 3443 | /** |
3293 | @page luaref | 3444 | @page luaref |
3294 | @subsubsection map_uv map_object:uv() | 3445 | @subsubsection map_uv map_object:uv(index, u, v) |
3446 | |||
3447 | Gets (and optionally sets) the texture U and V texture coordinates for this map. | ||
3448 | |||
3449 | Wraps evas_map_point_image_uv_set(). | ||
3450 | |||
3451 | @param index Index of the point to change. Must be smaller than map size. | ||
3452 | @param u The X coordinate within the image/texture source. | ||
3453 | @param v The Y coordinate within the image/texture source. | ||
3454 | |||
3455 | Note that the U,V arguments are optional, without them this function just queries | ||
3456 | the current values. The coordinate arguments can be separate values, or named | ||
3457 | fields in a table. | ||
3295 | 3458 | ||
3459 | @return A table with these fields: | ||
3460 | - number u: The X coordinate within the image/texture source. | ||
3461 | - number v: The Y coordinate within the image/texture source. | ||
3296 | 3462 | ||
3297 | @since 1.1.0 | 3463 | @since 1.1.0 |
3298 | */ | 3464 | */ |
@@ -3322,8 +3488,18 @@ _elua_map_uv(lua_State *L) // Stack usage [ | |||
3322 | 3488 | ||
3323 | /** | 3489 | /** |
3324 | @page luaref | 3490 | @page luaref |
3325 | @subsubsection map_zoom map_object:zoom() | 3491 | @subsubsection map_zoom map_object:zoom(x, y, x, y) |
3492 | |||
3493 | Apply a zoom to the map. | ||
3494 | |||
3495 | Wraps evas_map_util_zoom(). | ||
3326 | 3496 | ||
3497 | The arguments can be two separate values, or named fields in a table. | ||
3498 | |||
3499 | @param x The horizontal zoom amount. | ||
3500 | @param y The vertical zoom amount. | ||
3501 | @param x The X coordinate of the centre of the zoom. | ||
3502 | @param y The Y coordinate of the centre of the zoom. | ||
3327 | 3503 | ||
3328 | @since 1.1.0 | 3504 | @since 1.1.0 |
3329 | */ | 3505 | */ |
@@ -3530,7 +3706,7 @@ _elua_text_font(lua_State *L) // Stack usage [ | |||
3530 | @page luaref | 3706 | @page luaref |
3531 | @subsubsection text_text text_object:text(text) | 3707 | @subsubsection text_text text_object:text(text) |
3532 | 3708 | ||
3533 | Get (and optionally set) the actual tetx for this text object. | 3709 | Get (and optionally set) the actual text for this text object. |
3534 | 3710 | ||
3535 | Wraps evas_object_text_text_set(). | 3711 | Wraps evas_object_text_text_set(). |
3536 | 3712 | ||
@@ -3569,25 +3745,80 @@ _elua_text_text(lua_State *L) // Stack usage [ | |||
3569 | 3745 | ||
3570 | 3746 | ||
3571 | //--------------------------------------------------------------------------// | 3747 | //--------------------------------------------------------------------------// |
3748 | |||
3749 | // A metatable and functions so that calling non existant API does not crash Lua scripts. | ||
3750 | |||
3751 | static int _elua_bogan_nilfunc(lua_State *L); | ||
3752 | static int _elua_bogan_index(lua_State *L); | ||
3753 | |||
3754 | static const struct luaL_reg _elua_bogan_funcs [] = | ||
3755 | { | ||
3756 | {"nilfunc", _elua_bogan_nilfunc}, // Just return a nil. | ||
3757 | {"__index", _elua_bogan_index}, // Return the above func. | ||
3758 | |||
3759 | {NULL, NULL} // end | ||
3760 | }; | ||
3761 | |||
3762 | static int | ||
3763 | _elua_bogan_nilfunc(lua_State *L) | ||
3764 | { | ||
3765 | lua_getglobal(L, "nil"); | ||
3766 | return 1; | ||
3767 | } | ||
3768 | |||
3769 | static int | ||
3770 | _elua_bogan_index(lua_State *L) | ||
3771 | { | ||
3772 | const char *key; | ||
3773 | |||
3774 | key = lua_tostring(L, 2); | ||
3775 | LE("%s does not exist!", key); | ||
3776 | lua_pushcfunction(L, _elua_bogan_nilfunc); | ||
3777 | return 1; | ||
3778 | } | ||
3779 | |||
3780 | static void | ||
3781 | _elua_bogan_protect(lua_State *L) // Stack usage [-3, +3, m] | ||
3782 | { | ||
3783 | lua_pushnil(L); // Stack usage [-0, +1, -] | ||
3784 | luaL_newmetatable(L, "bogan"); // Stack usage [-0, +1, m] | ||
3785 | luaL_register(L, 0, _elua_bogan_funcs); // Stack usage [-1, +1, m] | ||
3786 | lua_setmetatable(L, -2); // Stack usage [-1, +0, -] | ||
3787 | lua_pop(L, 1); // Stack usage [-1, +0, -] | ||
3788 | } | ||
3789 | |||
3790 | //--------------------------------------------------------------------------// | ||
3791 | |||
3572 | // Brain dead inheritance thingy, built for speed. Kinda. Part 1. | 3792 | // Brain dead inheritance thingy, built for speed. Kinda. Part 1. |
3573 | static void | 3793 | static void |
3574 | _elua_add_functions(lua_State *L, const char *api, const luaL_Reg *funcs, const char *meta, const char *parent, const char *base) // Stack usage [-3, +5, m] if inheriting [-6, +11, em] | 3794 | _elua_add_functions(lua_State *L, const char *api, const luaL_Reg *funcs, const char *meta, const char *parent, const char *base) // Stack usage [-3, +5, m] if inheriting [-6, +11, em] |
3575 | { | 3795 | { |
3796 | // Create an api table, fill it full of the methods. | ||
3576 | luaL_register(L, api, funcs); // Stack usage [-0, +1, m] | 3797 | luaL_register(L, api, funcs); // Stack usage [-0, +1, m] |
3798 | // Set the api metatable to the bogan metatable. | ||
3799 | luaL_getmetatable(L, "bogan"); // Stack usage [-0, +1, -] | ||
3800 | lua_setmetatable(L, -2); // Stack usage [-1, +0, -] | ||
3801 | // Creat a meta metatable. | ||
3577 | luaL_newmetatable(L, meta); // Stack usage [-0, +1, m] | 3802 | luaL_newmetatable(L, meta); // Stack usage [-0, +1, m] |
3803 | // Put the gc functions in the metatable. | ||
3578 | luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] | 3804 | luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] |
3805 | // Create an __index entry in the metatable, make it point to the api table. | ||
3579 | lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] | 3806 | lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] |
3580 | lua_pushvalue(L, -3); // Stack usage [-0, +1, -] | 3807 | lua_pushvalue(L, -3); // Stack usage [-0, +1, -] |
3581 | lua_rawset(L, -3); // Stack usage [-2, +0, m] | 3808 | lua_rawset(L, -3); // Stack usage [-2, +0, m] |
3809 | // Later this metatable is used as the metatable for newly created objects of this class. | ||
3582 | 3810 | ||
3583 | if (base && parent) | 3811 | if (base && parent) |
3584 | { | 3812 | { |
3585 | // Inherit from base | 3813 | // Inherit from base |
3586 | lua_getglobal(L, base); // Stack usage [-0, +1, e] | 3814 | lua_getglobal(L, base); // Stack usage [-0, +1, e] |
3815 | // Create a new parent metatable. | ||
3587 | luaL_newmetatable(L, parent); // Stack usage [-0, +1, m] | 3816 | luaL_newmetatable(L, parent); // Stack usage [-0, +1, m] |
3817 | // Create an __index entry in the metatable, make it point to the base table. | ||
3588 | lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] | 3818 | lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] |
3589 | lua_pushvalue(L, -3); // Stack usage [-0, +1, -] | 3819 | lua_pushvalue(L, -3); // Stack usage [-0, +1, -] |
3590 | lua_rawset(L, -3); // Stack usage [-2, +0, m] | 3820 | lua_rawset(L, -3); // Stack usage [-2, +0, m] |
3821 | // Set the metatable for the api table to the parent metatable. | ||
3591 | lua_getglobal(L, api); // Stack usage [-0, +1, e] | 3822 | lua_getglobal(L, api); // Stack usage [-0, +1, e] |
3592 | luaL_getmetatable(L, parent); // Stack usage [-0, +1, -] | 3823 | luaL_getmetatable(L, parent); // Stack usage [-0, +1, -] |
3593 | lua_setmetatable(L, -2); // Stack usage [-1, +0, -] | 3824 | lua_setmetatable(L, -2); // Stack usage [-1, +0, -] |
@@ -3695,7 +3926,11 @@ _edje_lua2_script_init(Edje *ed) // Stack usage | |||
3695 | lua_call(L, 1, 0); // Stack usage [-2, +0, m] | 3926 | lua_call(L, 1, 0); // Stack usage [-2, +0, m] |
3696 | } | 3927 | } |
3697 | 3928 | ||
3929 | _elua_bogan_protect(L); // Stack usage [+3, -3, m] | ||
3930 | |||
3698 | luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m] | 3931 | luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m] |
3932 | luaL_getmetatable(L, "bogan"); // Stack usage [-0, +1, -] | ||
3933 | lua_setmetatable(L, -2); // Stack usage [-1, +0, -] | ||
3699 | luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m] | 3934 | luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m] |
3700 | luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] | 3935 | luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] |
3701 | 3936 | ||
@@ -3737,6 +3972,8 @@ _edje_lua2_script_init(Edje *ed) // Stack usage | |||
3737 | { | 3972 | { |
3738 | int err; | 3973 | int err; |
3739 | 3974 | ||
3975 | /* This ends up pushing a function onto the stack for the lua_pcall() below to use. | ||
3976 | * The function is the compiled code. */ | ||
3740 | err = luaL_loadbuffer(L, data, size, "edje_lua_script"); // Stack usage [-0, +1, m] | 3977 | err = luaL_loadbuffer(L, data, size, "edje_lua_script"); // Stack usage [-0, +1, m] |
3741 | if (err) | 3978 | if (err) |
3742 | { | 3979 | { |