@@ -672,8 +672,11 @@ def generate_status_convert_fn_intern_to_abi(self):
672672 # Ignoring the private fields for now
673673 self .dump ('}' )
674674
675- def generate_errhandler_args_convert_fn_intern_to_abi (self ):
676- self .dump (f'{ consts .INLINE_ATTRS } void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code)' )
675+ def generate_errhandler_args_convert_fn_intern_to_abi (self , header_only = False ):
676+ if header_only == True :
677+ self .dump (f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code);' )
678+ return
679+ self .dump (f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code)' )
677680 self .dump ('{' )
678681 lines = []
679682 lines .append ('ompi_communicator_t **comm;' )
@@ -684,19 +687,19 @@ def generate_errhandler_args_convert_fn_intern_to_abi(self):
684687 lines .append ('switch(object_type) {' )
685688 lines .append ('case OMPI_ERRHANDLER_TYPE_COMM:' )
686689 lines .append ('comm = (ompi_communicator_t **)object;' )
687- lines .append (f'*comm = (MPI_Comm *){ ConvertOMPIToStandard .COMM } (*comm);' )
690+ lines .append (f'*comm = (ompi_communicator_t *){ ConvertOMPIToStandard .COMM } (*comm);' )
688691 lines .append ('break;' )
689692 lines .append ('case OMPI_ERRHANDLER_TYPE_WIN:' )
690693 lines .append ('win = (ompi_win_t **)object;' )
691- lines .append (f'*win = (MPI_Win *){ ConvertOMPIToStandard .WIN } (*win);' )
694+ lines .append (f'*win = (ompi_win_t *){ ConvertOMPIToStandard .WIN } (*win);' )
692695 lines .append ('break;' )
693696 lines .append ('case OMPI_ERRHANDLER_TYPE_FILE:' )
694697 lines .append ('file = (ompi_file_t **)object;' )
695- lines .append (f'*file = (MPI_File *){ ConvertOMPIToStandard .FILE } (*file);' )
698+ lines .append (f'*file = (ompi_file_t *){ ConvertOMPIToStandard .FILE } (*file);' )
696699 lines .append ('break;' )
697700 lines .append ('case OMPI_ERRHANDLER_TYPE_INSTANCE:' )
698701 lines .append ('instance = (ompi_instance_t **)object;' )
699- lines .append (f'*instance = (MPI_Session *){ ConvertOMPIToStandard .SESSION } (*instance);' )
702+ lines .append (f'*instance = (ompi_instance_t *){ ConvertOMPIToStandard .SESSION } (*instance);' )
700703 lines .append ('break;' )
701704 lines .append ('};' )
702705 self .dump_lines (lines );
@@ -710,7 +713,8 @@ def define_all(self, type_, constants):
710713 self .define (self .mangle_name (type_ ), self .mangle_name (const ), i + 1 )
711714 self .dump ()
712715
713- def dump_code (self ):
716+ def dump_include_file_code (self ):
717+ '''generate code to use in include source file for converter functions'''
714718 header_guard = '_ABI_CONVERTERS_'
715719 self .dump (f'#ifndef { header_guard } ' )
716720 self .dump (f'#define { header_guard } ' )
@@ -743,11 +747,12 @@ def dump_code(self):
743747 lines .append ('}' )
744748 lines .append ('\n ' )
745749 self .dump_lines (lines )
746- #
747- # TODO: need to do something smarter
748- #
750+
751+ #
752+ # generate prototypes for methods included in standalond converter methods file
753+ #
749754 self .dump ('\n ' )
750- self .dump ( f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code);' )
755+ self .generate_errhandler_args_convert_fn_intern_to_abi ( header_only = True )
751756 self .dump ('\n ' )
752757
753758 # Now generate the conversion code - there's a reason for the order here
@@ -846,39 +851,8 @@ def dump_code(self):
846851""" )
847852 self .dump (f'#endif /* { header_guard } */' )
848853
849- class ABIConverterGlobalBuilder (ABIConverterBuilder ):
850-
851- def generate_errhandler_args_convert_fn_intern_to_abi (self ):
852- self .dump (f'void ompi_convert_errhandler_args_intern_to_abi(void *object, int object_type, int *err_code)' )
853- self .dump ('{' )
854- lines = []
855- lines .append ('ompi_communicator_t **comm;' )
856- lines .append ('ompi_file_t **file;' )
857- lines .append ('ompi_instance_t **instance;' )
858- lines .append ('ompi_win_t **win;' )
859- lines .append (f'*err_code = { ConvertOMPIToStandard .ERROR_CLASS } (*err_code);' )
860- lines .append ('switch(object_type) {' )
861- lines .append ('case OMPI_ERRHANDLER_TYPE_COMM:' )
862- lines .append ('comm = (ompi_communicator_t **)object;' )
863- lines .append (f'*comm = (ompi_communicator_t *){ ConvertOMPIToStandard .COMM } (*comm);' )
864- lines .append ('break;' )
865- lines .append ('case OMPI_ERRHANDLER_TYPE_WIN:' )
866- lines .append ('win = (ompi_win_t **)object;' )
867- lines .append (f'*win = (ompi_win_t *){ ConvertOMPIToStandard .WIN } (*win);' )
868- lines .append ('break;' )
869- lines .append ('case OMPI_ERRHANDLER_TYPE_FILE:' )
870- lines .append ('file = (ompi_file_t **)object;' )
871- lines .append (f'*file = (ompi_file_t *){ ConvertOMPIToStandard .FILE } (*file);' )
872- lines .append ('break;' )
873- lines .append ('case OMPI_ERRHANDLER_TYPE_INSTANCE:' )
874- lines .append ('instance = (ompi_instance_t **)object;' )
875- lines .append (f'*instance = (ompi_instance_t *){ ConvertOMPIToStandard .SESSION } (*instance);' )
876- lines .append ('break;' )
877- lines .append ('};' )
878- self .dump_lines (lines );
879- self .dump ('}' )
880-
881854 def dump_code (self ):
855+ '''generate code to use in standalone source file for converter functions'''
882856 self .dump ('#include "stddef.h"' )
883857 self .dump ('#include "stdint.h"' )
884858 self .dump ('#include "ompi/communicator/communicator.h"' )
@@ -1040,18 +1014,14 @@ def generate_function(prototype, fn_name, internal_fn, out, enable_count=False):
10401014 generate_function (template .prototype , base_name_c , internal_name , out ,
10411015 enable_count = True )
10421016
1043-
1044- def generate_converter_auxiliary_funcs (args , out ):
1045- """Generate ABI auxiliary files. """
1046- out .dump (f'/* { consts .GENERATED_MESSAGE } */' )
1047- builder = ABIConverterGlobalBuilder (out )
1048- builder .dump_code ()
1049-
10501017def generate_converters (args , out ):
1051- """Generate ABI conversion methods. """
1018+ """Generate ABI conversion methods for either the include file or the standalone source file """
10521019 out .dump (f'/* { consts .GENERATED_MESSAGE } */' )
10531020 builder = ABIConverterBuilder (out )
1054- builder .dump_code ()
1021+ if args .type == 'include_file' :
1022+ builder .dump_include_file_code ()
1023+ else :
1024+ builder .dump_code ()
10551025
10561026def generate_header (args , out ):
10571027 """Generate an ABI header and conversion code."""
0 commit comments