forked from xtuml/mc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel.mc3020_meta.arc
95 lines (95 loc) · 2.83 KB
/
model.mc3020_meta.arc
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
.//============================================================================
.// Notice:
.// (C) Copyright 1998-2013 Mentor Graphics Corporation
.// All rights reserved.
.//
.// This document contains confidential and proprietary information and
.// property of Mentor Graphics Corp. No part of this document may be
.// reproduced without the express written permission of Mentor Graphics Corp.
.//============================================================================
.//
.//
.//
.function SortAscendingByNumbAttr
.param inst_ref_set item_set
.//
.for each item in item_set
.assign item.Order = 0
.end for
.//
.assign item_set2 = item_set
.for each item1 in item_set
.for each item2 in item_set2
.if ( item1.Numb != item2.Numb )
.if ( item2.Numb > item1.Numb )
.assign item2.Order = item2.Order + 1
.end if
.end if
.end for
.end for
.end function
.//
.//
.// template function
.//
.function class_model_data
.param inst_ref c
.param inst_ref_set as
.//
.assign key_word_assign = ".assign"
.assign key_word_invoke = ".invoke"
.assign key_word_function = ".function"
.assign key_word_endfunction = ".end function"
.assign key_word_select = ".select"
.//
.if ( not_empty as )
${key_word_function} model_class_$_{c.Name}
.// The following generates a call inside the model function.
.// This allows access to other data components from within the class.
.if ( "" != "${c.Descrip:access}" )
${key_word_invoke} $_{c.Descrip:access} = model_class_$_{c.Descrip:access}()
.end if
.//
.for each a in as
.select one dt related by a->S_DT[R114]
.if ( "string" == dt.Name )
${key_word_assign} attr_${a.Name} = "${a.Descrip:default}"
.elif ( ( "boolean" == dt.Name ) or ( "integer" == dt.Name ) )
.if ( "" != "${a.Descrip:default}" )
${key_word_assign} attr_${a.Name} = ${a.Descrip:default}
.end if
.elif ( "unique_id" == dt.Name )
.if ( "" != "${a.Descrip:default}" )
${key_word_select} any $l{a.Descrip:default} from instances of $u{a.Descrip:default} where ( false )
${key_word_assign} attr_${a.Name} = $l{a.Descrip:default}
.end if
.end if
.end for
${key_word_endfunction}
.end if
.end function
.//
.// query
.//
.select any ss from instances of S_SS where ( selected.Name == "Translation Extensions" )
.select many cs related by ss->O_OBJ[R2] where ( selected.Numb > 2035 )
.invoke SortAscendingByNumbAttr( cs )
.assign count = cardinality cs
.assign number = 0
.while ( number < count )
.for each c in cs
.if ( c.Order == number )
.select many as related by c->O_ATTR[R102]
.invoke model = class_model_data( c, as )
.//
.// render
.//
${model.body}
.//
.break for
.end if
.end for
.end while
.//
.emit to file "../../../src/model.mc3020.arc"
.//