Sha256: 3f3c06bbf6b732e5775caa7f442e528e34812f7005a4639f80e545b19c9ea618

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

#include "<%= @namespace.header %>"

#include "lua_cpp_helper.h"

using namespace <%= @namespace.name %>;

<% if @namespace.members; @namespace.members.each do |function| %>

<%= function %>

<% end; end %>

// Register namespace

static const struct luaL_Reg <%= @namespace.name %>_functions[] = {
<% if @namespace.has_functions? %>
<%= indent(functions_registration, 2) %>,
<% end %>
  {NULL, NULL},
};

<% if @namespace.has_constants? %>
static const struct lua_constants_Reg <%= @namespace.name %>_namespace_constants[] = {
<%= indent(constants_registration, 2) %>,
  {NULL, NULL},
};
<% end %>

#ifdef DUB_LUA_NO_OPEN
int luaload_<%= @namespace.lib_name %>(lua_State *L) {
#else
extern "C" int luaopen_<%= @namespace.lib_name %>(lua_State *L) {
#endif
  // register functions
  luaL_register(L, <%= @namespace.name.inspect %>, <%= @namespace.name %>_functions);

<% if @namespace.has_constants? %>
  // register namespace enums
  register_constants(L, <%= @namespace.id_name.inspect %>, <%= @namespace.name %>_namespace_constants);
<% end %>
  return 0;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dub-1.0.0 lib/dub/lua/namespace.cpp.erb
dub-0.7.0 lib/dub/lua/namespace.cpp.erb