-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathclasses.c
More file actions
3638 lines (3176 loc) · 142 KB
/
Copy pathclasses.c
File metadata and controls
3638 lines (3176 loc) · 142 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Fed-x parser output module for generating C++ class definitions
** December 5, 1989
** release 2 17-Feb-1992
** release 3 March 1993
** release 4 December 1993
** K. C. Morris
**
** Development of Fed-x was funded by the United States Government,
** and is not subject to copyright.
*******************************************************************
The conventions used in this binding follow the proposed specification
for the STEP Standard Data Access Interface as defined in document
N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7.
*******************************************************************/
/**************************************************************//**
* \file classes.c
*** The functions in this file generate the C++ code for ENTITY **
*** classes, TYPEs, and TypeDescriptors. ***
** **/
/* this is used to add new dictionary calls */
/* #define NEWDICT */
#include <scl_memmgr.h>
#include <stdlib.h>
#include <assert.h>
#include "classes.h"
#include <scl_trace_fprintf.h>
int isAggregateType( const Type t );
int isAggregate( Variable a );
Variable VARis_type_shifter( Variable a );
char * FundamentalType( const Type t, int report_reftypes );
int multiple_inheritance = 1;
int print_logging = 0;
int corba_binding = 0;
int old_accessors = 0;
static int attr_count; /**< number each attr to avoid inter-entity clashes
several classes use attr_count for naming attr dictionary entry
variables. All but the last function generating code for a particular
entity increment a copy of it for naming each attr in the entity.
Here are the functions:
ENTITYhead_print (Entity entity, FILE* file,Schema schema)
LIBdescribe_entity (Entity entity, FILE* file, Schema schema)
LIBcopy_constructor (Entity ent, FILE* file)
LIBstructor_print (Entity entity, FILE* file, Schema schema)
LIBstructor_print_w_args (Entity entity, FILE* file, Schema schema)
ENTITYincode_print (Entity entity, FILES* files,Schema schema)
DAS
*/
static int type_count; ///< number each temporary type for same reason as \sa attr_count
extern int any_duplicates_in_select( const Linked_List list );
extern int unique_types( const Linked_List list );
extern char * non_unique_types_string( const Type type );
static void printEnumCreateHdr( FILE *, const Type );
static void printEnumCreateBody( FILE *, const Type );
static void printEnumAggrCrHdr( FILE *, const Type );
static void printEnumAggrCrBody( FILE *, const Type );
void printAccessHookFriend( FILE *, const char * );
void printAccessHookHdr( FILE *, const char * );
int TYPEget_RefTypeVarNm( const Type t, char * buf, Schema schema );
void TypeBody_Description( TypeBody body, char * buf );
/**
* Turn the string into a new string that will be printed the same as the
* original string. That is, turn backslash into a quoted backslash and
* turn \n into "\n" (i.e. 2 chars).
*
* Mostly replaced by format_for_std_stringout, below. This function is
* still used in one place in ENTITYincode_print().
*/
char * format_for_stringout( char * orig_buf, char * return_buf ) {
char * optr = orig_buf;
char * rptr = return_buf;
while( *optr ) {
if( *optr == '\n' ) {
*rptr = '\\';
rptr++;
*rptr = 'n';
} else if( *optr == '\\' ) {
*rptr = '\\';
rptr++;
*rptr = '\\';
} else {
*rptr = *optr;
}
rptr++;
optr++;
}
*rptr = '\0';
return return_buf;
}
/**
* Like format_for_stringout above, but splits the static string up
* into numerous small ones that are appended to a std::string named
* 'str'. It is assumed that this string already exists and is empty.
*
* This version takes a file pointer and eliminates use of the temp buffer.
*/
void format_for_std_stringout( FILE * f, const char * orig_buf ) {
const char * optr = orig_buf;
char * s_end = "\\n\" );\n";
char * s_begin = " str.append( \"";
fprintf(f, "%s", s_begin );
while( *optr ) {
if( *optr == '\n' ) {
fprintf( f, "%s", s_end );
fprintf( f, "%s", s_begin );
} else if( *optr == '\\' ) {
fprintf( f, "\\\\" );
} else {
fprintf( f, "%c", *optr );
}
optr++;
}
fprintf( f, s_end );
scl_free( orig_buf );
}
void USEREFout( Schema schema, Dictionary refdict, Linked_List reflist, char * type, FILE * file ) {
Dictionary dict;
DictionaryEntry de;
struct Rename * r;
Linked_List list;
char td_name[BUFSIZ];
char sch_name[BUFSIZ];
strncpy( sch_name, PrettyTmpName( SCHEMAget_name( schema ) ), BUFSIZ );
LISTdo( reflist, s, Schema ) {
fprintf( file, " // %s FROM %s; (all objects)\n", type, s->symbol.name );
fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( s->symbol.name ) );
fprintf( file, " is->all_objects_(1);\n" );
if( !strcmp( type, "USE" ) ) {
fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) );
} else {
fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) );
}
}
LISTod
if( !refdict ) {
return;
}
dict = DICTcreate( 10 );
/* sort each list by schema */
/* step 1: for each entry, store it in a schema-specific list */
DICTdo_init( refdict, &de );
while( 0 != ( r = ( struct Rename * )DICTdo( &de ) ) ) {
Linked_List list;
list = ( Linked_List )DICTlookup( dict, r->schema->symbol.name );
if( !list ) {
list = LISTcreate();
DICTdefine( dict, r->schema->symbol.name, ( Generic ) list,
( Symbol * )0, OBJ_UNKNOWN );
}
LISTadd( list, ( Generic ) r );
}
/* step 2: for each list, print out the renames */
DICTdo_init( dict, &de );
while( 0 != ( list = ( Linked_List )DICTdo( &de ) ) ) {
bool first_time = true;
LISTdo( list, r, struct Rename * )
/* note: SCHEMAget_name(r->schema) equals r->schema->symbol.name) */
if( first_time ) {
fprintf( file, " // %s FROM %s (selected objects)\n", type, r->schema->symbol.name );
fprintf( file, " is = new Interface_spec(\"%s\",\"%s\");\n", sch_name, PrettyTmpName( r->schema->symbol.name ) );
if( !strcmp( type, "USE" ) ) {
fprintf( file, " %s::schema->use_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) );
} else {
fprintf( file, " %s::schema->ref_interface_list_()->Append(is);\n", SCHEMAget_name( schema ) );
}
}
if( first_time ) {
first_time = false;
}
if( r->type == OBJ_TYPE ) {
sprintf( td_name, "%s", TYPEtd_name( ( Type )r->object ) );
} else if( r->type == OBJ_FUNCTION ) {
sprintf( td_name, "/* Function not implemented */ 0" );
} else if( r->type == OBJ_PROCEDURE ) {
sprintf( td_name, "/* Procedure not implemented */ 0" );
} else if( r->type == OBJ_RULE ) {
sprintf( td_name, "/* Rule not implemented */ 0" );
} else if( r->type == OBJ_ENTITY ) {
sprintf( td_name, "%s%s%s",
SCOPEget_name( ( ( Entity )r->object )->superscope ),
ENT_PREFIX, ENTITYget_name( ( Entity )r->object ) );
} else {
sprintf( td_name, "/* %c from OBJ_? in expbasic.h not implemented */ 0", r->type );
}
if( r->old != r->nnew ) {
fprintf( file, " // object %s AS %s\n", r->old->name,
r->nnew->name );
if( !strcmp( type, "USE" ) ) {
fprintf( file, " ui = new Used_item(\"%s\", %s, \"%s\", \"%s\");\n", r->schema->symbol.name, td_name, r->old->name, r->nnew->name );
fprintf( file, " is->explicit_items_()->Append(ui);\n" );
fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) );
} else {
fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"%s\", \"%s\");\n", r->schema->symbol.name, td_name, r->old->name, r->nnew->name );
fprintf( file, " is->explicit_items_()->Append(ri);\n" );
fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) );
}
} else {
fprintf( file, " // object %s\n", r->old->name );
if( !strcmp( type, "USE" ) ) {
fprintf( file, " ui = new Used_item(\"%s\", %s, \"\", \"%s\");\n", r->schema->symbol.name, td_name, r->nnew->name );
fprintf( file, " is->explicit_items_()->Append(ui);\n" );
fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ui);\n", SCHEMAget_name( schema ) );
} else {
fprintf( file, " ri = new Referenced_item(\"%s\", %s, \"\", \"%s\");\n", r->schema->symbol.name, td_name, r->nnew->name );
fprintf( file, " is->explicit_items_()->Append(ri);\n" );
fprintf( file, " %s::schema->interface_().explicit_items_()->Append(ri);\n", SCHEMAget_name( schema ) );
}
}
LISTod
}
HASHdestroy( dict );
}
const char * IdlEntityTypeName( Type t ) {
static char name [BUFSIZ];
strcpy( name, TYPE_PREFIX );
if( TYPEget_name( t ) ) {
strcpy( name, FirstToUpper( TYPEget_name( t ) ) );
} else {
return TYPEget_ctype( t );
}
return name;
}
const char * GetAggrElemType( const Type type ) {
Class_Of_Type class;
Type bt;
static char retval [BUFSIZ];
if( isAggregateType( type ) ) {
bt = TYPEget_nonaggregate_base_type( type );
if( isAggregateType( bt ) ) {
strcpy( retval, "ERROR_aggr_of_aggr" );
}
class = TYPEget_type( bt );
/* case TYPE_INTEGER: */
if( class == integer_ ) {
strcpy( retval, "long" );
}
/* case TYPE_REAL:
case TYPE_NUMBER: */
if( ( class == number_ ) || ( class == real_ ) ) {
strcpy( retval, "double" );
}
/* case TYPE_ENTITY: */
if( class == entity_ ) {
strcpy( retval, IdlEntityTypeName( bt ) );
}
/* case TYPE_ENUM: */
/* case TYPE_SELECT: */
if( ( class == enumeration_ )
|| ( class == select_ ) ) {
strcpy( retval, TYPEget_ctype( bt ) );
}
/* case TYPE_LOGICAL: */
if( class == logical_ ) {
strcpy( retval, "Logical" );
}
/* case TYPE_BOOLEAN: */
if( class == boolean_ ) {
strcpy( retval, "Bool" );
}
/* case TYPE_STRING: */
if( class == string_ ) {
strcpy( retval, "string" );
}
/* case TYPE_BINARY: */
if( class == binary_ ) {
strcpy( retval, "binary" );
}
}
return retval;
}
const char * TYPEget_idl_type( const Type t ) {
Class_Of_Type class;
static char retval [BUFSIZ];
/* aggregates are based on their base type
case TYPE_ARRAY:
case TYPE_BAG:
case TYPE_LIST:
case TYPE_SET:
*/
if( isAggregateType( t ) ) {
strcpy( retval, GetAggrElemType( t ) );
/* ///////////////////////// */
/* case TYPE_ARRAY: */
if( TYPEget_type( t ) == array_ ) {
strcat( retval, "__array" );
}
/* case TYPE_LIST: */
if( TYPEget_type( t ) == list_ ) {
strcat( retval, "__list" );
}
/* case TYPE_SET: */
if( TYPEget_type( t ) == set_ ) {
strcat( retval, "__set" );
}
/* case TYPE_BAG: */
if( TYPEget_type( t ) == bag_ ) {
strcat( retval, "__bag" );
}
return retval;
/* //////////////////////// */
}
/* the rest is for things that are not aggregates */
class = TYPEget_type( t );
/* case TYPE_LOGICAL: */
if( class == logical_ ) {
return ( "Logical" );
}
/* case TYPE_BOOLEAN: */
if( class == boolean_ ) {
return ( "Boolean" );
}
/* case TYPE_INTEGER: */
if( class == integer_ ) {
return ( "SDAI_Integer" );
}
/* return ("CORBA::Long");*/
/* case TYPE_REAL:
case TYPE_NUMBER: */
if( ( class == number_ ) || ( class == real_ ) ) {
return ( "SDAI_Real" );
}
/* return ("CORBA::Double"); */
/* case TYPE_STRING: */
if( class == string_ ) {
return ( "char *" );
}
/* case TYPE_BINARY: */
if( class == binary_ ) {
return ( AccessType( t ) );
}
/* case TYPE_ENTITY: */
if( class == entity_ ) {
/* better do this because the return type might go away */
strcpy( retval, IdlEntityTypeName( t ) );
strcat( retval, "_ptr" );
return retval;
/* return ("SDAI_Application_instance_ptr"); */
}
/* case TYPE_ENUM: */
/* case TYPE_SELECT: */
if( class == enumeration_ ) {
strncpy( retval, EnumName( TYPEget_name( t ) ), BUFSIZ - 2 );
strcat( retval, " /*" );
strcat( retval, IdlEntityTypeName( t ) );
strcat( retval, "*/ " );
/* strcat (retval, "_var");*/
return retval;
}
if( class == select_ ) {
return ( IdlEntityTypeName( t ) );
}
/* default returns undefined */
return ( "SCLundefined" );
}
int Handle_FedPlus_Args( int i, char * arg ) {
if( ( ( char )i == 's' ) || ( ( char )i == 'S' ) ) {
multiple_inheritance = 0;
}
if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) {
old_accessors = 1;
}
if( ( char )i == 'L' ) {
print_logging = 1;
}
if( ( ( char )i == 'c' ) || ( ( char )i == 'C' ) ) {
corba_binding = 1;
}
return 0;
}
/**************************************************************//**
** Procedure: generate_attribute_name
** Parameters: Variable a, an Express attribute; char *out, the C++ name
** Description: converts an Express name into the corresponding C++ name
** see relation to generate_dict_attr_name() DAS
** Side Effects:
** Status: complete 8/5/93
******************************************************************/
char * generate_attribute_name( Variable a, char * out ) {
char * temp, *p, *q = out;
temp = EXPRto_string( VARget_name( a ) );
p = ( char * )StrToLower( temp );
if( ! strncmp( p, "self\\", 5 ) ) {
p += 5;
}
while( *p ) {
/* copy p to out, 1 char at time. Skip \n's and spaces, convert */
/* '.' to '_', and convert to lowercase. */
if( ( *p != '\n' ) && ( *p != ' ' ) ) {
if( *p == '.' ) {
*q = '_';
} else {
*q = *p;
}
q++;
}
p++;
}
*q = '\0';
scl_free( temp );
return out;
}
char * generate_attribute_func_name( Variable a, char * out ) {
generate_attribute_name( a, out );
strncpy( out, StrToLower( out ), BUFSIZ );
if( old_accessors ) {
out[0] = toupper( out[0] );
} else {
out[strlen( out )] = '_';
}
return out;
}
/**************************************************************//**
** \fn generate_dict_attr_name
** \param a, an Express attribute
** \param out, the C++ name
** Description: converts an Express name into the corresponding SCL
** dictionary name. The difference between this and the
** generate_attribute_name() function is that for derived
** attributes the name will have the form <parent>.<attr_name>
** where <parent> is the name of the parent containing the
** attribute being derived and <attr_name> is the name of the
** derived attribute. Both <parent> and <attr_name> may
** contain underscores but <parent> and <attr_name> will be
** separated by a period. generate_attribute_name() generates
** the same name except <parent> and <attr_name> will be
** separated by an underscore since it is illegal to have a
** period in a variable name. This function is used for the
** dictionary name (a string) and generate_attribute_name()
** will be used for variable and access function names.
** Side Effects:
** Status: complete 8/5/93
******************************************************************/
char * generate_dict_attr_name( Variable a, char * out ) {
char * temp, *p, *q;
int j;
temp = EXPRto_string( VARget_name( a ) );
p = temp;
if( ! strncmp( StrToLower( p ), "self\\", 5 ) ) {
p = p + 5;
}
/* copy p to out */
strncpy( out, StrToLower( p ), BUFSIZ );
/* DAR - fixed so that '\n's removed */
for( j = 0, q = out; j < BUFSIZ; p++ ) {
/* copy p to out, 1 char at time. Skip \n's, and convert to lc. */
if( *p != '\n' ) {
*q = tolower( *p );
j++;
q++;
}
}
scl_free( temp );
return out;
}
/**************************************************************//**
** Procedure: TYPEget_express_type (const Type t)
** Parameters: const Type t -- type for attribute
** Returns: a string which is the type as it would appear in Express
** Description: supplies the type for error messages
and to register the entity
- calls itself recursively to create a description of
aggregate types
** Side Effects:
** Status: new 1/24/91
******************************************************************/
char * TYPEget_express_type( const Type t ) {
Class_Of_Type class;
Type bt;
char retval [BUFSIZ];
char * n, * permval, * aggr_type;
/* 1. "DEFINED" types */
/* case TYPE_ENUM: */
/* case TYPE_ENTITY: */
/* case TYPE_SELECT: */
if( ( n = TYPEget_name( t ) ) ) {
PrettyTmpName( n );
}
/* 2. "BASE" types */
class = TYPEget_type( t );
/* case TYPE_LOGICAL: */
if( ( class == boolean_ ) || ( class == logical_ ) ) {
return ( "Logical" );
}
/* case TYPE_INTEGER: */
if( class == integer_ ) {
return ( "Integer " );
}
/* case TYPE_REAL:
case TYPE_NUMBER: */
if( ( class == number_ ) || ( class == real_ ) ) {
return ( "Real " );
}
/* case TYPE_STRING: */
if( class == string_ ) {
return ( "String " ) ;
}
/* case TYPE_BINARY: */
if( class == binary_ ) {
return ( "Binary " ) ;
}
/* AGGREGATES
case TYPE_ARRAY:
case TYPE_BAG:
case TYPE_LIST:
case TYPE_SET:
*/
if( isAggregateType( t ) ) {
bt = TYPEget_nonaggregate_base_type( t );
class = TYPEget_type( bt );
/* case TYPE_ARRAY: */
if( TYPEget_type( t ) == array_ ) {
aggr_type = "Array";
}
/* case TYPE_LIST: */
if( TYPEget_type( t ) == list_ ) {
aggr_type = "List";
}
/* case TYPE_SET: */
if( TYPEget_type( t ) == set_ ) {
aggr_type = "Set";
}
/* case TYPE_BAG: */
if( TYPEget_type( t ) == bag_ ) {
aggr_type = "Bag";
}
sprintf( retval, "%s of %s",
aggr_type, TYPEget_express_type( bt ) );
/* this will declare extra memory when aggregate is > 1D */
permval = ( char * )scl_malloc( strlen( retval ) * sizeof( char ) + 1 );
strcpy( permval, retval );
return permval;
}
/* default returns undefined */
printf( "WARNING2: type %s is undefined\n", TYPEget_name( t ) );
return ( "SCLundefined" );
}
/**************************************************************//**
** Procedure: ATTRsign_access_method
** Parameters: const Variable a -- attribute to print
access method signature for
** FILE* file -- file being written to
** Returns: nothing
** Description: prints the signature for an access method
** based on the attribute type
** DAS i.e. prints the header for the attr. access functions
** (get and put attr value) in the entity class def in .h file
** Side Effects:
** Status: complete 17-Feb-1992
******************************************************************/
void ATTRsign_access_methods( Variable a, FILE * file ) {
Type t = VARget_type( a );
char ctype [BUFSIZ];
char attrnm [BUFSIZ];
generate_attribute_func_name( a, attrnm );
strncpy( ctype, AccessType( t ), BUFSIZ );
fprintf( file, " const %s %s() const;\n", ctype, attrnm );
fprintf( file, " void %s (const %s x);\n\n", attrnm, ctype );
return;
}
/**************************************************************//**
** Procedure: ATTRprint_access_methods_get_head
** Parameters: const Variable a -- attribute to find the type for
** FILE* file -- file being written
** Type t - type of the attribute
** Class_Of_Type class -- type name of the class
** const char *attrnm -- name of the attribute
** char *ctype -- (possibly returned) name of the attribute c++ type
** Returns: name to be used for the type of the c++ access functions
** Description: prints the access method get head based on the attribute type
** DAS which being translated is it prints the function header
** for the get attr value access function defined for an
** entity class. This is the .cc file version.
** Side Effects:
** Status: complete 7/15/93 by DDH
******************************************************************/
void ATTRprint_access_methods_get_head( const char * classnm, Variable a,
FILE * file ) {
Type t = VARget_type( a );
char ctype [BUFSIZ]; /* return type of the get function */
char funcnm [BUFSIZ]; /* name of member function */
generate_attribute_func_name( a, funcnm );
/* ///////////////////////////////////////////////// */
strncpy( ctype, AccessType( t ), BUFSIZ );
fprintf( file, "\nconst %s %s::%s( ) const ", ctype, classnm, funcnm );
return;
}
/**************************************************************//**
** Procedure: ATTRprint_access_methods_put_head
** Parameters: const Variable a -- attribute to find the type for
** FILE* file -- file being written to
** Type t - type of the attribute
** Class_Of_Type class -- type name of the class
** const char *attrnm -- name of the attribute
** char *ctype -- name of the attribute c++ type
** Returns: name to be used for the type of the c++ access functions
** Description: prints the access method put head based on the attribute type
** DAS which being translated is it prints the function header
** for the put attr value access function defined for an
** entity class. This is the .cc file version.
** Side Effects:
** Status: complete 7/15/93 by DDH
******************************************************************/
void ATTRprint_access_methods_put_head( CONST char * entnm, Variable a, FILE * file ) {
Type t = VARget_type( a );
char ctype [BUFSIZ];
char funcnm [BUFSIZ];
generate_attribute_func_name( a, funcnm );
/* ///////////////////////////////////////////////// */
strncpy( ctype, AccessType( t ), BUFSIZ );
fprintf( file, "\nvoid \n%s::%s (const %s x) ", entnm, funcnm, ctype );
return;
}
void AGGRprint_access_methods( CONST char * entnm, Variable a, FILE * file, Type t,
char * ctype, char * attrnm ) {
ATTRprint_access_methods_get_head( entnm, a, file );
fprintf( file, "{\n" );
fprintf( file, " return (%s) %s_%s;\n}\n", ctype,( ( a->type->u.type->body->base ) ? "" : "&"), attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n _%s%sShallowCopy (*x);\n}\n", attrnm, ( ( a->type->u.type->body->base ) ? "->" : ".") );
return;
}
/**************************************************************//**
** Procedure: ATTRprint_access_method
** Parameters: const Variable a -- attribute to find the type for
** FILE* file -- file being written to
** Returns: name to be used for the type of the c++ access functions
** Description: prints the access method based on the attribute type
** i.e. get and put value access functions defined in a class
** generated for an entity.
** Side Effects:
** Status: complete 1/15/91
** updated 17-Feb-1992 to print to library file instead of header
** updated 15-July-1993 to call the get/put head functions by DDH
******************************************************************/
void ATTRprint_access_methods( CONST char * entnm, Variable a, FILE * file ) {
Type t = VARget_type( a );
Class_Of_Type class;
char ctype [BUFSIZ]; /* type of data member */
char attrnm [BUFSIZ];
char membernm[BUFSIZ];
char funcnm [BUFSIZ]; /* name of member function */
char nm [BUFSIZ];
/* I believe nm has the name of the underlying type without Sdai in
front of it */
if( TYPEget_name( t ) ) {
strncpy( nm, FirstToUpper( TYPEget_name( t ) ), BUFSIZ - 1 );
}
generate_attribute_func_name( a, funcnm );
generate_attribute_name( a, attrnm );
strcpy( membernm, attrnm );
membernm[0] = toupper( membernm[0] );
class = TYPEget_type( t );
strncpy( ctype, AccessType( t ), BUFSIZ );
if( isAggregate( a ) ) {
AGGRprint_access_methods( entnm, a, file, t, ctype, attrnm );
return;
}
ATTRprint_access_methods_get_head( entnm, a, file );
/* case TYPE_ENTITY: */
if( class == entity_ ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" );
fprintf( file, " if(! (_%s == S_ENTITY_NULL) )\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"reference to Sdai%s entity #\" << _%s->STEPfile_id << std::endl;\n",
nm, attrnm );
/* funcnm, attrnm);*/
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"null entity\" << std::endl;\n }\n" );
fprintf( file, " logStream->close();\n" );
fprintf( file, " }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " return (%s) _%s; \n}\n", ctype, attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "\n" );
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" );
fprintf( file, " if(! (x == S_ENTITY_NULL) )\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() assigned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"reference to Sdai%s entity #\" << x->STEPfile_id << std::endl;\n",
nm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() assigned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"null entity\" << std::endl;\n }\n" );
fprintf( file, " logStream->close();\n" );
fprintf( file, " }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " _%s = x; \n}\n", attrnm );
return;
}
/* case TYPE_LOGICAL: */
if( ( class == boolean_ ) || ( class == logical_ ) ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " logStream->open(SCLLOGFILE,ios::app);\n" );
fprintf( file, " if(!_%s.is_null())\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n",
attrnm, attrnm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n" );
fprintf( file, " logStream->close();\n" );
fprintf( file, " }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " return (%s) _%s;\n}\n", ctype, attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() assigned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s.element_at(x) << std::endl;\n", attrnm );
fprintf( file, " }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " _%s.put (x); \n}\n", attrnm );
return;
}
/* case TYPE_ENUM: */
if( class == enumeration_ ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!_%s.is_null())\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s.element_at(_%s.asInt()) << std::endl;\n",
attrnm, attrnm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " return (%s) _%s; \n}\n",
EnumName( TYPEget_name( t ) ), attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() assigned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s.element_at(x) << std::endl;\n", attrnm );
fprintf( file, " }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " _%s.put (x); \n}\n", attrnm );
return;
}
/* case TYPE_SELECT: */
if( class == select_ ) {
fprintf( file, " { return (const %s) &_%s; }\n", ctype, attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, " { _%s = x; }\n", attrnm );
return;
}
/* case STRING:*/
/* case TYPE_BINARY: */
if( ( class == string_ ) || ( class == binary_ ) ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!_%s.is_null())\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s << std::endl;\n", attrnm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " return (const %s) _%s; \n}\n", ctype, attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!x)\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << x << std::endl;\n" );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
}
fprintf( file, " _%s = x; \n}\n", attrnm );
return;
}
/* case TYPE_INTEGER: */
if( class == integer_ ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!(_%s == S_INT_NULL) )\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s << std::endl;\n", attrnm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
}
/* default: INTEGER */
/* is the same type as the data member */
fprintf( file, " return (const %s) _%s; \n}\n", ctype, attrnm );
ATTRprint_access_methods_put_head( entnm, a, file );
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!(x == S_INT_NULL) )\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << x << std::endl;\n" );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
/* default: INTEGER */
/* is the same type as the data member */
}
fprintf( file, " _%s = x; \n}\n", attrnm );
}
/* case TYPE_REAL:
case TYPE_NUMBER: */
if( ( class == number_ ) || ( class == real_ ) ) {
fprintf( file, "{\n" );
if( print_logging ) {
fprintf( file, "#ifdef SCL_LOGGING\n" );
fprintf( file, " if(*logStream)\n {\n" );
fprintf( file, " if(!(_%s == S_REAL_NULL) )\n {\n", attrnm );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << _%s << std::endl;\n", attrnm );
fprintf( file, " }\n else\n {\n" );
fprintf( file, " *logStream << time(NULL) << \" SDAI %s::%s() returned: \";\n",
entnm, funcnm );
fprintf( file,
" *logStream << \"unset\" << std::endl;\n }\n }\n" );
fprintf( file, "#endif\n" );
}