Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sample and documentation updates, bug fixes
imported from personal svn: * added cpp reflection sample * added nest indentation sample * added $< line slurp * added utils module * rst documentation updates
- Loading branch information
Showing
23 changed files
with
897 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ Python API | |
.. automodule:: texthon.parser | ||
:members: | ||
|
||
.. _utility_module: | ||
.. automodule:: texthon.utils | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "rtt.h" | ||
#include <stdio.h> | ||
|
||
using namespace game; | ||
|
||
void print_r(unsigned int level, char const* name, rtt::typeinfo_base const* type, void* ptr) | ||
{ | ||
for(unsigned int i = 0; i < level; ++i) | ||
{ | ||
printf(" "); | ||
} | ||
|
||
switch(type->get_id()) | ||
{ | ||
case rtt::type_traits<float>::id: | ||
printf("%s: %f\n", name, *type->cast<float>(ptr)); | ||
break; | ||
|
||
case rtt::type_traits<int>::id: | ||
printf("%s: %i\n", name, *type->cast<int>(ptr)); | ||
break; | ||
|
||
default: | ||
printf("%s:\n", name); | ||
for(unsigned int field = 0; field < type->field_count(); ++field) | ||
{ | ||
print_r(level + 1, type->field_name(field), type->field_type(field), type->get_field(ptr, field)); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
template <class T> void print(T& obj) | ||
{ | ||
print_r(0, "obj", rtt::get_type(&obj), &obj); | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
rtt::create(); | ||
|
||
transform trans = { | ||
{0, 0, 1, 0}, | ||
{0, 1, 0, 0}, | ||
{1, 0, 0, 0}, | ||
{0, 0, 0, 1}, | ||
}; | ||
object obj; | ||
obj.health = 100; | ||
obj.xform = trans; | ||
print(obj); | ||
|
||
rtt::destroy(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def norm(types): | ||
typeId = 0 | ||
for type in types: | ||
type["id"] = typeId | ||
|
||
if "extern" not in type: | ||
type["extern"] = False | ||
if "members" not in type: | ||
type["members"] = [] | ||
|
||
typeId += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
namespace texthon { | ||
|
||
struct type_lib | ||
{ | ||
int get_typeid(int* t) | ||
{ | ||
return 0; | ||
} | ||
}; | ||
|
||
struct type_info | ||
{ | ||
unsigned int field_count; | ||
|
||
void* get_field(void* ptr, unsigned int field); | ||
type_info const* get_field_type(void* ptr, unsigned int field); | ||
|
||
virtual void on_visit(void* p) | ||
{ | ||
T* actual = static_cast<T>(p); | ||
|
||
} | ||
}; | ||
|
||
template <class T> T* lib::try_cast(type_info const& type, void* ptr) | ||
{ | ||
id = type.lib.map<T>; | ||
} | ||
|
||
} |
Oops, something went wrong.