mirror of
https://github.com/AxioDL/CodeGen.git
synced 2026-07-11 06:18:36 -07:00
Fixed some build errors, added support for enum iteration
This commit is contained in:
+3
-2
@@ -1,9 +1,10 @@
|
||||
# Define CODEGEN_OUT_PATH and CODEGEN_SRC_PATH, then include this file in a qmake project
|
||||
# Define CODEGEN_DIR, CODEGEN_OUT_PATH and CODEGEN_SRC_PATH, then include this file in a qmake project
|
||||
# The include must be at the bottom of the file (after SOURCES, HEADERS, and INCLUDEPATH are all fully initialized)
|
||||
Codegen.name = Codegen
|
||||
Codegen.input = SOURCES
|
||||
Codegen.output = $$CODEGEN_OUT_PATH
|
||||
Codegen.variable_out = SOURCES
|
||||
Codegen.commands = python $$EXTERNALS_DIR/CodeGen/codegen.py -pwd $$CODEGEN_SRC_PATH -cmdinput -include $$INCLUDEPATH -sourcefiles $$SOURCES $$HEADERS -o $$CODEGEN_OUT_PATH
|
||||
Codegen.commands = python $$CODEGEN_DIR/codegen.py -pwd $$CODEGEN_SRC_PATH -cmdinput -include $$INCLUDEPATH -sourcefiles $$SOURCES $$HEADERS -o $$CODEGEN_OUT_PATH
|
||||
Codegen.CONFIG += target_predeps combine
|
||||
QMAKE_EXTRA_COMPILERS += Codegen
|
||||
DEFINES += WITH_CODEGEN
|
||||
|
||||
@@ -303,6 +303,7 @@ def RunCodegen():
|
||||
SourceFiles += glob.glob("%s\\**\\*.h" % SourceRoot, recursive=True)
|
||||
OutCodegenSource = OutputCppSource
|
||||
|
||||
print("Codegen Input: " + " ".join(SourceFiles))
|
||||
print("Build Dir: " + ExportPath)
|
||||
|
||||
# Clang index
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <cstring>
|
||||
#include <ctype.h>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
typedef std::unordered_map<int, const char*> CEnumNameMap;
|
||||
typedef std::map<int, const char*> CEnumNameMap;
|
||||
|
||||
/** Provides runtime information about enum types */
|
||||
template<typename T, typename = typename std::enable_if< std::is_enum<T>::value >::type>
|
||||
@@ -65,9 +65,33 @@ public:
|
||||
*/
|
||||
inline static T ErrorValue()
|
||||
{
|
||||
return skErrorValue;
|
||||
return (T) skErrorValue;
|
||||
}
|
||||
|
||||
/** Iterator class for iterating through all possible enum values */
|
||||
class CIterator
|
||||
{
|
||||
CEnumNameMap::const_iterator mInternalIterator;
|
||||
|
||||
public:
|
||||
CIterator()
|
||||
{
|
||||
mInternalIterator = skNameMap.cbegin();
|
||||
}
|
||||
|
||||
inline T Value() const { return (T) mInternalIterator->first; }
|
||||
inline const char* Name() const { return mInternalIterator->second; }
|
||||
inline operator bool() const { return mInternalIterator != skNameMap.cend(); }
|
||||
inline CIterator& operator++() { mInternalIterator++; return *this; }
|
||||
inline CIterator operator++(int){ CIterator RetV = *this; mInternalIterator++; return RetV; }
|
||||
};
|
||||
};
|
||||
|
||||
/** Easier accessor function */
|
||||
template<typename T>
|
||||
inline const char* EnumValueName(T InEnum)
|
||||
{
|
||||
return TEnumReflection<T>::ConvertValueToString(InEnum);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user