@@ -100,8 +100,19 @@ def generateErrorMessage(indent_level, vuid, cur_cmd, message, object_info):
100100class LoaderSourceOutputGenerator (AutomaticSourceOutputGenerator ):
101101 """Generate loader source using XML element attributes from registry"""
102102
103+ def getProto (self , cur_cmd , allow_export = True ):
104+ # Start by making it a C calling convention
105+ func_proto = cur_cmd .cdecl .replace (
106+ "XRAPI_ATTR" , 'extern "C" XRAPI_ATTR' )
107+ if allow_export and self .isCoreExtensionName (cur_cmd .ext_name ):
108+ # Export core functions, if permitted.
109+ func_proto = func_proto .replace (
110+ "XRAPI_ATTR" , 'LOADER_EXPORT XRAPI_ATTR' )
111+ return func_proto
112+
103113 # Override the base class header warning so the comment indicates this file.
104114 # self the LoaderSourceOutputGenerator object
115+
105116 def outputGeneratedHeaderWarning (self ):
106117 generated_warning = '// *********** THIS FILE IS GENERATED - DO NOT EDIT ***********\n '
107118 generated_warning += '// See loader_source_generator.py for modifications\n '
@@ -206,13 +217,7 @@ def outputLoaderManualFuncs(self):
206217 if cur_cmd .protect_value :
207218 manual_funcs += '#if %s\n ' % cur_cmd .protect_string
208219
209- # Use the Cdecl directly from the XML
210- func_proto = cur_cmd .cdecl
211-
212- # Export only core functions
213- if self .isCoreExtensionName (cur_cmd .ext_name ):
214- func_proto = func_proto .replace (
215- "XRAPI_ATTR" , "LOADER_EXPORT XRAPI_ATTR" )
220+ func_proto = self .getProto (cur_cmd )
216221
217222 # Output the standard API form of the command
218223 manual_funcs += func_proto
@@ -222,7 +227,7 @@ def outputLoaderManualFuncs(self):
222227 # loader, add a prototype for the terminator (unless it doesn't have a terminator)
223228 if ((cur_cmd .name in MANUAL_LOADER_INSTANCE_FUNCS or cur_cmd .name in MANUAL_LOADER_INSTANCE_TERMINATOR_FUNCS )
224229 and cur_cmd .name not in self .no_trampoline_or_terminator ):
225- manual_funcs += func_proto .replace (
230+ manual_funcs += self . getProto ( cur_cmd , allow_export = False ) .replace (
226231 "XRAPI_CALL xr" , "XRAPI_CALL LoaderXrTerm" )
227232 manual_funcs += '\n '
228233
@@ -493,12 +498,7 @@ def outputLoaderGeneratedFuncs(self):
493498
494499 if cur_cmd .protect_value :
495500 generated_funcs += '#if %s\n ' % cur_cmd .protect_string
496- decl = cur_cmd .cdecl .replace (";" , " XRLOADER_ABI_TRY {\n " )
497-
498- # Export only core functions
499- if self .isCoreExtensionName (cur_cmd .ext_name ):
500- decl = decl .replace (
501- "XRAPI_ATTR" , "LOADER_EXPORT XRAPI_ATTR" )
501+ decl = self .getProto (cur_cmd ).replace (";" , " XRLOADER_ABI_TRY {\n " )
502502
503503 generated_funcs += decl
504504 generated_funcs += tramp_variable_defines
0 commit comments