mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 15:42:23 -07:00
C++ namespace examples
This commit is contained in:
@@ -1,30 +1,60 @@
|
||||
|
||||
struct Bar
|
||||
static int Static = 5;
|
||||
namespace NS
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
static int staticDataInNS = 99;
|
||||
struct A
|
||||
{
|
||||
static int staticData;
|
||||
int a = 20;
|
||||
int b = 30;
|
||||
void Foo()
|
||||
{
|
||||
Static += 1;
|
||||
staticDataInNS += 1;
|
||||
staticData++;
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
};
|
||||
int A::staticData = 123;
|
||||
}
|
||||
|
||||
struct Resource
|
||||
{
|
||||
int resourceType;
|
||||
};
|
||||
|
||||
struct BarContainer
|
||||
struct Stack
|
||||
{
|
||||
Bar *bar;
|
||||
int bar_count;
|
||||
int bar_cap;
|
||||
Resource *resource;
|
||||
};
|
||||
|
||||
struct Foo
|
||||
struct StackNode
|
||||
{
|
||||
BarContainer bar;
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
StackNode *next;
|
||||
Stack v;
|
||||
};
|
||||
|
||||
struct Context
|
||||
{
|
||||
StackNode *entry_stack_first;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Bar bar[100] = {0};
|
||||
Foo foo_ = {bar, 50, sizeof(bar)/sizeof(Bar)};
|
||||
Foo &foo = foo_;
|
||||
Resource r_ = {0};
|
||||
Resource *r = &r_;
|
||||
Stack s = {r};
|
||||
StackNode n_ = {0, s};
|
||||
StackNode *n = &n_;
|
||||
Context c_ = {n};
|
||||
Context *context = &c_;
|
||||
|
||||
// evaluate `context.entry_stack_first.v.resource.resourceType == 0xd8`
|
||||
int x = 0;
|
||||
|
||||
NS::A a = {0};
|
||||
a.Foo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user