Commit 2650bc21 authored by David Milligan's avatar David Milligan
Browse files

lua.mo: move each lua API library to a separate file

--HG--
branch : lua
parent 05d0bc267e89
......@@ -7,10 +7,11 @@ LUA_SRC=lua
CORE_O= $(LUA_SRC)/lapi.o $(LUA_SRC)/lcode.o $(LUA_SRC)/lctype.o $(LUA_SRC)/ldebug.o $(LUA_SRC)/ldo.o $(LUA_SRC)/ldump.o $(LUA_SRC)/lfunc.o $(LUA_SRC)/lgc.o $(LUA_SRC)/llex.o $(LUA_SRC)/lmem.o $(LUA_SRC)/lobject.o $(LUA_SRC)/lopcodes.o $(LUA_SRC)/lparser.o $(LUA_SRC)/lstate.o $(LUA_SRC)/lstring.o $(LUA_SRC)/ltable.o $(LUA_SRC)/ltm.o $(LUA_SRC)/lundump.o $(LUA_SRC)/lvm.o $(LUA_SRC)/lzio.o
LIB_O= $(LUA_SRC)/lauxlib.o $(LUA_SRC)/lbaselib.o $(LUA_SRC)/lbitlib.o $(LUA_SRC)/lcorolib.o $(LUA_SRC)/ldblib.o $(LUA_SRC)/liolib.o $(LUA_SRC)/lmathlib.o $(LUA_SRC)/lstrlib.o $(LUA_SRC)/ltablib.o $(LUA_SRC)/lutf8lib.o $(LUA_SRC)/loadlib.o $(LUA_SRC)/linit.o
LUA_LIB_O= lua_console.o lua_camera.o lua_lv.o lua_lens.o lua_movie.o lua_display.o lua_key.o lua_menu.o lua_constants.o
# define the module name - make sure name is max 8 characters
MODULE_NAME=lua
MODULE_OBJS=$(LUA_SRC)/ml-lua-shim.o $(CORE_O) $(LIB_O) lua.o
MODULE_OBJS=$(LUA_SRC)/ml-lua-shim.o $(CORE_O) $(LIB_O) $(LUA_LIB_O) lua.o
MODULE_CFLAGS += -DLUA_32BITS
# include modules environment
......
This diff is collapsed.
#include <dryos.h>
#include <string.h>
#include <lens.h>
#include <shoot.h>
#include "lua_common.h"
static int luaCB_camera_index(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "shutter")) lua_pushinteger(L, RAW2TV(lens_info.raw_shutter));
else if(!strcmp(key, "aperture")) lua_pushinteger(L, RAW2AV(lens_info.raw_aperture));
else if(!strcmp(key, "iso")) lua_pushinteger(L, RAW2SV(lens_info.raw_iso));
else if(!strcmp(key, "ec")) lua_pushinteger(L, RAW2EC(lens_info.ae));
else if(!strcmp(key, "flash_ec")) lua_pushinteger(L, RAW2EC(lens_info.flash_ae));
else if(!strcmp(key, "mode")) lua_pushinteger(L, shooting_mode);
else if(!strcmp(key, "af_mode")) lua_pushinteger(L, af_mode);
else if(!strcmp(key, "metering_mode")) lua_pushinteger(L, metering_mode);
else if(!strcmp(key, "drive_mode")) lua_pushinteger(L, drive_mode);
else if(!strcmp(key, "model")) lua_pushstring(L, camera_model);
else if(!strcmp(key, "model_short")) lua_pushstring(L, __camera_model_short);
else if(!strcmp(key, "firmware")) lua_pushstring(L, firmware_version);
else if(!strcmp(key, "temperature")) lua_pushinteger(L, efic_temp);
else if(!strcmp(key, "state")) lua_pushinteger(L, gui_state);
else lua_rawget(L, 1);
return 1;
}
static int luaCB_camera_newindex(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "shutter"))
{
LUA_PARAM_INT(value, 3);
lens_set_rawshutter(TV2RAW(value));
}
else if(!strcmp(key, "aperture"))
{
LUA_PARAM_INT(value, 3);
lens_set_rawaperture(AV2RAW(value));
}
else if(!strcmp(key, "iso"))
{
LUA_PARAM_NUMBER(value, 3);
lens_set_rawiso(SV2RAW(value));
}
else if(!strcmp(key, "ec"))
{
LUA_PARAM_NUMBER(value, 3);
lens_set_ae(EC2RAW(value));
}
else if(!strcmp(key, "flash_ec"))
{
LUA_PARAM_NUMBER(value, 3);
lens_set_flash_ae(EC2RAW(value));
}
else if(!strcmp(key, "model") || !strcmp(key, "firmware") || !strcmp(key, "mode") || !strcmp(key, "af_mode") || !strcmp(key, "metering_mode") || !strcmp(key, "drive_mode") || !strcmp(key, "temperature") || !strcmp(key, "state"))
{
return luaL_error(L, "'%s' is readonly!", key);
}
else
{
lua_rawset(L, 1);
}
return 0;
}
static int luaCB_camera_shoot(lua_State * L)
{
LUA_PARAM_INT_OPTIONAL(wait, 1, 64);
LUA_PARAM_INT_OPTIONAL(should_af, 2, 1);
int result = lens_take_picture(wait, should_af);
lua_pushinteger(L, result);
return 1;
}
static int luaCB_camera_bulb(lua_State * L)
{
LUA_PARAM_INT(duration, 1);
bulb_take_pic(duration);
return 0;
}
static const luaL_Reg cameralib[] =
{
{ "shoot", luaCB_camera_shoot },
{ "bulb", luaCB_camera_bulb },
{ NULL, NULL }
};
LUA_LIB(camera)
/*
* Copyright (C) 2014 David Milligan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _lua_common_h
#define _lua_common_h
#include "lua/lauxlib.h"
#include "lua/lua.h"
#include "lua/lualib.h"
#define MAX_PATH_LEN 0x80
#define SCRIPTS_DIR "ML/SCRIPTS"
#define EC2RAW(ec) ec * 8 / 10
#define CBR_RET_KEYPRESS_NOTHANDLED 1
#define CBR_RET_KEYPRESS_HANDLED 0
//#define CONFIG_VSYNC_EVENTS
#define LUA_PARAM_INT(name, index)\
if(index > lua_gettop(L) || !lua_isinteger(L, index)) return luaL_argerror(L, index, "expected integer for param '" #name "'");\
int name = lua_tointeger(L, index)
#define LUA_PARAM_INT_OPTIONAL(name, index, default) int name = (index <= lua_gettop(L) && lua_isinteger(L, index)) ? lua_tointeger(L, index) : default
#define LUA_PARAM_BOOL(name, index)\
if(index > lua_gettop(L) || !lua_isboolean(L, index)) return luaL_argerror(L, index, "expected boolean for param '" #name "'");\
int name = lua_toboolean(L, index)
#define LUA_PARAM_BOOL_OPTIONAL(name, index, default) int name = (index <= lua_gettop(L) && lua_isboolean(L, index)) ? lua_toboolean(L, index) : default
#define LUA_PARAM_NUMBER(name, index)\
if(index > lua_gettop(L) || !lua_isnumber(L, index)) return luaL_argerror(L, index, "expected number for param '" #name "'");\
float name = lua_tonumber(L, index)
#define LUA_PARAM_NUMBER_OPTIONAL(name, index, default) float name = (index <= lua_gettop(L) && lua_isnumber(L, index)) ? lua_tonumber(L, index) : default
#define LUA_PARAM_STRING(name, index)\
if(index > lua_gettop(L) || !lua_isstring(L, index)) return luaL_argerror(L, index, "expected string for param '" #name "'");\
const char * name = lua_tostring(L, index)
#define LUA_PARAM_STRING_OPTIONAL(name, index, default) const char * name = (index <= lua_gettop(L) && lua_isstring(L, index)) ? lua_tostring(L, index) : default
#define LUA_FIELD_STRING(field, default) lua_getfield(L, -1, field) == LUA_TSTRING ? lua_tostring(L, -1) : default; lua_pop(L, 1)
#define LUA_FIELD_INT(field, default) lua_getfield(L, -1, field) == LUA_TNUMBER ? lua_tointeger(L, -1) : default; lua_pop(L, 1)
#define LUA_CONSTANT(name, value) lua_pushinteger(L, value); lua_setfield(L, -2, #name)
#define LUA_LIB(name)\
int luaopen_##name(lua_State * L) {\
lua_newtable(L);\
luaL_setfuncs(L, name##lib, 0);\
lua_newtable(L);\
lua_pushcfunction(L, luaCB_##name##_index);\
lua_setfield(L, -2, "__index");\
lua_pushcfunction(L, luaCB_##name##_newindex);\
lua_setfield(L, -2, "__newindex");\
lua_setmetatable(L, -2);\
return 1;\
}
struct script_menu_entry
{
int menu_value;
lua_State * L;
struct menu_entry * menu_entry;
int select_ref;
int update_ref;
int warning_ref;
int info_ref;
int submenu_ref;
};
int docall(lua_State *L, int narg, int nres);
int luaopen_console(lua_State * L);
int luaopen_camera(lua_State * L);
int luaopen_lv(lua_State * L);
int luaopen_lens(lua_State * L);
int luaopen_movie(lua_State * L);
int luaopen_display(lua_State * L);
int luaopen_key(lua_State * L);
int luaopen_menu(lua_State * L);
int luaopen_MODE(lua_State * L);
int luaopen_ICON_TYPE(lua_State * L);
int luaopen_UNIT(lua_State * L);
int luaopen_DEPENDS_ON(lua_State * L);
int luaopen_FONT(lua_State * L);
int luaopen_COLOR(lua_State * L);
int luaopen_KEY(lua_State * L);
#endif
#include <dryos.h>
#include <string.h>
#include <console.h>
#include "lua_common.h"
static int luaCB_console_show(lua_State * L)
{
console_show();
return 0;
}
static int luaCB_console_hide(lua_State * L)
{
console_hide();
return 0;
}
static int luaCB_console_write(lua_State * L)
{
if(lua_isstring(L, 1)) console_puts(lua_tostring(L, 1));
return 0;
}
static int luaCB_console_index(lua_State * L) { lua_rawget(L, 1); return 1; }
static int luaCB_console_newindex(lua_State * L) { lua_rawset(L, 1); return 0; }
static const luaL_Reg consolelib[] =
{
{ "show", luaCB_console_show },
{ "hide", luaCB_console_hide },
{ "write", luaCB_console_write },
{ NULL, NULL }
};
LUA_LIB(console)
\ No newline at end of file
#include <dryos.h>
#include <bmp.h>
#include <menu.h>
#include <property.h>
#include "lua_common.h"
int luaopen_MODE(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(P, SHOOTMODE_P);
LUA_CONSTANT(TV, SHOOTMODE_TV);
LUA_CONSTANT(AV, SHOOTMODE_AV);
LUA_CONSTANT(M, SHOOTMODE_M);
LUA_CONSTANT(BULB, SHOOTMODE_BULB);
LUA_CONSTANT(ADEP, SHOOTMODE_ADEP);
LUA_CONSTANT(C, SHOOTMODE_C);
LUA_CONSTANT(C2, SHOOTMODE_C2);
LUA_CONSTANT(C3, SHOOTMODE_C3);
LUA_CONSTANT(CA, SHOOTMODE_CA);
LUA_CONSTANT(AUTO, SHOOTMODE_AUTO);
LUA_CONSTANT(NOFLASH, SHOOTMODE_NOFLASH);
LUA_CONSTANT(PORTRAIT, SHOOTMODE_PORTRAIT);
LUA_CONSTANT(LANDSCAPE, SHOOTMODE_LANDSCAPE);
LUA_CONSTANT(MACRO, SHOOTMODE_MACRO);
LUA_CONSTANT(SPORTS, SHOOTMODE_SPORTS);
LUA_CONSTANT(NIGHT, SHOOTMODE_NIGHT);
LUA_CONSTANT(MOVIE, SHOOTMODE_MOVIE);
return 1;
}
int luaopen_ICON_TYPE(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(AUTO, IT_AUTO);
LUA_CONSTANT(BOOL, IT_BOOL);
LUA_CONSTANT(DICE, IT_DICE);
LUA_CONSTANT(PERCENT, IT_PERCENT);
LUA_CONSTANT(ALWAYS_ON, IT_ALWAYS_ON);
LUA_CONSTANT(ACTION, IT_ACTION);
LUA_CONSTANT(BOOL_NEG, IT_BOOL_NEG);
LUA_CONSTANT(DISABLE_SOME_FEATURE, IT_DISABLE_SOME_FEATURE);
LUA_CONSTANT(SUBMENU, IT_SUBMENU);
LUA_CONSTANT(DICE_OFF, IT_DICE_OFF);
LUA_CONSTANT(PERCENT_OFF, IT_PERCENT_OFF);
LUA_CONSTANT(PERCENT_LOG, IT_PERCENT_LOG);
LUA_CONSTANT(PERCENT_LOG_OFF, IT_PERCENT_LOG_OFF);
return 1;
}
int luaopen_UNIT(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(EV, UNIT_1_8_EV);
LUA_CONSTANT(x10, UNIT_x10);
LUA_CONSTANT(PERCENT, UNIT_PERCENT);
LUA_CONSTANT(PERCENT_x10, UNIT_PERCENT_x10);
LUA_CONSTANT(ISO, UNIT_ISO);
LUA_CONSTANT(HEX, UNIT_HEX);
LUA_CONSTANT(DEC, UNIT_DEC);
LUA_CONSTANT(TIME, UNIT_TIME);
return 1;
}
int luaopen_DEPENDS_ON(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(GLOBAL_DRAW, DEP_GLOBAL_DRAW);
LUA_CONSTANT(LIVEVIEW, DEP_LIVEVIEW);
LUA_CONSTANT(NOT_LIVEVIEW, DEP_NOT_LIVEVIEW);
LUA_CONSTANT(MOVIE_MODE, DEP_MOVIE_MODE);
LUA_CONSTANT(PHOTO_MODE, DEP_PHOTO_MODE);
LUA_CONSTANT(AUTOFOCUS, DEP_AUTOFOCUS);
LUA_CONSTANT(MANUAL_FOCUS, DEP_MANUAL_FOCUS);
LUA_CONSTANT(CFN_AF_HALFSHUTTER, DEP_CFN_AF_HALFSHUTTER);
LUA_CONSTANT(CFN_AF_BACK_BUTTON, DEP_CFN_AF_BACK_BUTTON);
LUA_CONSTANT(EXPSIM, DEP_EXPSIM);
LUA_CONSTANT(NOT_EXPSIM, DEP_NOT_EXPSIM);
LUA_CONSTANT(CHIPPED_LENS, DEP_CHIPPED_LENS);
LUA_CONSTANT(M_MODE, DEP_M_MODE);
LUA_CONSTANT(MANUAL_ISO, DEP_MANUAL_ISO);
LUA_CONSTANT(SOUND_RECORDING, DEP_SOUND_RECORDING);
LUA_CONSTANT(NOT_SOUND_RECORDING, DEP_NOT_SOUND_RECORDING);
return 1;
}
int luaopen_FONT(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(MONO_12, FONT_MONO_12);
LUA_CONSTANT(MONO_20, FONT_MONO_20);
LUA_CONSTANT(SANS_23, FONT_SANS_23);
LUA_CONSTANT(SANS_28, FONT_SANS_28);
LUA_CONSTANT(SANS_32, FONT_SANS_32);
LUA_CONSTANT(CANON, FONT_CANON);
LUA_CONSTANT(SMALL, FONT_SMALL);
LUA_CONSTANT(MED, FONT_MED);
LUA_CONSTANT(MED_LARGE, FONT_MED_LARGE);
return 1;
}
int luaopen_COLOR(lua_State * L)
{
lua_newtable(L);
LUA_CONSTANT(TRANSPARENT, COLOR_EMPTY);
LUA_CONSTANT(WHITE, COLOR_WHITE);
LUA_CONSTANT(BLACK, COLOR_BLACK);
LUA_CONSTANT(TRANSPARENT_BLACK, COLOR_TRANSPARENT_BLACK);
LUA_CONSTANT(CYAN, COLOR_CYAN);
LUA_CONSTANT(GREEN1, COLOR_GREEN1);
LUA_CONSTANT(GREEN2, COLOR_GREEN2);
LUA_CONSTANT(RED, COLOR_RED);
LUA_CONSTANT(LIGHT_BLUE, COLOR_LIGHT_BLUE);
LUA_CONSTANT(BLUE, COLOR_BLUE);
LUA_CONSTANT(DARK_RED, COLOR_DARK_RED);
LUA_CONSTANT(MAGENTA, COLOR_MAGENTA);
LUA_CONSTANT(YELLOW, COLOR_YELLOW);
LUA_CONSTANT(ORANGE, COLOR_ORANGE);
LUA_CONSTANT(ALMOST_BLACK, COLOR_ALMOST_BLACK);
LUA_CONSTANT(ALMOST_WHITE, COLOR_ALMOST_WHITE);
LUA_CONSTANT(DARK_GREEN1_MOD, COLOR_DARK_GREEN1_MOD);
LUA_CONSTANT(DARK_GREEN2_MOD, COLOR_DARK_GREEN2_MOD);
LUA_CONSTANT(DARK_ORANGE_MOD, COLOR_DARK_ORANGE_MOD);
LUA_CONSTANT(DARK_CYAN1_MOD, COLOR_DARK_CYAN1_MOD);
LUA_CONSTANT(DARK_CYAN2_MOD, COLOR_DARK_CYAN2_MOD);
return 1;
}
\ No newline at end of file
#include <dryos.h>
#include <string.h>
#include <bmp.h>
#include <zebra.h>
#include <screenshot.h>
#include "lua_common.h"
static int luaCB_display_on(lua_State * L)
{
display_on();
return 0;
}
static int luaCB_display_off(lua_State * L)
{
display_off();
return 0;
}
static int luaCB_display_screenshot(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(filename, 1, SCREENSHOT_FILENAME_AUTO);
LUA_PARAM_INT_OPTIONAL(mode, 2, SCREENSHOT_BMP | SCREENSHOT_YUV);
take_screenshot((char*)filename, mode);
return 0;
}
static int luaCB_display_clear(lua_State * L)
{
clrscr();
return 0;
}
static int luaCB_display_print(lua_State * L)
{
LUA_PARAM_STRING(str, 1);
LUA_PARAM_INT(x, 2);
LUA_PARAM_INT(y, 3);
LUA_PARAM_INT_OPTIONAL(font, 4, (int)FONT_MED);
LUA_PARAM_INT_OPTIONAL(fg, 5, COLOR_WHITE);
LUA_PARAM_INT_OPTIONAL(bg, 6, COLOR_BLACK);
bmp_printf(FONT(font, fg, bg), x, y, "%s", str);
return 0;
}
static int luaCB_display_pixel(lua_State * L)
{
LUA_PARAM_INT(x, 1);
LUA_PARAM_INT(y, 2);
LUA_PARAM_INT(color, 3);
bmp_putpixel(x, y, (uint8_t)color);
return 0;
}
static int luaCB_display_line(lua_State * L)
{
LUA_PARAM_INT(x1, 1);
LUA_PARAM_INT(y1, 2);
LUA_PARAM_INT(x2, 3);
LUA_PARAM_INT(y2, 4);
LUA_PARAM_INT(color, 5);
draw_line(x1, y1, x2, y2, (uint8_t)color);
return 0;
}
static int luaCB_display_rect(lua_State * L)
{
LUA_PARAM_INT(x, 1);
LUA_PARAM_INT(y, 2);
LUA_PARAM_INT(w, 3);
LUA_PARAM_INT(h, 4);
LUA_PARAM_INT(stroke, 5);
LUA_PARAM_INT_OPTIONAL(fill, 6, -1);
if(fill >= 0) bmp_fill((uint8_t)fill, x, y, w, h);
if(stroke >= 0) bmp_draw_rect((uint8_t)stroke, x, y, w, h);
return 0;
}
static int luaCB_display_circle(lua_State * L)
{
LUA_PARAM_INT(x, 1);
LUA_PARAM_INT(y, 2);
LUA_PARAM_INT(r, 3);
LUA_PARAM_INT(stroke, 4);
LUA_PARAM_INT_OPTIONAL(fill, 5, -1);
if(fill >= 0) fill_circle(x, y, r, (uint8_t)fill);
if(stroke >= 0) draw_circle(x, y, r, (uint8_t)stroke);
return 0;
}
static int luaCB_display_index(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "idle")) lua_pushboolean(L, display_idle());
else lua_rawget(L, 1);
return 1;
}
static int luaCB_display_newindex(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "idle"))
{
return luaL_error(L, "'%s' is readonly!", key);
}
else
{
lua_rawset(L, 1);
}
return 0;
}
const luaL_Reg displaylib[] =
{
{"on", luaCB_display_on},
{"off", luaCB_display_off},
{"screenshot", luaCB_display_screenshot},
{"clear", luaCB_display_clear},
{"print", luaCB_display_print},
{"pixel", luaCB_display_pixel},
{"line", luaCB_display_line},
{"rect", luaCB_display_rect},
{"circle", luaCB_display_circle},
{NULL, NULL}
};
LUA_LIB(display);
\ No newline at end of file
#include <dryos.h>
#include <string.h>
#include "lua_common.h"
extern int last_keypress;
int module_send_keypress(int module_key);
static int luaCB_key_press(lua_State * L)
{
LUA_PARAM_INT(key, 1);
module_send_keypress(key);
return 0;
}
static int luaCB_key_wait(lua_State * L)
{
LUA_PARAM_INT_OPTIONAL(key, 1, 0);
LUA_PARAM_INT_OPTIONAL(timeout, 1, 0);
timeout *= 10;
last_keypress = 0;
int time = 0;
//TODO: probably better to use a semaphore
while((key && last_keypress != key) || (!key && !last_keypress))
{
msleep(100);
if(timeout && time++ > timeout)
{
lua_pushinteger(L, 0);
return 1;
}
}
lua_pushinteger(L, last_keypress);
return 1;
}
static int luaCB_key_index(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "last")) lua_pushinteger(L, last_keypress);
else lua_rawget(L, 1);
return 1;
}
static int luaCB_key_newindex(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "last"))
{
return luaL_error(L, "'%s' is readonly!", key);
}
else
{
lua_rawset(L, 1);
}
return 0;
}
const luaL_Reg keylib[] =
{
{"press", luaCB_key_press},
{"wait", luaCB_key_wait},
{NULL, NULL}
};
LUA_LIB(key)
#include <dryos.h>
#include <string.h>
#include <lens.h>
#include <focus.h>
#include "lua_common.h"
static int luaCB_lens_index(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "name")) lua_pushstring(L, lens_info.name);
else if(!strcmp(key, "focal_length")) lua_pushinteger(L, lens_info.focal_len);
else if(!strcmp(key, "focal_distance")) lua_pushinteger(L, lens_info.focus_dist);
else if(!strcmp(key, "hyperfocal")) lua_pushinteger(L, lens_info.hyperfocal);
else if(!strcmp(key, "dof_near")) lua_pushinteger(L, lens_info.dof_near);
else if(!strcmp(key, "dof_far")) lua_pushinteger(L, lens_info.dof_far);
else if(!strcmp(key, "af")) lua_pushboolean(L, !is_manual_focus());
else lua_rawget(L, 1);
return 1;
}
static int luaCB_lens_newindex(lua_State * L)
{
LUA_PARAM_STRING_OPTIONAL(key, 2, "");
if(!strcmp(key, "name") || !strcmp(key, "focal_length") || !strcmp(key, "focal_distance") || !strcmp(key, "hyperfocal") || !strcmp(key, "dof_near") || !strcmp(key, "dof_far") || !strcmp(key, "af"))
{