Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
orangeduck committed Oct 7, 2014
1 parent cf656d8 commit 68174e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,23 @@ luaL_dostring(L,
);
```

You can then wrap this function in whatever Lua interface you like. One nice idea is to create a table and set it's `__index` metamethod to return the C function of the same name.

```lua
HelloMT = {}
HelloMT.__index = function (table, key)
return function (...)
return C(key, ...)
end
end

Hello = {}
setmetatable(Hello, HelloMT)

Hello.hello_world()
Hello.hello_person('Marcelo')
```

### Advanced Interface

Using LuaAutoC it is easy to wrap pointers to structs so that they act like object instances. All we need to do is set `__index` and `__newindex` in the metatable.
Expand Down

0 comments on commit 68174e8

Please sign in to comment.