@@ -58,52 +58,29 @@ namespace bin2cpp
5858
5959 bool BaseGenerator::lookupStringVariable (const std::string& name, std::string& output)
6060 {
61- if ( name == " bin2cpp_output_file_macro_guard" ) { output = getCppIncludeGuardMacroName (mContext .headerFilename ); return true ; }
62- if ( name == " bin2cpp_output_file_header" ) { output = getHeaderTemplate (); return true ; }
63- if ( name == " bin2cpp_file_object_macro_guard_prefix" ) { output = getClassMacroGuardPrefix (); return true ; }
61+ if ( name == " bin2cpp_baseclass" ) { output = mContext .baseClass ; return true ; }
62+ if ( name == " bin2cpp_classname" ) { output = getClassName (); return true ; }
63+ if ( name == " bin2cpp_cpp_save_method_template" ) { output = getCppSaveMethodTemplate (); return true ; }
64+ if ( name == " bin2cpp_file_manager_c_registration_implementation" && mContext .registerFiles ) { output = getCFileManagerStaticFileRegistrationImplementation (); return true ; }
65+ if ( name == " bin2cpp_file_manager_c_registration_post_init_implementation" && mContext .registerFiles ) { output = getCFileManagerRegistrationPostInitImplementation (); return true ; }
66+ if ( name == " bin2cpp_file_manager_c_registration_predeclaration" && mContext .registerFiles ) { output = getCFileManagerRegistrationPredeclarationImplementation (); return true ; }
67+ if ( name == " bin2cpp_file_manager_cpp_registration_implementation" && mContext .registerFiles ) { output = getCppFileManagerRegistrationImplementationTemplate (); return true ; }
6468 if ( name == " bin2cpp_file_manager_file_header" ) { output = getHeaderTemplate (false ); return true ; }
6569 if ( name == " bin2cpp_file_manager_header_file_name" ) { output = mContext .managerHeaderFilename ; return true ; }
6670 if ( name == " bin2cpp_file_manager_macro_guard_prefix" ) { output = getFileManagerMacroGuardPrefix (); return true ; }
67- if ( name == " bin2cpp_baseclass" ) { output = mContext .baseClass ; return true ; }
68- if ( name == " bin2cpp_classname" ) { output = getClassName (); return true ; }
69- if ( name == " bin2cpp_namespace" ) { output = mContext .codeNamespace ; return true ; }
70- // if ( name == "bin2cpp_baseclass_uppercase" ) { output = ra::strings::Uppercase(mContext.baseClass); return true; }
71- // if ( name == "bin2cpp_classname_uppercase" ) { output = ra::strings::Uppercase(getClassName()); return true; }
72- // if ( name == "bin2cpp_namespace_uppercase" ) { output = ra::strings::Lowercase(mContext.codeNamespace); return true; }
73- // if ( name == "bin2cpp_baseclass_lowercase" ) { output = ra::strings::Lowercase(mContext.baseClass); return true; }
74- // if ( name == "bin2cpp_classname_lowercase" ) { output = ra::strings::Lowercase(getClassName()); return true; }
75- // if ( name == "bin2cpp_namespace_lowercase" ) { output = ra::strings::Lowercase(mContext.codeNamespace); return true; }
76- if ( name == " bin2cpp_function_identifier" ) { output = mContext .functionIdentifier ; return true ; }
71+ if ( name == " bin2cpp_file_object_file_name_impl" ) { output = getFileObjectGetFileNameImplementation (); return true ; }
72+ if ( name == " bin2cpp_file_object_file_name" ) { output = getFileObjectFileName (); return true ; }
73+ if ( name == " bin2cpp_file_object_file_path_impl" ) { output = getFileObjectGetFilePathImplementation (); return true ; }
74+ if ( name == " bin2cpp_file_object_file_path" ) { output = getFileObjectFilePath (); return true ; }
75+ if ( name == " bin2cpp_file_object_getter_function_name" ) { output = getFileObjectGetterFunctionName (); return true ; }
76+ if ( name == " bin2cpp_file_object_macro_guard_prefix" ) { output = getClassMacroGuardPrefix (); return true ; }
7777 if ( name == " bin2cpp_function_identifier_lowercase" ) { output = ra::strings::Lowercase (mContext .functionIdentifier ); return true ; }
78- if ( name == " bin2cpp_getter_function_name" ) { output = getGetterFunctionName (); return true ; }
79- if ( name == " bin2cpp_header_source_file_include_path" ) { output = getCppHeaderIncludePath (); return true ; }
80- if ( name == " bin2cpp_file_object_file_name_impl" ) { output = getFileClassGetFileNameImplementation (); return true ; }
81- if ( name == " bin2cpp_file_object_file_path_impl" ) { output = getFileClassGetFilePathImplementation (); return true ; }
82- if ( name == " bin2cpp_file_object_file_name" ) { output = getFileClassFileName (); return true ; }
83- if ( name == " bin2cpp_file_object_file_path" ) { output = getFileClassFilePath (); return true ; }
84- if ( name == " bin2cpp_cpp_get_save_method_impl" ) { output = getCppSaveMethodTemplate (); return true ; }
85- if ( name == " bin2cpp_cpp_get_file_manager_registration_impl" && mContext .registerFiles ) { output = getCppFileManagerRegistrationImplementationTemplate (); return true ; }
86- if ( name == " bin2cpp_c_file_manager_registration_predeclaration" && mContext .registerFiles ) { output = getCFileManagerRegistrationPredeclarationImplementation (); return true ; }
87- if ( name == " bin2cpp_c_file_manager_registration_implementation" && mContext .registerFiles ) { output = getCFileManagerStaticFileRegistrationImplementation (); return true ; }
88-
89- if ( name == " bin2cpp_c_file_manager_registration_post_init_impl" && mContext .registerFiles )
90- {
91- std::string tmp;
92- tmp += " \n " ;
93- tmp += " // register when loaded if static initialisation does not work\n " ;
94- tmp += " ${bin2cpp_namespace}_filemanager_register_file(file);\n " ;
95- output = tmp;
96- return true ;
97- }
98-
99- if ( name == " bin2cpp_input_file_size" )
100- {
101- // determine file properties
102- uint32_t file_size = ra::filesystem::GetFileSize (mContext .inputFilePath .c_str ());
103- std::string file_size_str = ra::strings::ToString (file_size);
104- output = file_size_str;
105- return true ;
106- }
78+ if ( name == " bin2cpp_function_identifier" ) { output = mContext .functionIdentifier ; return true ; }
79+ if ( name == " bin2cpp_header_file_include_path" ) { output = getHeaderFileIncludePath (); return true ; }
80+ if ( name == " bin2cpp_input_file_size" ) { output = ra::strings::ToString (ra::filesystem::GetFileSize (mContext .inputFilePath .c_str ())); return true ; }
81+ if ( name == " bin2cpp_namespace" ) { output = mContext .codeNamespace ; return true ; }
82+ if ( name == " bin2cpp_output_file_header_template" ) { output = getHeaderTemplate (); return true ; }
83+ if ( name == " bin2cpp_output_file_macro_guard" ) { output = getIncludeGuardMacroName (mContext .headerFilename ); return true ; }
10784
10885 // Unknown name
10986 return false ;
@@ -124,7 +101,7 @@ namespace bin2cpp
124101 // protected methods
125102 // -------------------------------
126103
127- std::string BaseGenerator::getGetterFunctionName ()
104+ std::string BaseGenerator::getFileObjectGetterFunctionName ()
128105 {
129106
130107 std::string getter;
@@ -243,7 +220,7 @@ namespace bin2cpp
243220 std::string output;
244221 output << " typedef const " << mContext .baseClass << " & (*t_func)();\n " ;
245222 output << " extern bool RegisterFile(t_func iFunctionPointer);\n " ;
246- output << " static bool k" << className << " Registered = " << mContext .codeNamespace << " ::RegisterFile(&" << getGetterFunctionName () << " );\n " ;
223+ output << " static bool k" << className << " Registered = " << mContext .codeNamespace << " ::RegisterFile(&" << getFileObjectGetterFunctionName () << " );\n " ;
247224 output << " \n " ;
248225 return output;
249226 }
@@ -284,6 +261,15 @@ namespace bin2cpp
284261 return output;
285262 }
286263
264+ std::string BaseGenerator::getCFileManagerRegistrationPostInitImplementation ()
265+ {
266+ std::string output;
267+ output += " \n " ;
268+ output += " // register when loaded if static initialisation does not work\n " ;
269+ output += " ${bin2cpp_namespace}_filemanager_register_file(file);\n " ;
270+ return output;
271+ }
272+
287273 std::string BaseGenerator::getClassName ()
288274 {
289275 std::string functionIdentifier = ra::strings::CapitalizeFirstCharacter (mContext .functionIdentifier );
@@ -307,14 +293,14 @@ namespace bin2cpp
307293 {
308294 // define macro guard a macro matching the filename
309295 std::string output;
310- output += getCppIncludeGuardMacroName (mContext .codeNamespace .c_str ()); // prefix the custom namespace for the file manager
296+ output += getIncludeGuardMacroName (mContext .codeNamespace .c_str ()); // prefix the custom namespace for the file manager
311297 if ( !output.empty () )
312298 output += " _" ;
313- output += getCppIncludeGuardMacroName (mContext .managerHeaderFilename );
299+ output += getIncludeGuardMacroName (mContext .managerHeaderFilename );
314300 return output;
315301 }
316302
317- std::string BaseGenerator::getFileClassGetFileNameImplementation ()
303+ std::string BaseGenerator::getFileObjectGetFileNameImplementation ()
318304 {
319305 std::string output;
320306
@@ -341,7 +327,7 @@ namespace bin2cpp
341327 return output;
342328 }
343329
344- std::string BaseGenerator::getFileClassGetFilePathImplementation ()
330+ std::string BaseGenerator::getFileObjectGetFilePathImplementation ()
345331 {
346332 std::string output;
347333
@@ -378,7 +364,7 @@ namespace bin2cpp
378364 return output;
379365 }
380366
381- std::string BaseGenerator::getFileClassFileName ()
367+ std::string BaseGenerator::getFileObjectFileName ()
382368 {
383369 std::string output;
384370
@@ -389,7 +375,7 @@ namespace bin2cpp
389375 return output;
390376 }
391377
392- std::string BaseGenerator::getFileClassFilePath ()
378+ std::string BaseGenerator::getFileObjectFilePath ()
393379 {
394380 std::string output;
395381
@@ -413,7 +399,7 @@ namespace bin2cpp
413399 {
414400 // if reported path is not specified ?
415401 // report the same as getFileName()
416- output = getFileClassFileName ();
402+ output = getFileObjectFileName ();
417403 return output;
418404 }
419405
@@ -422,7 +408,7 @@ namespace bin2cpp
422408 return output;
423409 }
424410
425- std::string BaseGenerator::getCppHeaderIncludePath ()
411+ std::string BaseGenerator::getHeaderFileIncludePath ()
426412 {
427413 return mContext .headerFilename ;
428414 }
@@ -473,7 +459,7 @@ namespace bin2cpp
473459 bool BaseGenerator::createCppHeaderFile (const char * header_file_path)
474460 {
475461 const std::string text = " "
476- " ${bin2cpp_output_file_header }"
462+ " ${bin2cpp_output_file_header_template }"
477463 " #ifndef ${bin2cpp_output_file_macro_guard}\n "
478464 " #define ${bin2cpp_output_file_macro_guard}\n "
479465 " \n "
@@ -494,7 +480,7 @@ namespace bin2cpp
494480 " virtual bool save(const char * filename) const = 0;\n "
495481 " };\n "
496482 " #endif //${bin2cpp_file_object_macro_guard_prefix}_FILE_OBJECT_CLASS\n "
497- " const ${bin2cpp_baseclass} & ${bin2cpp_getter_function_name }();\n "
483+ " const ${bin2cpp_baseclass} & ${bin2cpp_file_object_getter_function_name }();\n "
498484 " }; //${bin2cpp_namespace}\n "
499485 " \n "
500486 " #endif //${bin2cpp_output_file_macro_guard}\n "
@@ -562,7 +548,7 @@ namespace bin2cpp
562548 bool BaseGenerator::createCHeaderFile (const char * file_path)
563549 {
564550 const std::string text = " "
565- " ${bin2cpp_output_file_header }"
551+ " ${bin2cpp_output_file_header_template }"
566552 " #ifndef ${bin2cpp_output_file_macro_guard}\n "
567553 " #define ${bin2cpp_output_file_macro_guard}\n "
568554 " \n "
@@ -587,7 +573,7 @@ namespace bin2cpp
587573 " } ${bin2cpp_baseclass};\n "
588574 " typedef ${bin2cpp_baseclass}* ${bin2cpp_baseclass}Ptr;\n "
589575 " #endif //${bin2cpp_file_object_macro_guard_prefix}_FILE_OBJECT_STRUCT\n "
590- " ${bin2cpp_baseclass}* ${bin2cpp_getter_function_name }(void);\n "
576+ " ${bin2cpp_baseclass}* ${bin2cpp_file_object_getter_function_name }(void);\n "
591577 " \n "
592578 " #endif //${bin2cpp_output_file_macro_guard}\n "
593579 ;
0 commit comments