Skip to content

Commit fd8b7e3

Browse files
committed
exp2py: reduce TYPE output to class level pass statement for simple types
1 parent 0be8f43 commit fd8b7e3

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

src/exp2python/src/classes_python.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,22 +2012,26 @@ TYPEprint_descriptions( const Type type, FILES * files, Schema schema ) {
20122012
} else {
20132013
fprintf( files->lib, "%s):\n", output );
20142014
}
2015-
fprintf( files->lib, "\tdef __init__(self,*kargs):\n" );
2016-
fprintf( files->lib, "\t\tpass\n" );
2017-
/* call the where / rules */
2018-
LISTdo( type->where, w, Where )
2019-
if( strcmp( w->label->name, "<unnamed>" ) ) {
2020-
/* define a function with the name 'label' */
2021-
fprintf( files->lib, "\t\tself.%s()\n", w->label->name );
2022-
} else {
2023-
/* no label */
2024-
fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number );
2025-
where_rule_number ++;
2015+
2016+
if (LISTempty(type->where)) {
2017+
fprintf( files->lib, "\tpass\n" );
2018+
} else {
2019+
fprintf( files->lib, "\tdef __init__(self, *args):\n" );
2020+
/* call the where / rules */
2021+
LISTdo( type->where, w, Where )
2022+
if( strcmp( w->label->name, "<unnamed>" ) ) {
2023+
/* define a function with the name 'label' */
2024+
fprintf( files->lib, "\t\tself.%s()\n", w->label->name );
2025+
} else {
2026+
/* no label */
2027+
fprintf( files->lib, "\t\tself.unnamed_wr_%i()\n", where_rule_number );
2028+
where_rule_number ++;
2029+
}
2030+
LISTod
2031+
fprintf( files->lib, "\n" );
2032+
/* then we process the where rules */
2033+
WHEREPrint( type->where, 0, files->lib );
20262034
}
2027-
LISTod
2028-
fprintf( files->lib, "\n" );
2029-
/* then we process the where rules */
2030-
WHEREPrint( type->where, 0, files->lib );
20312035
}
20322036
} else { /* TODO: cleanup, currently this is deadcode */
20332037
switch( TYPEget_body( type )->type ) {

0 commit comments

Comments
 (0)