diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2011-01-26 20:32:21 +0100 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2011-01-26 20:32:21 +0100 |
commit | d92b6e7c6586581aa2a12f9f4a591e154c8d2470 (patch) | |
tree | 25792d8e8dfa073a471d21b0da1931cc4aa8d73f /src/lanes.c | |
parent | d53c28a0b0aeb9f884624a13d08697a79ebc3d71 (diff) | |
parent | aa50523aa86ffb1f0f4150721e9f4d1a8cd63774 (diff) | |
download | lanes-d92b6e7c6586581aa2a12f9f4a591e154c8d2470.tar.gz lanes-d92b6e7c6586581aa2a12f9f4a591e154c8d2470.tar.bz2 lanes-d92b6e7c6586581aa2a12f9f4a591e154c8d2470.zip |
Merge branch 'pull_request_2' of https://github.com/dptr1988/lanes
Diffstat (limited to 'src/lanes.c')
-rw-r--r-- | src/lanes.c | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/src/lanes.c b/src/lanes.c index 0873339..f4bef7b 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -1854,21 +1854,17 @@ LUAG_FUNC( wakeup_conv ) | |||
1854 | /*---=== Module linkage ===--- | 1854 | /*---=== Module linkage ===--- |
1855 | */ | 1855 | */ |
1856 | 1856 | ||
1857 | #define REG_FUNC( name ) \ | 1857 | static const struct luaL_reg lanes_functions [] = { |
1858 | lua_pushcfunction( L, LG_##name ); \ | 1858 | {"linda_id", LG_linda_id}, |
1859 | lua_setglobal( L, #name ) | 1859 | {"thread_status", LG_thread_status}, |
1860 | 1860 | {"thread_join", LG_thread_join}, | |
1861 | #define REG_FUNC2( name, val ) \ | 1861 | {"thread_cancel", LG_thread_cancel}, |
1862 | lua_pushcfunction( L, val ); \ | 1862 | {"now_secs", LG_now_secs}, |
1863 | lua_setglobal( L, #name ) | 1863 | {"wakeup_conv", LG_wakeup_conv}, |
1864 | 1864 | {"_single", LG__single}, | |
1865 | #define REG_STR2( name, val ) \ | 1865 | {"_deep_userdata", luaG_deep_userdata}, |
1866 | lua_pushstring( L, val ); \ | 1866 | {NULL, NULL} |
1867 | lua_setglobal( L, #name ) | 1867 | }; |
1868 | |||
1869 | #define REG_INT2( name, val ) \ | ||
1870 | lua_pushinteger( L, val ); \ | ||
1871 | lua_setglobal( L, #name ) | ||
1872 | 1868 | ||
1873 | /* | 1869 | /* |
1874 | * One-time initializations | 1870 | * One-time initializations |
@@ -2005,9 +2001,9 @@ __declspec(dllexport) | |||
2005 | #endif | 2001 | #endif |
2006 | assert( timer_deep != 0 ); | 2002 | assert( timer_deep != 0 ); |
2007 | 2003 | ||
2008 | // Linda identity function | 2004 | // Create main module interface table |
2009 | // | 2005 | lua_newtable(L); |
2010 | REG_FUNC( linda_id ); | 2006 | luaL_register(L, NULL, lanes_functions); |
2011 | 2007 | ||
2012 | // metatable for threads | 2008 | // metatable for threads |
2013 | // | 2009 | // |
@@ -2016,29 +2012,22 @@ __declspec(dllexport) | |||
2016 | lua_setfield( L, -2, "__gc" ); | 2012 | lua_setfield( L, -2, "__gc" ); |
2017 | 2013 | ||
2018 | lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param | 2014 | lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param |
2019 | lua_setglobal( L, "thread_new" ); | 2015 | lua_setfield(L, -2, "thread_new"); |
2020 | |||
2021 | REG_FUNC( thread_status ); | ||
2022 | REG_FUNC( thread_join ); | ||
2023 | REG_FUNC( thread_cancel ); | ||
2024 | |||
2025 | REG_STR2( _version, VERSION ); | ||
2026 | REG_FUNC( _single ); | ||
2027 | |||
2028 | REG_FUNC2( _deep_userdata, luaG_deep_userdata ); | ||
2029 | |||
2030 | REG_FUNC( now_secs ); | ||
2031 | REG_FUNC( wakeup_conv ); | ||
2032 | 2016 | ||
2033 | luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); | 2017 | luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); |
2034 | lua_setglobal( L, "timer_gateway" ); | 2018 | lua_setfield(L, -2, "timer_gateway"); |
2035 | 2019 | ||
2036 | REG_INT2( max_prio, THREAD_PRIO_MAX ); | 2020 | lua_pushstring(L, VERSION); |
2021 | lua_setfield(L, -2, "_version"); | ||
2022 | |||
2023 | lua_pushinteger(L, THREAD_PRIO_MAX); | ||
2024 | lua_setfield(L, -2, "max_prio"); | ||
2037 | 2025 | ||
2038 | lua_pushlightuserdata( L, CANCEL_ERROR ); | 2026 | lua_pushlightuserdata( L, CANCEL_ERROR ); |
2039 | lua_setglobal( L, "cancel_error" ); | 2027 | lua_setfield(L, -2, "cancel_error"); |
2040 | 2028 | ||
2041 | return 0; | 2029 | // Return the local module table |
2030 | return 1; | ||
2042 | } | 2031 | } |
2043 | 2032 | ||
2044 | 2033 | ||