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 package com.unitesk.atp.treedl;
33
34 import com.unitesk.atp.treedl.TDL.*;
35 import com.unitesk.atp.tool.PluginClass;
36
37 /***
38 * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
39 * @version $Id: CSharpInterfaceFactoryGenerator.java,v 1.2 2005/11/20 21:26:55 all-x Exp $
40 */
41 public class CSharpInterfaceFactoryGenerator
42 extends CSharpTextGenerator
43 implements TDL_Visitor
44 {
45 /***
46 * {@inheritDoc}
47 */
48 public String getVersion()
49 {
50 return PluginClass.getRevision( "$Revision: 1.2 $" ) + "-alpha";
51 }
52
53 public void visitModule( Module node )
54 {
55 setFunction( "PredefinedTypeName", new PredefinedTypeNameFunction() );
56
57 generateHeader();
58
59 int indexOfLastDot = getOutClassName().lastIndexOf( '.' );
60 if( indexOfLastDot != -1 )
61 {
62 txt( "namespace " + getOutClassName().substring( 0, indexOfLastDot ) ); nl();
63 block_nl();
64 }
65
66 if( node.getOptHeader() != null )
67 {
68 txt( "//-----------------------------------------------------------------------------" ); nl();
69 txt( "// tree header" ); nl();
70 txt( "${optHeader}" ); nl();
71 txt( "//-----------------------------------------------------------------------------" ); nl();
72 nl();
73 }
74
75 String outShortClassName = getOutClassName().substring( indexOfLastDot + 1 );
76
77 txt( "public interface " + outShortClassName ); nl();
78 block();
79 list( "memberIndex", 0, node.sizeOptMemberList(), "${optMemberList[memberIndex]}", null );
80 unblock_nl();
81
82 if( node.getName().sizeIdList() > 1 )
83 {
84 txt( "}" ); nl();
85 }
86 }
87
88 public void visitNodeTypeDecl( NodeTypeDecl node )
89 {
90 if( node.isAbstract() ) return;
91
92 nl();
93 txt( "${parent.name}.${name} Create${name}" );
94 int constructorParametersCount = 0;
95 for( int i = 0; i < node.sizeFullFieldList(); i++ )
96 {
97 Field field = node.getFullFieldList( i );
98
99 if( TDL_Module.isConstructorParameter( field ) )
100 {
101 pushNode( field );
102
103 nl();
104 txtif( constructorParametersCount == 0, "(", "," );
105 txt( " ${type} ${name}" );
106 constructorParametersCount++;
107
108 popNode();
109 }
110 }
111
112 switch( constructorParametersCount )
113 {
114 case 0:
115 txt( "();" );
116 break;
117 case 1:
118 txt( " );" );
119 break;
120 default:
121 nl();
122 txt( ");" );
123 break;
124 }
125 nl();
126 }
127
128 public void visitConstTypeDecl( ConstTypeDecl node )
129 {
130 }
131
132 public void visitOperationDecl( OperationDecl node )
133 {
134 }
135
136 public void visitBaseModule( BaseModule node )
137 {
138 throw new UnsupportedOperationException();
139 }
140
141 public void visitConstructorCodeMember( ConstructorCodeMember node )
142 {
143 throw new UnsupportedOperationException();
144 }
145
146 public void visitBodyCodeMember( BodyCodeMember node )
147 {
148 throw new UnsupportedOperationException();
149 }
150
151 public void visitField( Field node )
152 {
153 throw new UnsupportedOperationException();
154 }
155
156 public void visitNonVirtualParameterDecl( NonVirtualParameterDecl node )
157 {
158 throw new UnsupportedOperationException();
159 }
160
161 public void visitVirtualParameterDecl( VirtualParameterDecl node )
162 {
163 throw new UnsupportedOperationException();
164 }
165
166 public void visitCase( Case node )
167 {
168 throw new UnsupportedOperationException();
169 }
170
171 public void visitCaseSignature( CaseSignature node )
172 {
173 throw new UnsupportedOperationException();
174 }
175
176 public void visitParameter( Parameter node )
177 {
178 throw new UnsupportedOperationException();
179 }
180 }