Skip to content

Commit 9025643

Browse files
committed
fix generation of TYPE ENUMERATION
1 parent b996d83 commit 9025643

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/exp2python/src/classes_python.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,29 +1960,28 @@ TYPEenum_lib_print( const Type type, FILE * f ) {
19601960
} else {
19611961
fprintf( f, "\n# ENUMERATION TYPE %s\n", TYPEget_name( type ) );
19621962
}
1963-
/* first write all the values of the enum */
1964-
DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM );
19651963
/* then outputs the enum */
19661964
if( is_python_keyword( TYPEget_name( type ) ) ) {
1967-
fprintf( f, "%s_ = ENUMERATION(", TYPEget_name( type ) );
1965+
fprintf( f, "%s_ = ENUMERATION('%s_','", TYPEget_name( type ), TYPEget_name( type ) );
19681966
} else {
1969-
fprintf( f, "%s = ENUMERATION(", TYPEget_name( type ) );
1967+
fprintf( f, "%s = ENUMERATION('%s','", TYPEget_name( type ), TYPEget_name( type ) );
19701968
}
1971-
/* set up the dictionary info */
19721969

1970+
/* set up the dictionary info */
19731971
DICTdo_type_init( ENUM_TYPEget_items( type ), &de, OBJ_ENUM );
19741972
while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) {
19751973
strncpy( c_enum_ele, EnumCElementName( type, expr ), BUFSIZ );
19761974
if( is_python_keyword( EXPget_name( expr ) ) ) {
1977-
fprintf( f, "\n'%s_',", EXPget_name( expr ) );
1975+
fprintf( f, "%s_ ", EXPget_name( expr ) );
19781976
} else {
1979-
fprintf( f, "\n\t'%s',", EXPget_name( expr ) );
1977+
fprintf( f, "%s ", EXPget_name( expr ) );
19801978
}
19811979
}
1982-
fprintf( f, "\n\tscope = schema_scope)\n" );
1980+
fprintf( f, "')\n" );
19831981
}
19841982

19851983

1984+
19861985
void Type_Description( const Type, char * );
19871986

19881987
/* return printable version of entire type definition */
@@ -2246,7 +2245,9 @@ TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) {
22462245
fprintf( files->lib, "%s = bool\n", TYPEget_name( type ) );
22472246
} else if( TYPEis_select( type ) ) {
22482247
TYPEselect_lib_print( type, files -> lib );
2249-
} else {
2248+
} else if( TYPEis_enumeration( type ) ) {
2249+
TYPEenum_lib_print( type, files -> lib );
2250+
} else {
22502251
/* the defined datatype inherits from the base type */
22512252
fprintf( files->lib, "# Defined datatype %s\n", TYPEget_name( type ) );
22522253
fprintf( files->lib, "class %s(", TYPEget_name( type ) );

0 commit comments

Comments
 (0)