Skip to content

Instantly share code, notes, and snippets.

package = "lub"
version = "1.0.4-1"
source = {
url = 'https://github.com/lubyk/lub/archive/REL-1.0.4.tar.gz',
dir = 'lub-REL-1.0.4',
}
description = {
summary = "Lubyk base module.",
detailed = [[
lub: helper code, class declaration.
@lubyk
lubyk / gist:5212902
Last active December 15, 2015 05:59

actual modules dependency analysis

  • core contains: TimeRef, Finalizer, Fifo, Mutex and msgpack
  • zmq contains: non-GUI scheduler, message based networking
  • mdns contains: ZeroConf
  • lk contains: sockets, Scheduler, Timer, Thread, network transparency, utilities

Dependency up to "four" library

class ClubsController < ApplicationController
before_filter :check_is_admin
layout :admin_layout
def club
attrs = secure(Node) { Node.transform_attributes(attrs) }
zip = attrs.delete('parent_zip')
parent = visitor.find_node(nil, zip, nil, request)
if !parent.can_write? && !visitor.exec_acl
@lubyk
lubyk / gist:1654861
Created January 22, 2012 01:02
cast to shared pointer
binder = dub.LuaBinder()
binder.TYPE_TO_NATIVE['FooPtr'] = {
type = 'FooPtr', -- not sure why this is needed
-- Get value from Lua.
pull = function(name, position, prefix)
-- Allocate a FooPtr on the stack
return format('FooPtr %s = ((Foo**)dub_checksdata(L, %i, "lib.Foo"));',
name, position)
end,
#include "dummy/Dummy.h"
#include "lua_cpp_helper.h"
using namespace dummy;
@lubyk
lubyk / gist:1444128
Created December 7, 2011 19:01
ThreadedLuaObject cpp
#include "lubyk/lua_object.h"
#include "lua_cpp_helper.h"
using namespace lubyk;
LuaObject::LuaObject() throw ()
: userdata_(NULL),
worker_(NULL),
class_name_("??") {
}
@lubyk
lubyk / gist:1444097
Created December 7, 2011 18:55
ThreadedLuaObject
/** Calls a lua function back.
*/
class LuaObject
{
/** This is used to invalidate the userdata in case the object is deleted
* out of Lua.
*/
void **userdata_;
public:
/** Prepare tables to work with the table based self idion.
@lubyk
lubyk / gist:1444080
Created December 7, 2011 18:51
simple C++ class example
namespace dummy {
/** Dummy
*
* @dub ignore: 'cppOnlyMethod'
*/
class Dummy : public ThreadedLuaObject {
public:
Dummy() {}
/** This is only called by C++ but has to be public for xyz reasons so it
@lubyk
lubyk / gist:1221403
Created September 16, 2011 07:00
Lua garbage collection weirdness
~~~ = link from table with weak values
********************************************************************************
State before removing 'foobar':
+----------------------------------------+
| |
v |
scheduler ---> wrap ---> t ~~~> thread ---> coroutine --- (up-value) --> foobar ---> udata
^ ^
| |