void RegisterEntityLib(lua_State* ls) { luaL_register( ls, "Entity", functions ); }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ int Open_LuaSD( vlc_object_t *p_this ) { services_discovery_t *p_sd = ( services_discovery_t * )p_this; services_discovery_sys_t *p_sys; lua_State *L = NULL; char *psz_name; if( !strcmp( p_sd->psz_name, "lua" ) ) { // We want to load the module name "lua" // This module can be used to load lua script not registered // as builtin lua SD modules. config_ChainParse( p_sd, "lua-", ppsz_sd_options, p_sd->p_cfg ); psz_name = var_GetString( p_sd, "lua-sd" ); } else { // We are loading a builtin lua sd module. psz_name = strdup(p_sd->psz_name); } if( !( p_sys = malloc( sizeof( services_discovery_sys_t ) ) ) ) { free( psz_name ); return VLC_ENOMEM; } p_sd->p_sys = p_sys; p_sd->pf_control = Control; p_sys->psz_filename = vlclua_find_file( "sd", psz_name ); if( !p_sys->psz_filename ) { msg_Err( p_sd, "Couldn't find lua services discovery script \"%s\".", psz_name ); free( psz_name ); goto error; } free( psz_name ); L = luaL_newstate(); if( !L ) { msg_Err( p_sd, "Could not create new Lua State" ); goto error; } vlclua_set_this( L, p_sd ); luaL_openlibs( L ); luaL_register( L, "vlc", p_reg ); luaopen_input( L ); luaopen_msg( L ); luaopen_object( L ); luaopen_sd_sd( L ); luaopen_strings( L ); luaopen_variables( L ); luaopen_stream( L ); luaopen_gettext( L ); luaopen_xml( L ); lua_pop( L, 1 ); if( vlclua_add_modules_path( L, p_sys->psz_filename ) ) { msg_Warn( p_sd, "Error while setting the module search path for %s", p_sys->psz_filename ); goto error; } if( luaL_dofile( L, p_sys->psz_filename ) ) { msg_Err( p_sd, "Error loading script %s: %s", p_sys->psz_filename, lua_tostring( L, lua_gettop( L ) ) ); lua_pop( L, 1 ); goto error; } p_sys->L = L; vlc_mutex_init( &p_sys->lock ); vlc_cond_init( &p_sys->cond ); TAB_INIT( p_sys->i_query, p_sys->ppsz_query ); if( vlc_clone( &p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW ) ) { TAB_CLEAN( p_sys->i_query, p_sys->ppsz_query ); vlc_cond_destroy( &p_sys->cond ); vlc_mutex_destroy( &p_sys->lock ); goto error; } return VLC_SUCCESS; error: if( L ) lua_close( L ); free( p_sys->psz_filename ); free( p_sys ); return VLC_EGENERIC; }
void nixio_open_io(lua_State *L) { lua_pushvalue(L, -2); luaL_register(L, NULL, M); lua_pop(L, 1); }
void luaopen_misc( lua_State *L ) { lua_newtable( L ); luaL_register( L, NULL, vlclua_misc_reg ); lua_setfield( L, -2, "misc" ); }
DECL_IMPORT void agent_platform_core_event_init(lua_State *L) { luaL_register(L, "agent.platform.core", R); }
LUALIB_API int luaopen_os (lua_State *L) { luaL_register(L, LUA_OSLIBNAME, syslib); return 1; }
// Initialize the library int luaopen_fastimage(lua_State * L) { luaL_register(L, "fastimage", lua_functions); return 1; }
int luaopen_gslib(lua_State* L) { const char* libName = "gslib"; luaL_register(L, libName, fun_list); return 1; }
LUALIB_API int luaopen_debug (lua_State *L) { luaL_register(L, LUA_DBLIBNAME, dblib); return 1; }
static void init_chunkqueue_mt(lua_State *L) { luaL_register(L, NULL, chunkqueue_mt); }
int luaopen_libsmrdist(lua_State * L) { luaL_register(L, "libsmrdist", smrdist); return 1; }
//----------------------------------------------------------------// void MOAISim::RegisterLuaClass ( MOAILuaState& state ) { MOAIGlobalEventSource::RegisterLuaClass ( state ); state.SetField ( -1, "EVENT_FINALIZE", ( u32 )EVENT_FINALIZE ); state.SetField ( -1, "EVENT_PAUSE", ( u32 )EVENT_PAUSE ); state.SetField ( -1, "EVENT_RESUME", ( u32 )EVENT_RESUME ); state.SetField ( -1, "SIM_LOOP_FORCE_STEP", ( u32 )SIM_LOOP_FORCE_STEP ); state.SetField ( -1, "SIM_LOOP_ALLOW_BOOST", ( u32 )SIM_LOOP_ALLOW_BOOST ); state.SetField ( -1, "SIM_LOOP_ALLOW_SPIN", ( u32 )SIM_LOOP_ALLOW_SPIN ); state.SetField ( -1, "SIM_LOOP_NO_DEFICIT", ( u32 )SIM_LOOP_NO_DEFICIT ); state.SetField ( -1, "SIM_LOOP_NO_SURPLUS", ( u32 )SIM_LOOP_NO_SURPLUS ); state.SetField ( -1, "SIM_LOOP_RESET_CLOCK", ( u32 )SIM_LOOP_RESET_CLOCK ); state.SetField ( -1, "SIM_LOOP_ALLOW_SOAK", ( u32 )SIM_LOOP_ALLOW_SOAK ); state.SetField ( -1, "LOOP_FLAGS_DEFAULT", ( u32 )LOOP_FLAGS_DEFAULT ); state.SetField ( -1, "LOOP_FLAGS_FIXED", ( u32 )LOOP_FLAGS_FIXED ); state.SetField ( -1, "LOOP_FLAGS_MULTISTEP", ( u32 )LOOP_FLAGS_MULTISTEP ); state.SetField ( -1, "LOOP_FLAGS_SOAK", ( u32 )LOOP_FLAGS_SOAK ); state.SetField ( -1, "DEFAULT_STEPS_PER_SECOND", ( u32 )DEFAULT_STEPS_PER_SECOND ); state.SetField ( -1, "DEFAULT_BOOST_THRESHOLD", ( u32 )DEFAULT_BOOST_THRESHOLD ); state.SetField ( -1, "DEFAULT_LONG_DELAY_THRESHOLD", ( u32 )DEFAULT_LONG_DELAY_THRESHOLD ); state.SetField ( -1, "DEFAULT_CPU_BUDGET", ( u32 )DEFAULT_CPU_BUDGET ); state.SetField ( -1, "DEFAULT_STEP_MULTIPLIER", ( u32 )DEFAULT_STEP_MULTIPLIER ); luaL_Reg regTable [] = { { "clearLoopFlags", _clearLoopFlags }, { "crash", _crash }, { "enterFullscreenMode", _enterFullscreenMode }, { "exitFullscreenMode", _exitFullscreenMode }, { "forceGarbageCollection", _forceGarbageCollection }, { "framesToTime", _framesToTime }, { "getDeviceTime", _getDeviceTime }, { "getElapsedFrames", _getElapsedFrames }, { "getElapsedTime", _getElapsedTime }, { "getHistogram", _getHistogram }, { "getLoopFlags", _getLoopFlags }, { "getLuaObjectCount", _getLuaObjectCount }, { "getMemoryUsage", _getMemoryUsage }, { "getPerformance", _getPerformance }, { "getStep", _getStep }, { "openWindow", _openWindow }, { "pauseTimer", _pauseTimer }, { "reportHistogram", _reportHistogram }, { "reportLeaks", _reportLeaks }, { "setBoostThreshold", _setBoostThreshold }, { "setCpuBudget", _setCpuBudget}, { "setHistogramEnabled", _setHistogramEnabled }, { "setLeakTrackingEnabled", _setLeakTrackingEnabled }, { "setListener", &MOAIGlobalEventSource::_setListener < MOAISim > }, { "setLongDelayThreshold", _setLongDelayThreshold }, { "setLoopFlags", _setLoopFlags }, { "setLuaAllocLogEnabled", _setLuaAllocLogEnabled }, { "setStep", _setStep }, { "setStepMultiplier", _setStepMultiplier }, { "setTimerError", _setTimerError }, { "setTraceback", _setTraceback }, { "timeToFrames", _timeToFrames }, { NULL, NULL } }; luaL_register( state, 0, regTable ); }
LUALIB_API int luaopen_posix_sys_socket(lua_State *L) { luaL_register(L, "posix.sys.socket", posix_sys_socket_fns); lua_pushliteral(L, "posix.sys.socket for " LUA_VERSION " / " PACKAGE_STRING); lua_setfield(L, -2, "version"); #if _POSIX_VERSION >= 200112L LPOSIX_CONST( SOMAXCONN ); LPOSIX_CONST( AF_UNSPEC ); LPOSIX_CONST( AF_INET ); LPOSIX_CONST( AF_INET6 ); LPOSIX_CONST( AF_UNIX ); # if HAVE_LINUX_NETLINK_H LPOSIX_CONST( AF_NETLINK ); # endif LPOSIX_CONST( SOL_SOCKET ); LPOSIX_CONST( IPPROTO_TCP ); LPOSIX_CONST( IPPROTO_UDP ); LPOSIX_CONST( IPPROTO_IP ); LPOSIX_CONST( IPPROTO_IPV6 ); # ifdef IPPROTO_ICMP LPOSIX_CONST( IPPROTO_ICMP ); # endif LPOSIX_CONST( SOCK_STREAM ); LPOSIX_CONST( SOCK_DGRAM ); # ifdef SOCK_RAW LPOSIX_CONST( SOCK_RAW ); # endif LPOSIX_CONST( SHUT_RD ); LPOSIX_CONST( SHUT_WR ); LPOSIX_CONST( SHUT_RDWR ); LPOSIX_CONST( SO_ACCEPTCONN ); LPOSIX_CONST( SO_BROADCAST ); LPOSIX_CONST( SO_LINGER ); LPOSIX_CONST( SO_RCVTIMEO ); LPOSIX_CONST( SO_SNDTIMEO ); # ifdef SO_BINDTODEVICE LPOSIX_CONST( SO_BINDTODEVICE ); # endif LPOSIX_CONST( SO_DEBUG ); LPOSIX_CONST( SO_DONTROUTE ); LPOSIX_CONST( SO_ERROR ); LPOSIX_CONST( SO_KEEPALIVE ); LPOSIX_CONST( SO_OOBINLINE ); LPOSIX_CONST( SO_RCVBUF ); LPOSIX_CONST( SO_RCVLOWAT ); LPOSIX_CONST( SO_REUSEADDR ); LPOSIX_CONST( SO_SNDBUF ); LPOSIX_CONST( SO_SNDLOWAT ); LPOSIX_CONST( SO_TYPE ); LPOSIX_CONST( TCP_NODELAY ); LPOSIX_CONST( AI_ADDRCONFIG ); LPOSIX_CONST( AI_ALL ); LPOSIX_CONST( AI_CANONNAME ); LPOSIX_CONST( AI_NUMERICHOST ); LPOSIX_CONST( AI_NUMERICSERV ); LPOSIX_CONST( AI_PASSIVE ); LPOSIX_CONST( AI_V4MAPPED ); # ifdef IPV6_JOIN_GROUP LPOSIX_CONST( IPV6_JOIN_GROUP ); # endif # ifdef IPV6_LEAVE_GROUP LPOSIX_CONST( IPV6_LEAVE_GROUP ); # endif # ifdef IPV6_MULTICAST_HOPS LPOSIX_CONST( IPV6_MULTICAST_HOPS ); # endif # ifdef IPV6_MULTICAST_IF LPOSIX_CONST( IPV6_MULTICAST_IF ); # endif # ifdef IPV6_MULTICAST_LOOP LPOSIX_CONST( IPV6_MULTICAST_LOOP ); # endif # ifdef IPV6_UNICAST_HOPS LPOSIX_CONST( IPV6_UNICAST_HOPS ); # endif # ifdef IPV6_V6ONLY LPOSIX_CONST( IPV6_V6ONLY ); # endif # if HAVE_LINUX_NETLINK_H LPOSIX_CONST( NETLINK_ROUTE ); LPOSIX_CONST( NETLINK_UNUSED ); LPOSIX_CONST( NETLINK_USERSOCK ); LPOSIX_CONST( NETLINK_FIREWALL ); LPOSIX_CONST( NETLINK_NFLOG ); LPOSIX_CONST( NETLINK_XFRM ); LPOSIX_CONST( NETLINK_SELINUX ); LPOSIX_CONST( NETLINK_ISCSI ); LPOSIX_CONST( NETLINK_AUDIT ); LPOSIX_CONST( NETLINK_FIB_LOOKUP ); LPOSIX_CONST( NETLINK_CONNECTOR ); LPOSIX_CONST( NETLINK_NETFILTER ); LPOSIX_CONST( NETLINK_IP6_FW ); LPOSIX_CONST( NETLINK_DNRTMSG ); LPOSIX_CONST( NETLINK_KOBJECT_UEVENT ); LPOSIX_CONST( NETLINK_GENERIC ); LPOSIX_CONST( NETLINK_SCSITRANSPORT ); LPOSIX_CONST( NETLINK_ECRYPTFS ); # endif #endif return 1; }
static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int priv_table) { const luaL_reg *reg_list; obj_type *type = type_reg->type; const obj_base *base = type_reg->bases; if(type_reg->req_type == REG_PACKAGE) { obj_type_register_package(L, type_reg); return; } if(type_reg->req_type == REG_META) { obj_type_register_meta(L, type_reg); return; } /* create public functions table. */ reg_list = type_reg->pub_funcs; if(reg_list != NULL && reg_list[0].name != NULL) { /* register "constructors" as to object's public API */ luaL_register(L, NULL, reg_list); /* fill public API table. */ /* make public API table callable as the default constructor. */ lua_newtable(L); /* create metatable */ lua_pushliteral(L, "__call"); lua_pushcfunction(L, reg_list[0].func); /* push first constructor function. */ lua_pushcclosure(L, obj_constructor_call_wrapper, 1); /* make __call wrapper. */ lua_rawset(L, -3); /* metatable.__call = <default constructor> */ #if OBJ_DATA_HIDDEN_METATABLE lua_pushliteral(L, "__metatable"); lua_pushboolean(L, 0); lua_rawset(L, -3); /* metatable.__metatable = false */ #endif /* setmetatable on public API table. */ lua_setmetatable(L, -2); lua_pop(L, 1); /* pop public API table, don't need it any more. */ /* create methods table. */ lua_newtable(L); } else { /* register all methods as public functions. */ #if OBJ_DATA_HIDDEN_METATABLE lua_pop(L, 1); /* pop public API table, don't need it any more. */ /* create methods table. */ lua_newtable(L); #endif } luaL_register(L, NULL, type_reg->methods); /* fill methods table. */ luaL_newmetatable(L, type->name); /* create metatable */ lua_pushliteral(L, ".name"); lua_pushstring(L, type->name); lua_rawset(L, -3); /* metatable['.name'] = "<object_name>" */ lua_pushliteral(L, ".type"); lua_pushlightuserdata(L, type); lua_rawset(L, -3); /* metatable['.type'] = lightuserdata -> obj_type */ lua_pushlightuserdata(L, type); lua_pushvalue(L, -2); /* dup metatable. */ lua_rawset(L, LUA_REGISTRYINDEX); /* REGISTRY[type] = metatable */ /* add metatable to 'priv_table' */ lua_pushstring(L, type->name); lua_pushvalue(L, -2); /* dup metatable. */ lua_rawset(L, priv_table); /* priv_table["<object_name>"] = metatable */ luaL_register(L, NULL, type_reg->metas); /* fill metatable */ /* add obj_bases to metatable. */ while(base->id >= 0) { lua_pushlightuserdata(L, (void *)base); lua_rawseti(L, -2, base->id); base++; } obj_type_register_constants(L, type_reg->constants, -2, type_reg->bidirectional_consts); obj_type_register_implements(L, type_reg->implements); lua_pushliteral(L, "__index"); lua_pushvalue(L, -3); /* dup methods table */ lua_rawset(L, -3); /* metatable.__index = methods */ #if OBJ_DATA_HIDDEN_METATABLE lua_pushliteral(L, "__metatable"); lua_pushboolean(L, 0); lua_rawset(L, -3); /* hide metatable: metatable.__metatable = false */ #endif lua_pop(L, 2); /* drop metatable & methods */ }
LUALIB_API int luaopen_bit (lua_State *L) { luaL_register(L, "bit", bitlib); return 1; }
extern "C" int luaopen_cv_vendor(lua_State *L) { // register functions luaL_register(L, "cv", lib_functions); return 0; }
int Open_LuaIntf( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t*)p_this; intf_sys_t *p_sys; lua_State *L; config_ChainParse( p_intf, "lua-", ppsz_intf_options, p_intf->p_cfg ); char *psz_name = NULL; if( !p_intf->psz_intf || !*p_intf->psz_intf ) psz_name = strdup( "rc" ); else psz_name = GetModuleName( p_intf ); if( !psz_name ) psz_name = strdup( "dummy" ); char *psz_config; bool b_config_set = false; p_intf->p_sys = (intf_sys_t*)malloc( sizeof(intf_sys_t) ); if( !p_intf->p_sys ) { free( psz_name ); return VLC_ENOMEM; } p_sys = p_intf->p_sys; p_sys->psz_filename = vlclua_find_file( p_this, "intf", psz_name ); if( !p_sys->psz_filename ) { msg_Err( p_intf, "Couldn't find lua interface script \"%s\".", psz_name ); goto error; } msg_Dbg( p_intf, "Found lua interface script: %s", p_sys->psz_filename ); L = luaL_newstate(); if( !L ) { msg_Err( p_intf, "Could not create new Lua State" ); goto error; } vlclua_set_this( L, p_intf ); vlclua_set_intf( L, p_sys ); luaL_openlibs( L ); /* register our functions */ luaL_register( L, "vlc", p_reg ); /* register submodules */ luaopen_acl( L ); luaopen_config( L ); luaopen_volume( L ); luaopen_httpd( L ); luaopen_input( L ); luaopen_msg( L ); luaopen_misc( L ); luaopen_net( L ); luaopen_object( L ); luaopen_osd( L ); luaopen_playlist( L ); luaopen_sd( L ); luaopen_stream( L ); luaopen_strings( L ); luaopen_variables( L ); luaopen_video( L ); luaopen_vlm( L ); luaopen_volume( L ); luaopen_gettext( L ); luaopen_xml( L ); luaopen_md5( L ); /* clean up */ lua_pop( L, 1 ); /* Setup the module search path */ if( vlclua_add_modules_path( p_intf, L, p_sys->psz_filename ) ) { msg_Warn( p_intf, "Error while setting the module search path for %s", p_sys->psz_filename ); lua_close( L ); goto error; } /* * Get the lua-config string. * If the string is empty, try with the old http-* or telnet-* options * and build the right configuration line */ psz_config = var_CreateGetNonEmptyString( p_intf, "lua-config" ); if( !psz_config ) { if( !strcmp( psz_name, "http" ) ) { char *psz_http_host = var_CreateGetNonEmptyString( p_intf, "http-host" ); char *psz_http_src = var_CreateGetNonEmptyString( p_intf, "http-src" ); bool b_http_index = var_CreateGetBool( p_intf, "http-index" ); if( psz_http_host ) { char *psz_esc = config_StringEscape( psz_http_host ); asprintf( &psz_config, "http={host='%s'", psz_esc ); free( psz_esc ); free( psz_http_host ); } if( psz_http_src ) { char *psz_esc = config_StringEscape( psz_http_src ); if( psz_config ) { char *psz_tmp; asprintf( &psz_tmp, "%s,dir='%s'", psz_config, psz_esc ); free( psz_config ); psz_config = psz_tmp; } else asprintf( &psz_config, "http={dir='%s'", psz_esc ); free( psz_esc ); free( psz_http_src ); } if( psz_config ) { char *psz_tmp; asprintf( &psz_tmp, "%s,no_index=%s}", psz_config, b_http_index ? "true" : "false" ); free( psz_config ); psz_config = psz_tmp; } else asprintf( &psz_config, "http={no_index=%s}", b_http_index ? "true" : "false" ); } else if( !strcmp( psz_name, "telnet" ) ) { char *psz_telnet_host = var_CreateGetString( p_intf, "telnet-host" ); if( !strcmp( psz_telnet_host, "*console" ) ) ; else { vlc_url_t url; vlc_UrlParse( &url, psz_telnet_host, 0 ); int i_telnet_port = var_CreateGetInteger( p_intf, "telnet-port" ); if ( url.i_port != 0 ) { if ( i_telnet_port == TELNETPORT_DEFAULT ) i_telnet_port = url.i_port; else if ( url.i_port != i_telnet_port ) msg_Warn( p_intf, "ignoring port %d (using %d)", url.i_port, i_telnet_port ); } char *psz_esc_host = config_StringEscape( url.psz_host ); free( psz_telnet_host ); vlc_UrlClean( &url ); asprintf( &psz_telnet_host, "telnet://%s:%d", psz_esc_host ? psz_esc_host : "", i_telnet_port ); free( psz_esc_host ); } char *psz_telnet_passwd = var_CreateGetString( p_intf, "telnet-password" ); char *psz_esc_passwd = config_StringEscape( psz_telnet_passwd ); asprintf( &psz_config, "telnet={host='%s',password='******'}", psz_telnet_host, psz_esc_passwd ); free( psz_esc_passwd ); free( psz_telnet_passwd ); free( psz_telnet_host ); } else if( !strcmp( psz_name, "cli" ) ) { char *psz_rc_host = var_CreateGetNonEmptyString( p_intf, "rc-host" ); if( !psz_rc_host ) psz_rc_host = var_CreateGetNonEmptyString( p_intf, "cli-host" ); if( psz_rc_host ) { char *psz_esc_host = config_StringEscape( psz_rc_host ); asprintf( &psz_config, "cli={host='%s'}", psz_esc_host ); free( psz_esc_host ); free( psz_rc_host ); } } } if( psz_config ) { char *psz_buffer; if( asprintf( &psz_buffer, "config={%s}", psz_config ) != -1 ) { char *psz_log = StripPasswords( psz_buffer ); if( psz_log != NULL ) { msg_Dbg( p_intf, "Setting config variable: %s", psz_log ); free( psz_log ); } if( luaL_dostring( L, psz_buffer ) == 1 ) msg_Err( p_intf, "Error while parsing \"lua-config\"." ); free( psz_buffer ); lua_getglobal( L, "config" ); if( lua_istable( L, -1 ) ) { if( !strcmp( psz_name, "cli" ) ) { lua_getfield( L, -1, "rc" ); if( lua_istable( L, -1 ) ) { /* msg_Warn( p_intf, "The `rc' lua interface script " "was renamed `cli', please update " "your configuration!" ); */ lua_setfield( L, -2, "cli" ); } else lua_pop( L, 1 ); } lua_getfield( L, -1, psz_name ); if( lua_istable( L, -1 ) ) { lua_setglobal( L, "config" ); b_config_set = true; } } } free( psz_config ); } if( !b_config_set ) { lua_newtable( L ); lua_setglobal( L, "config" ); } /* Wrapper for legacy telnet config */ if ( !strcmp( psz_name, "telnet" ) ) { /* msg_Warn( p_intf, "The `telnet' lua interface script was replaced " "by `cli', please update your configuration!" ); */ char *wrapped_file = vlclua_find_file( p_this, "intf", "cli" ); if( !wrapped_file ) { msg_Err( p_intf, "Couldn't find lua interface script \"cli\", " "needed by telnet wrapper" ); p_intf->psz_header = NULL; lua_close( p_sys->L ); goto error; } lua_pushstring( L, wrapped_file ); lua_setglobal( L, "wrapped_file" ); free( wrapped_file ); } p_sys->L = L; p_intf->psz_header = psz_name; /* ^^ Do I need to clean that up myself in Close_LuaIntf? */ vlc_mutex_init( &p_sys->lock ); vlc_cond_init( &p_sys->wait ); p_sys->exiting = false; if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { p_intf->psz_header = NULL; vlc_cond_destroy( &p_sys->wait ); vlc_mutex_destroy( &p_sys->lock ); lua_close( p_sys->L ); goto error; } return VLC_SUCCESS; error: free( p_sys->psz_filename ); free( p_sys ); free( psz_name ); return VLC_EGENERIC; }
int luaopen_scriptevents(lua_State* L) { luaL_register(L, "Events", scriptevent_module); return 1; }
int luaopen_cdf (lua_State *L) { lua_newtable(L); luaL_register(L, NULL, cdf_lib); return 1; }
void luaopen_sd( lua_State *L ) { lua_newtable( L ); luaL_register( L, NULL, vlclua_sd_reg ); lua_setfield( L, -2, "sd" ); }
int luaopen_affinity(lua_State *L){ luaL_register(L,"affinity",affinity); return 1; }
/** * @brief Loads the Toolkit Lua library. * * @param L Lua state. * @return 0 on success. */ int nlua_loadTk( lua_State *L ) { luaL_register(L, "tk", tk_methods); return 0; }
LUALIB_API int luaopen_table (lua_State *L) { luaL_register(L, LUA_TABLIBNAME, tab_funcs); return 1; }
/** * Entry point into the 'ev' lua library. Validates that the * dynamically linked libev version matches, creates the object * registry, and creates the table returned by require(). */ LUALIB_API int luaopen_ev(lua_State *L) { assert(ev_version_major() == EV_VERSION_MAJOR && ev_version_minor() >= EV_VERSION_MINOR); create_obj_registry(L); luaL_register(L, "ev", R); luaopen_ev_loop(L); lua_setfield(L, -2, "Loop"); luaopen_ev_timer(L); lua_setfield(L, -2, "Timer"); luaopen_ev_io(L); lua_setfield(L, -2, "IO"); luaopen_ev_signal(L); lua_setfield(L, -2, "Signal"); luaopen_ev_idle(L); lua_setfield(L, -2, "Idle"); luaopen_ev_child(L); lua_setfield(L, -2, "Child"); luaopen_ev_stat(L); lua_setfield(L, -2, "Stat"); lua_pushnumber(L, EV_READ); lua_setfield(L, -2, "READ"); lua_pushnumber(L, EV_WRITE); lua_setfield(L, -2, "WRITE"); lua_pushnumber(L, EV_TIMEOUT); lua_setfield(L, -2, "TIMEOUT"); lua_pushnumber(L, EV_SIGNAL); lua_setfield(L, -2, "SIGNAL"); lua_pushnumber(L, EV_IDLE); lua_setfield(L, -2, "IDLE"); lua_pushnumber(L, EV_CHILD); lua_setfield(L, -2, "CHILD"); lua_pushnumber(L, EV_STAT); lua_setfield(L, -2, "STAT"); lua_pushnumber(L, EV_MINPRI); lua_setfield(L, -2, "MINPRI"); lua_pushnumber(L, EV_MAXPRI); lua_setfield(L, -2, "MAXPRI"); lua_pushnumber(L, SIGHUP); lua_setfield(L, -2, "SIGHUP"); lua_pushnumber(L, SIGINT); lua_setfield(L, -2, "SIGINT"); lua_pushnumber(L, SIGQUIT); lua_setfield(L, -2, "SIGQUIT"); lua_pushnumber(L, SIGILL); lua_setfield(L, -2, "SIGILL"); lua_pushnumber(L, SIGTRAP); lua_setfield(L, -2, "SIGTRAP"); lua_pushnumber(L, SIGABRT); lua_setfield(L, -2, "SIGABRT"); lua_pushnumber(L, SIGIOT); lua_setfield(L, -2, "SIGIOT"); lua_pushnumber(L, SIGBUS); lua_setfield(L, -2, "SIGBUS"); lua_pushnumber(L, SIGFPE); lua_setfield(L, -2, "SIGFPE"); lua_pushnumber(L, SIGUSR1); lua_setfield(L, -2, "SIGUSR1"); lua_pushnumber(L, SIGSEGV); lua_setfield(L, -2, "SIGSEGV"); lua_pushnumber(L, SIGUSR2); lua_setfield(L, -2, "SIGUSR2"); lua_pushnumber(L, SIGPIPE); lua_setfield(L, -2, "SIGPIPE"); lua_pushnumber(L, SIGALRM); lua_setfield(L, -2, "SIGALRM"); lua_pushnumber(L, SIGTERM); lua_setfield(L, -2, "SIGTERM"); lua_pushnumber(L, SIGSTKFLT); lua_setfield(L, -2, "SIGSTKFLT"); lua_pushnumber(L, SIGCHLD); lua_setfield(L, -2, "SIGCHLD"); lua_pushnumber(L, SIGCONT); lua_setfield(L, -2, "SIGCONT"); lua_pushnumber(L, SIGTSTP); lua_setfield(L, -2, "SIGTSTP"); lua_pushnumber(L, SIGTTIN); lua_setfield(L, -2, "SIGTTIN"); lua_pushnumber(L, SIGTTOU); lua_setfield(L, -2, "SIGTTOU"); lua_pushnumber(L, SIGURG); lua_setfield(L, -2, "SIGURG"); lua_pushnumber(L, SIGXCPU); lua_setfield(L, -2, "SIGXCPU"); lua_pushnumber(L, SIGXFSZ); lua_setfield(L, -2, "SIGXFSZ"); lua_pushnumber(L, SIGVTALRM); lua_setfield(L, -2, "SIGVTALRM"); lua_pushnumber(L, SIGPROF); lua_setfield(L, -2, "SIGPROF"); lua_pushnumber(L, SIGWINCH); lua_setfield(L, -2, "SIGWINCH"); lua_pushnumber(L, SIGIO); lua_setfield(L, -2, "SIGIO"); lua_pushnumber(L, SIGPOLL); lua_setfield(L, -2, "SIGPOLL"); lua_pushnumber(L, SIGPWR); lua_setfield(L, -2, "SIGPWR"); lua_pushnumber(L, SIGSYS); lua_setfield(L, -2, "SIGSYS"); return 1; }
int luaopen_signal (lua_State *L) { static const struct luaL_Reg lib[] = { {"signal", l_signal}, {"raise", l_raise}, #if INCLUDE_KILL {"kill", l_kill}, #endif #if INCLUDE_PAUSE {"pause", l_pause}, #endif {NULL, NULL} }; int i; int max_signal; ML = L; if (lua_pushthread(L)) lua_pop(L, 1); else luaL_error(L, "library should be opened by the main thread"); /* environment */ lua_newtable(L); lua_replace(L, LUA_ENVIRONINDEX); lua_pushvalue(L, LUA_ENVIRONINDEX); lua_setfield(L, LUA_REGISTRYINDEX, LUA_SIGNAL_NAME); /* for hooks */ /* add the library */ luaL_register(L, LUA_LIB_NAME, lib); lua_pushliteral(L, LUA_LIB_VERSION); lua_setfield(L, -2, "version"); for (i = 0, max_signal = 0; lua_signals[i].name != NULL; i++) if (lua_signals[i].sig > max_signal) max_signal = lua_signals[i].sig+1; /* +1 !!! (for < loops) */ signal_stack = lua_newuserdata(L, sizeof(volatile sig_atomic_t)*max_signal*2); lua_newtable(L); lua_pushcfunction(L, library_gc); lua_setfield(L, -2, "__gc"); lua_setmetatable(L, -2); /* when userdata is gc'd, close library */ memset((void *) signal_stack, 0, sizeof(volatile sig_atomic_t)*max_signal*2); signal_stack_top = max_signal; lua_pushboolean(L, 1); lua_rawset(L, LUA_ENVIRONINDEX); while (i--) /* i set from previous for loop */ { lua_pushstring(L, lua_signals[i].name); lua_pushinteger(L, lua_signals[i].sig); lua_rawset(L, LUA_ENVIRONINDEX); /* add copy to environment table */ lua_pushstring(L, lua_signals[i].name); lua_pushinteger(L, lua_signals[i].sig); lua_settable(L, -3); /* add copy to signal table */ } /* set default interrupt handler */ lua_getfield(L, -1, "signal"); lua_pushinteger(L, SIGINT); lua_pushcfunction(L, interrupted); lua_call(L, 2, 0); return 1; }
/** * Register the cc3_pixel_t datatype for Camscripter */ void register_pixel_struct(void) { luaL_newmetatable(L, "scripter.pixel"); // pixel metatable lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); luaL_register(L, NULL, pixellib_m); // pixel methods }
static void createmeta (lua_State *L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ luaL_register(L, NULL, flib); /* file methods */ }
int luaopen_texio (lua_State *L) { luaL_register(L,"texio",texiolib); return 1; }
LUALIB_API int luaopen_base (lua_State *L) { base_open(L); luaL_register(L, LUA_COLIBNAME, co_funcs); return 2; }
LUALIB_API int luaopen_program(lua_State *L) { luaL_register(L, "program", g_programlib); return 1; }