Lua documentation tweaks and make nspace example more concise.
This commit is contained in:
parent
8b75b90b2f
commit
c99417ab13
4 changed files with 21 additions and 31 deletions
|
|
@ -7,20 +7,15 @@ int module_variable = 9;
|
|||
namespace MyWorld {
|
||||
class World {
|
||||
public:
|
||||
World():
|
||||
world_max_count(9) {}
|
||||
World() : world_max_count(9) {}
|
||||
int create_world() { return 17; }
|
||||
const int world_max_count; // = 9
|
||||
};
|
||||
namespace Nested {
|
||||
class Dweller {
|
||||
public:
|
||||
Dweller():
|
||||
food_count(11) {}
|
||||
enum Gender { MALE = 0, FEMALE = 1 };
|
||||
static int populate_cave() { return 19; }
|
||||
int create_cave() { return 13; }
|
||||
int food_count; // = 11
|
||||
static int count() { return 19; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%nspace MyWorld::Nested::Dweller;
|
||||
%nspace MyWorld::World;
|
||||
%nspace MyWorld::Nested::Dweller;
|
||||
%nspace MyWorld::World;
|
||||
|
||||
%include "example.h"
|
||||
|
|
|
|||
|
|
@ -37,5 +37,10 @@ assert( w1.world_max_count == 9 )
|
|||
-- Accessing enums from class within namespace
|
||||
print( "Accessing enums: ex.MyWorld.Nested.Dweller.MALE = ", ex.MyWorld.Nested.Dweller.MALE )
|
||||
assert( ex.MyWorld.Nested.Dweller.MALE == 0 )
|
||||
print( "Accessing enums: ex.MyWorld.Nested.Dweller.FEMALE = ", ex.MyWorld.Nested.Dweller.FEMALE )
|
||||
assert( ex.MyWorld.Nested.Dweller.FEMALE == 1 )
|
||||
|
||||
-- Accessing static member function
|
||||
print( "Accessing static member function: ex.MyWorld.Nested.Dweller.count() = ", ex.MyWorld.Nested.Dweller.count() )
|
||||
assert( ex.MyWorld.Nested.Dweller.count() == 19 )
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue