Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bb2255

Browse files
committed
Modified ManagerGenerator to use TemplateProcessor.
1 parentec2880f commit2bb2255

File tree

6 files changed

+409
-410
lines changed

6 files changed

+409
-410
lines changed

‎src/bin2cpp/BaseGenerator.cpp‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,22 @@ namespace bin2cpp
5959
std::stringBaseGenerator::lookupTemplateVariable(const std::string& name)
6060
{
6161
if ( name =="bin2cpp_output_file_macro_guard" )returngetCppIncludeGuardMacroName(mContext.headerFilename);
62-
if ( name =="bin2cpp_embedded_file_class_macro_guard" )returngetClassMacroGuardPrefix();
62+
if ( name =="bin2cpp_embedded_file_class_macro_guard_prefix" )returngetClassMacroGuardPrefix();
6363
if ( name =="bin2cpp_output_file_header" )returngetHeaderTemplate();
64+
if ( name =="bin2cpp_filemanager_file_header" )returngetHeaderTemplate(false);
65+
if ( name =="bin2cpp_file_manager_header_file_name" )returnmContext.managerHeaderFilename;
66+
if ( name =="bin2cpp_file_manager_macro_guard_prefix" )returngetFileManagerMacroGuardPrefix();
6467
if ( name =="bin2cpp_baseclass" )returnmContext.baseClass;
6568
if ( name =="bin2cpp_classname" )returngetClassName();
69+
if ( name =="bin2cpp_namespace" )returnmContext.codeNamespace;
70+
if ( name =="bin2cpp_baseclass_uppercase" )returnra::strings::Uppercase(mContext.baseClass);
71+
if ( name =="bin2cpp_classname_uppercase" )returnra::strings::Uppercase(getClassName());
72+
if ( name =="bin2cpp_namespace_uppercase" )returnra::strings::Lowercase(mContext.codeNamespace);
73+
if ( name =="bin2cpp_baseclass_lowercase" )returnra::strings::Lowercase(mContext.baseClass);
74+
if ( name =="bin2cpp_classname_lowercase" )returnra::strings::Lowercase(getClassName());
75+
if ( name =="bin2cpp_namespace_lowercase" )returnra::strings::Lowercase(mContext.codeNamespace);
6676
if ( name =="bin2cpp_function_identifier" )returnmContext.functionIdentifier;
6777
if ( name =="bin2cpp_function_identifier_lowercase" )returnra::strings::Lowercase(mContext.functionIdentifier);
68-
if ( name =="bin2cpp_classname" )returngetClassName();
69-
if ( name =="bin2cpp_namespace" )returnmContext.codeNamespace;
7078
if ( name =="bin2cpp_cpp_getter_function_name" )returngetGetterFunctionName();
7179
if ( name =="bin2cpp_insert_input_file_as_code" )returngetInputFileDataAsCode();
7280
if ( name =="bin2cpp_cpp_header_include_path" )returngetCppHeaderIncludePath();
@@ -283,6 +291,17 @@ namespace bin2cpp
283291
return macroGuardPrefix;
284292
}
285293

294+
std::stringBaseGenerator::getFileManagerMacroGuardPrefix()
295+
{
296+
//define macro guard a macro matching the filename
297+
std::string output;
298+
output +=getCppIncludeGuardMacroName(mContext.codeNamespace.c_str());//prefix the custom namespace for the file manager
299+
if ( !output.empty() )
300+
output +="_";
301+
output +=getCppIncludeGuardMacroName(mContext.managerHeaderFilename);
302+
return output;
303+
}
304+
286305
std::stringBaseGenerator::getImplOfGetFileName()
287306
{
288307
std::string output;
@@ -456,8 +475,8 @@ namespace bin2cpp
456475
"\n"
457476
"namespace ${bin2cpp_namespace}\n"
458477
"{\n"
459-
" #ifndef ${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_CLASS\n"
460-
" #define ${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_CLASS\n"
478+
" #ifndef ${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_CLASS\n"
479+
" #define ${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_CLASS\n"
461480
" class ${bin2cpp_baseclass}\n"
462481
" {\n"
463482
" public:\n"
@@ -468,7 +487,7 @@ namespace bin2cpp
468487
" virtual const char * getBuffer() const = 0;\n"
469488
" virtual bool save(const char * filename) const = 0;\n"
470489
" };\n"
471-
" #endif //${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_CLASS\n"
490+
" #endif //${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_CLASS\n"
472491
" const ${bin2cpp_baseclass} & ${bin2cpp_cpp_getter_function_name}();\n"
473492
"}; //${bin2cpp_namespace}\n"
474493
"\n"
@@ -544,8 +563,8 @@ namespace bin2cpp
544563
"#include <stddef.h>\n"
545564
"#include <stdbool.h>\n"
546565
"\n"
547-
"#ifndef ${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_STRUCT\n"
548-
"#define ${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_STRUCT\n"
566+
"#ifndef ${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_STRUCT\n"
567+
"#define ${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_STRUCT\n"
549568
"typedef struct ${bin2cpp_baseclass} ${bin2cpp_baseclass};\n"
550569
"typedef bool(*${bin2cpp_namespace}_load_func)();\n"
551570
"typedef void(*${bin2cpp_namespace}_free_func)();\n"
@@ -561,7 +580,7 @@ namespace bin2cpp
561580
" ${bin2cpp_namespace}_save_func save;\n"
562581
"} ${bin2cpp_baseclass};\n"
563582
"typedef ${bin2cpp_baseclass}* ${bin2cpp_baseclass}Ptr;\n"
564-
"#endif //${bin2cpp_embedded_file_class_macro_guard}_EMBEDDEDFILE_STRUCT\n"
583+
"#endif //${bin2cpp_embedded_file_class_macro_guard_prefix}_EMBEDDEDFILE_STRUCT\n"
565584
"${bin2cpp_baseclass}* ${bin2cpp_cpp_getter_function_name}(void);\n"
566585
"\n"
567586
"#endif //${bin2cpp_output_file_macro_guard}\n"

‎src/bin2cpp/BaseGenerator.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace bin2cpp
6666
virtual std::stringgetCFileManagerStaticFileRegistrationImplementation();
6767
virtual std::stringgetClassName();
6868
virtual std::stringgetClassMacroGuardPrefix();
69+
virtual std::stringgetFileManagerMacroGuardPrefix();
6970
virtual std::stringgetImplOfGetFileName();
7071
virtual std::stringgetImplOfGetFilePath();
7172
virtual std::stringgetFileClassFileName();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp