aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorPeter Dettwiler <junk_mail@dptr1988.mooo.com>2011-01-09 16:45:29 -0800
committerdptr1988 <junk_mail@dptr1988.mooo.com>2011-01-25 15:38:46 -0800
commitaa50523aa86ffb1f0f4150721e9f4d1a8cd63774 (patch)
tree3e7dd5bf4d0808243665059e7996293b8b9224b0 /src/lanes.c
parent8ce207a848429e8581e8a900b645927f86e78435 (diff)
downloadlanes-aa50523aa86ffb1f0f4150721e9f4d1a8cd63774.tar.gz
lanes-aa50523aa86ffb1f0f4150721e9f4d1a8cd63774.tar.bz2
lanes-aa50523aa86ffb1f0f4150721e9f4d1a8cd63774.zip
Changed lanes.c to export functions as a module rather than writing them directly to the globals table.
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/src/lanes.c b/src/lanes.c
index ba9e59a..2b90caf 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1845,21 +1845,17 @@ LUAG_FUNC( wakeup_conv )
1845/*---=== Module linkage ===--- 1845/*---=== Module linkage ===---
1846*/ 1846*/
1847 1847
1848#define REG_FUNC( name ) \ 1848static const struct luaL_reg lanes_functions [] = {
1849 lua_pushcfunction( L, LG_##name ); \ 1849 {"linda_id", LG_linda_id},
1850 lua_setglobal( L, #name ) 1850 {"thread_status", LG_thread_status},
1851 1851 {"thread_join", LG_thread_join},
1852#define REG_FUNC2( name, val ) \ 1852 {"thread_cancel", LG_thread_cancel},
1853 lua_pushcfunction( L, val ); \ 1853 {"now_secs", LG_now_secs},
1854 lua_setglobal( L, #name ) 1854 {"wakeup_conv", LG_wakeup_conv},
1855 1855 {"_single", LG__single},
1856#define REG_STR2( name, val ) \ 1856 {"_deep_userdata", luaG_deep_userdata},
1857 lua_pushstring( L, val ); \ 1857 {NULL, NULL}
1858 lua_setglobal( L, #name ) 1858};
1859
1860#define REG_INT2( name, val ) \
1861 lua_pushinteger( L, val ); \
1862 lua_setglobal( L, #name )
1863 1859
1864/* 1860/*
1865* One-time initializations 1861* One-time initializations
@@ -1996,9 +1992,9 @@ __declspec(dllexport)
1996#endif 1992#endif
1997 assert( timer_deep != 0 ); 1993 assert( timer_deep != 0 );
1998 1994
1999 // Linda identity function 1995 // Create main module interface table
2000 // 1996 lua_newtable(L);
2001 REG_FUNC( linda_id ); 1997 luaL_register(L, NULL, lanes_functions);
2002 1998
2003 // metatable for threads 1999 // metatable for threads
2004 // 2000 //
@@ -2007,29 +2003,22 @@ __declspec(dllexport)
2007 lua_setfield( L, -2, "__gc" ); 2003 lua_setfield( L, -2, "__gc" );
2008 2004
2009 lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param 2005 lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param
2010 lua_setglobal( L, "thread_new" ); 2006 lua_setfield(L, -2, "thread_new");
2011
2012 REG_FUNC( thread_status );
2013 REG_FUNC( thread_join );
2014 REG_FUNC( thread_cancel );
2015
2016 REG_STR2( _version, VERSION );
2017 REG_FUNC( _single );
2018
2019 REG_FUNC2( _deep_userdata, luaG_deep_userdata );
2020
2021 REG_FUNC( now_secs );
2022 REG_FUNC( wakeup_conv );
2023 2007
2024 luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); 2008 luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep );
2025 lua_setglobal( L, "timer_gateway" ); 2009 lua_setfield(L, -2, "timer_gateway");
2026 2010
2027 REG_INT2( max_prio, THREAD_PRIO_MAX ); 2011 lua_pushstring(L, VERSION);
2012 lua_setfield(L, -2, "_version");
2013
2014 lua_pushinteger(L, THREAD_PRIO_MAX);
2015 lua_setfield(L, -2, "max_prio");
2028 2016
2029 lua_pushlightuserdata( L, CANCEL_ERROR ); 2017 lua_pushlightuserdata( L, CANCEL_ERROR );
2030 lua_setglobal( L, "cancel_error" ); 2018 lua_setfield(L, -2, "cancel_error");
2031 2019
2032 return 0; 2020 // Return the local module table
2021 return 1;
2033} 2022}
2034 2023
2035 2024