mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 04:48:40 +00:00
C++ namespace examples
This commit is contained in:
@@ -1,30 +1,60 @@
|
|||||||
|
|
||||||
struct Bar
|
static int Static = 5;
|
||||||
|
namespace NS
|
||||||
{
|
{
|
||||||
int x;
|
static int staticDataInNS = 99;
|
||||||
int y;
|
struct A
|
||||||
int z;
|
{
|
||||||
|
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;
|
Resource *resource;
|
||||||
int bar_count;
|
|
||||||
int bar_cap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Foo
|
struct StackNode
|
||||||
{
|
{
|
||||||
BarContainer bar;
|
StackNode *next;
|
||||||
int a;
|
Stack v;
|
||||||
int b;
|
};
|
||||||
int c;
|
|
||||||
|
struct Context
|
||||||
|
{
|
||||||
|
StackNode *entry_stack_first;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Bar bar[100] = {0};
|
Resource r_ = {0};
|
||||||
Foo foo_ = {bar, 50, sizeof(bar)/sizeof(Bar)};
|
Resource *r = &r_;
|
||||||
Foo &foo = foo_;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user