Skip to content

Commit 3455040

Browse files
Major refactor, buildable CMake projects
1 parent 5ff4c23 commit 3455040

File tree

186 files changed

+7845
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+7845
-1001
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Austin Brunkhorst
3+
Copyright (c) 2016 Austin Brunkhorst
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#hasExplicitGetter}}{{& explicitGetter}}{{/hasExplicitGetter}}{{^hasExplicitGetter}}&{{& parentQualifiedName}}::{{& name}}{{/hasExplicitGetter}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#hasExplicitSetter}}&{{& parentQualifiedName}}::{{& explicitSetter}}{{/hasExplicitSetter}}{{^hasExplicitSetter}}&{{& parentQualifiedName}}::{{& name}}{{/hasExplicitSetter}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#hasExplicitGetter}}{{#hasParent}}&{{& parentQualifiedName}}::{{& explicitGetter}}{{/hasParent}}{{^hasParent}}&{{& explicitGetter}}{{/hasParent}}{{/hasExplicitGetter}}{{^hasExplicitGetter}}{{#hasParent}}&{{& parentQualifiedName}}::{{name}}{{/hasParent}}{{^hasParent}}&{{& qualifiedName}}{{/hasParent}}{{/hasExplicitGetter}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#hasExplicitSetter}}{{#hasParent}}&{{& parentQualifiedName}}::{{& explicitSetter}}{{/hasParent}}{{^hasParent}}&{{& explicitSetter}}{{/hasParent}}{{/hasExplicitSetter}}{{^hasExplicitSetter}}{{#hasParent}}&{{& parentQualifiedName}}::{{name}}{{/hasParent}}{{^hasParent}}&{{& qualifiedName}}{{/hasParent}}{{/hasExplicitSetter}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* ----------------------------------------------------------------------------
2+
** GENERATED HEADER FILE
3+
** Do not modify the contents of this file.
4+
**
5+
** Ursine3D Meta Generator v{{version}}
6+
** --------------------------------------------------------------------------*/
7+
8+
#pragma once
9+
10+
namespace ursine { namespace meta { class ReflectionDatabase; } }
11+
12+
namespace meta_generated
13+
{
14+
extern void AllocateModuleFile{{targetName}}{{moduleFileName}}(ursine::meta::ReflectionDatabase &db);
15+
extern void DefineModuleFile{{targetName}}{{moduleFileName}}(ursine::meta::ReflectionDatabase &db);
16+
}

Templates/source.mustache renamed to Resources/Templates/module-file-source.mustache

Lines changed: 36 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
/* ----------------------------------------------------------------------------
2+
** GENERATED SOURCE FILE
3+
** Do not modify the contents of this file.
4+
**
5+
** Ursine3D Meta Generator v{{version}}
6+
** --------------------------------------------------------------------------*/
17
{{#usingPrecompiledHeader}}#include "{{precompiledHeader}}"
28
{{/usingPrecompiledHeader}}
3-
#include "{{ouputHeaderFile}}"
49

5-
#if !defined(URSINE_REFLECTION_INCLUDED)
10+
#include "{{moduleFileHeader}}"
11+
#include "{{moduleFileSourceHeader}}"
612

7-
#include <Utilities/MacroUtils.h>
8-
9-
URSINE_ERROR( "<UrsineReflection.h> must be included in the input header file." )
10-
11-
#endif
13+
#include <ReflectionDatabase.h>
1214

1315
namespace m = ursine::meta;
1416

15-
m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
16-
auto &db = m::ReflectionDatabase::Instance( );
17-
17+
void meta_generated::AllocateModuleFile{{targetName}}{{moduleFileName}}(m::ReflectionDatabase &db)
18+
{
1819
///////////////////////////////////////////////////////////////////////////
19-
// Class Allocations
20+
// Class Allocation
2021
///////////////////////////////////////////////////////////////////////////
2122
{{#class}}
2223
{
@@ -45,7 +46,7 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
4546
}
4647
{{/class}}
4748
///////////////////////////////////////////////////////////////////////////
48-
// Enum Allocations
49+
// Enum Allocation
4950
///////////////////////////////////////////////////////////////////////////
5051
{{#enum}}
5152
{
@@ -73,6 +74,10 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
7374
{{/constPtrTypeEnabled}}
7475
}
7576
{{/enum}}
77+
}
78+
79+
void meta_generated::DefineModuleFile{{targetName}}{{moduleFileName}}(m::ReflectionDatabase &db)
80+
{
7681
///////////////////////////////////////////////////////////////////////////
7782
// Global Definitions
7883
///////////////////////////////////////////////////////////////////////////
@@ -99,15 +104,6 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
99104
{{#globalFunction}}
100105
db.AddGlobalFunction( "{{& qualifiedName}}",
101106
static_cast<{{& qualifiedSignature}}>( {{& qualifiedName}} ),
102-
[](m::ArgumentList &args)
103-
{ {{#isVoidReturnType}}
104-
{{> invocationBody}};
105-
106-
return m::Variant { };{{/isVoidReturnType}}{{^isVoidReturnType}}
107-
return m::Variant {
108-
{{> invocationBody}}
109-
};{{/isVoidReturnType}}
110-
},
111107
{
112108
{{> metaDataInitializerList}}
113109
}
@@ -129,7 +125,8 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
129125
};
130126

131127
type.SetEnum<{{& qualifiedName}}>( "{{& displayName}}", {
132-
{{#member}} { "{{key}}", {{value}} }{{^isLast}},{{/isLast}}
128+
{{#member}}
129+
{ "{{key}}", {{value}} }{{^isLast}},{{/isLast}}
133130
{{/member}}
134131
} );
135132

@@ -158,71 +155,44 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
158155
type.LoadBaseClasses( db, typeID, {
159156
{{#baseClass}}typeof( {{& name}} ){{^isLast}},{{/isLast}} {{/baseClass}}
160157
} );
158+
{{#arrayTypeEnabled}}
159+
// Array Constructor
160+
type.SetArrayConstructor<{{& qualifiedName}}>( );{{/arrayTypeEnabled}}
161161

162162
// Constructors
163-
{{#constructor}}
163+
{{#constructor}}{{#enableNonDynamic}}
164164
type.AddConstructor<{{& templateParameters}}>(
165-
[](m::ArgumentList &args)
166-
{
167-
return m::Variant {
168-
{{> invocationBody}}
169-
};
170-
},
171165
{
172166
{{> metaDataInitializerList}}
173-
},
174-
false
167+
}
175168
);
176-
{{/constructor}}
169+
{{/enableNonDynamic}}{{/constructor}}
177170
// Dynamic Constructors
178171
{{#dynamicConstructor}}
179-
type.AddConstructor<{{& templateParameters}}>(
180-
[](m::ArgumentList &args)
181-
{
182-
return m::Variant {
183-
{{> dynamicInvocationBody}}
184-
};
185-
},
172+
type.AddConstructor<{{& dynamicTemplateParameters}}>(
186173
{
187174
{{> metaDataInitializerList}}
188-
},
189-
true
175+
}
190176
);
191177
{{/dynamicConstructor}}
192178
// Fields
193179
{{#field}}
194-
type.AddField<{{parentQualifiedName}}, {{type}}>( "{{& displayName}}",
195-
{{#isGetterAccessible}}[](const m::Variant &obj)
196-
{
197-
auto &instance = obj.GetValue<{{parentQualifiedName}}>( );
198-
199-
return m::Variant { {{> getterBody}} };
200-
},{{/isGetterAccessible}}{{^isGetterAccessible}}
201-
nullptr,{{/isGetterAccessible}}{{#isSetterAccessible}}
202-
[](m::Variant &obj, const m::Variant &value)
203-
{
204-
auto &instance = obj.GetValue<{{parentQualifiedName}}>( );
205-
206-
{{> setterBody}}
207-
},{{/isSetterAccessible}}{{^isSetterAccessible}}
208-
nullptr,{{/isSetterAccessible}}
180+
type.AddField<{{& parentQualifiedName}}, {{& type}}>( "{{& displayName}}",
181+
{{#isGetterAccessible}}{{> getterBody}},{{/isGetterAccessible}}{{^isGetterAccessible}}
182+
((m::FieldGetter<{{& parentQualifiedName}}, {{& type}}, true>::Signature))nullptr,{{/isGetterAccessible}}{{#isSetterAccessible}}
183+
{{> setterBody}},{{/isSetterAccessible}}{{^isSetterAccessible}}
184+
(m::FieldSetter<{{& parentQualifiedName}}, {{& type}}, true>::Signature)nullptr,{{/isSetterAccessible}}
209185
{
210186
{{> metaDataInitializerList}}
211187
}
212188
);
213189
{{/field}}
214190
// Static Fields
215191
{{#staticField}}
216-
type.AddStaticField<{{& parentQualifiedName}}, {{type}}>( "{{& displayName}}",
217-
{{#isGetterAccessible}}[](void)
218-
{
219-
return m::Variant { {{> getterBody}} };
220-
},{{/isGetterAccessible}}{{^isGetterAccessible}}
192+
type.AddStaticField<{{& parentQualifiedName}}, {{& type}}>( "{{& displayName}}",
193+
{{#isGetterAccessible}}{{> getterBody}},{{/isGetterAccessible}}{{^isGetterAccessible}}
221194
nullptr,{{/isGetterAccessible}}{{#isSetterAccessible}}
222-
[](const m::Argument &value)
223-
{
224-
{{> setterBody}}
225-
},{{/isSetterAccessible}}{{^isSetterAccessible}}
195+
{{> setterBody}},{{/isSetterAccessible}}{{^isSetterAccessible}}
226196
nullptr,{{/isSetterAccessible}}
227197
{
228198
{{> metaDataInitializerList}}
@@ -233,17 +203,6 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
233203
{{#method}}
234204
type.AddMethod( "{{name}}",
235205
static_cast<{{& qualifiedSignature}}>( &{{parentQualifiedName}}::{{name}} ),
236-
[](m::Variant &obj, m::ArgumentList &args)
237-
{
238-
auto &instance = obj.GetValue<{{parentQualifiedName}}>( );
239-
{{#isVoidReturnType}}
240-
instance.{{> invocationBody}};
241-
242-
return m::Variant { };{{/isVoidReturnType}}{{^isVoidReturnType}}
243-
return m::Variant {
244-
instance.{{> invocationBody}}
245-
};{{/isVoidReturnType}}
246-
},
247206
{
248207
{{> metaDataInitializerList}}
249208
}
@@ -253,15 +212,6 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
253212
{{#staticMethod}}
254213
type.AddStaticMethod<{{parentQualifiedName}}>( "{{name}}",
255214
static_cast<{{& qualifiedSignature}}>( {{parentQualifiedName}}::{{& qualifiedName}} ),
256-
[](m::ArgumentList &args)
257-
{ {{#isVoidReturnType}}
258-
{{parentQualifiedName}}::{{> invocationBody}};
259-
260-
return m::Variant { };{{/isVoidReturnType}}{{^isVoidReturnType}}
261-
return m::Variant {
262-
{{parentQualifiedName}}::{{> invocationBody}}
263-
};{{/isVoidReturnType}}
264-
},
265215
{
266216
{{> metaDataInitializerList}}
267217
}
@@ -270,4 +220,4 @@ m::ReflectionDatabase::Initializer {{targetName}}Initializer([] {
270220
m::TypeInfo<{{& qualifiedName}}>::Defined = true;
271221
}
272222
}{{/class}}
273-
});
223+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* ----------------------------------------------------------------------------
2+
** GENERATED HEADER FILE
3+
** Do not modify the contents of this file.
4+
**
5+
** Ursine3D Meta Generator v{{version}}
6+
** --------------------------------------------------------------------------*/
7+
8+
#pragma once
9+
10+
#include <Meta/ReflectionModule.h>
11+
12+
namespace meta_generated
13+
{
14+
namespace module
15+
{
16+
class Module{{targetName}} : public ursine::meta::ReflectionModule
17+
{
18+
public:
19+
Module{{targetName}}(ursine::meta::ReflectionDatabase &db);
20+
~Module{{targetName}}(void);
21+
};
22+
}
23+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* ----------------------------------------------------------------------------
2+
** GENERATED SOURCE FILE
3+
** Do not modify the contents of this file.
4+
**
5+
** Ursine3D Meta Generator v{{version}}
6+
** --------------------------------------------------------------------------*/
7+
{{#usingPrecompiledHeader}}#include "{{precompiledHeader}}"
8+
{{/usingPrecompiledHeader}}
9+
10+
#include "{{moduleHeaderFile}}"
11+
12+
///////////////////////////////////////////////////////////////////////////////
13+
// Module Files
14+
///////////////////////////////////////////////////////////////////////////////
15+
16+
{{#moduleFile}}
17+
#include "{{& header}}"{{/moduleFile}}
18+
19+
namespace m = ursine::meta;
20+
21+
meta_generated::Module{{targetName}}::Module{{targetName}}(m::ReflectionDatabase &db)
22+
: ReflectionModule( db )
23+
{
24+
///////////////////////////////////////////////////////////////////////////
25+
// External Allocation
26+
///////////////////////////////////////////////////////////////////////////
27+
{{#external}}
28+
{
29+
{ // Base Type
30+
auto id = db.AllocateType( "{{& displayName}}" );
31+
auto &type = db.types[ id ];
32+
33+
m::TypeInfo<{{& qualifiedName}}>::Register( id, type, true );
34+
}
35+
{{#ptrTypeEnabled}}
36+
{ // Pointer Type
37+
auto id = db.AllocateType( "{{& displayName}}*" );
38+
auto &type = db.types[ id ];
39+
40+
m::TypeInfo<{{& qualifiedName}}*>::Register( id, type, false );
41+
}
42+
{{/ptrTypeEnabled}}
43+
{{#constPtrTypeEnabled}}
44+
{ // Const Pointer Type
45+
auto id = db.AllocateType( "const {{& displayName}}*" );
46+
auto &type = db.types[ id ];
47+
48+
m::TypeInfo<const {{& qualifiedName}}*>::Register( id, type, false );
49+
}
50+
{{/constPtrTypeEnabled}}
51+
}
52+
{{/external}}
53+
///////////////////////////////////////////////////////////////////////////
54+
// Module File Allocation
55+
///////////////////////////////////////////////////////////////////////////
56+
{{#moduleFile}}
57+
AllocateModuleFile{{targetName}}{{& name}}( db );{{/moduleFile}}
58+
}
59+
60+
meta_generated::Module{{targetName}}::~Module{{targetName}}(void)
61+
{
62+
///////////////////////////////////////////////////////////////////////////
63+
// Module File Definition
64+
///////////////////////////////////////////////////////////////////////////
65+
{{#moduleFile}}
66+
DefineModuleFile{{targetName}}{{& name}}( db );{{/moduleFile}}
67+
}

Source/CMake/FindLLVM.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set(LLVM_SEARCH_PATHS
2+
${LLVM_ROOT}
3+
$ENV{LLVM_ROOT}
4+
)
5+
6+
set(LIBCLANG_LIBRARY_NAME "libclang${CMAKE_STATIC_LIBRARY_SUFFIX}")
7+
set(LIBCLANG_SHARED_LIBRARY_NAME "libclang${CMAKE_SHARED_LIBRARY_SUFFIX}")
8+
9+
# include directories
10+
find_path(LLVM_INCLUDE_DIRS
11+
NAMES "clang-c/Index.h"
12+
PATHS ${LLVM_SEARCH_PATHS}
13+
PATH_SUFFIXES "include"
14+
)
15+
16+
# static library directory
17+
find_path(LLVM_LIBRARY_DIR
18+
NAMES ${LIBCLANG_LIBRARY_NAME}
19+
PATHS ${LLVM_SEARCH_PATHS}
20+
PATH_SUFFIXES "lib"
21+
)
22+
23+
# shared library directory
24+
find_path(LLVM_BINARY_DIR
25+
NAMES ${LIBCLANG_SHARED_LIBRARY_NAME}
26+
PATHS ${LLVM_SEARCH_PATHS}
27+
PATH_SUFFIXES "bin"
28+
)
29+
30+
# unable to find everything
31+
if (NOT LLVM_INCLUDE_DIRS OR
32+
NOT LLVM_LIBRARY_DIR OR
33+
NOT LLVM_BINARY_DIR)
34+
message(SEND_ERROR
35+
"Unable to find LLVM installation. "
36+
"Make sure that \"LLVM_ROOT\" is set with the installation directory in either an environment variable or through the CMake GUI."
37+
)
38+
endif ()
39+
40+
set(LLVM_LIBCLANG_LIBRARY "${LLVM_LIBRARY_DIR}/${LIBCLANG_LIBRARY_NAME}")
41+
set(LLVM_LIBCLANG_SHARED_LIBRARY "${LLVM_BINARY_DIR}/${LIBCLANG_SHARED_LIBRARY_NAME}")

Source/Common/Compiler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#if _MSC_VER && !__INTEL_COMPILER
4+
5+
#define COMPILER_MSVC
6+
7+
#endif
File renamed without changes.

0 commit comments

Comments
 (0)