KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > generator > cidl > lib > CIDLGenerator


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.generator.cidl.lib;
28
29 // Package dependencies
30
import org.objectweb.openccm.ast.api.Declaration;
31 import org.objectweb.openccm.ast.api.DeclarationKind;
32
33 /**
34  * This generator prints out CIDL declarations from the
35  */

36
37 public class CIDLGenerator
38      extends org.objectweb.openccm.generator.psdl.lib.PSDLGenerator
39   implements org.objectweb.openccm.generator.cidl.api.CIDLGenerator
40 {
41
42     // ===========================================================
43
//
44
// Constructors.
45
//
46
// ===========================================================
47

48     /**
49      * The default constructor.
50      *
51      * @param ast - The Abstract Syntax Tree.
52      */

53
54     public CIDLGenerator(org.objectweb.openccm.ast.api.AST ast)
55     {
56         // Call the IDL3Generator constructor
57
super(ast);
58
59         // Init internal states
60
translator_ = new org.objectweb.openccm.generator.translator.ast2idl.lib.AST_CIDLTranslator();
61     }
62
63     // ===========================================================
64
//
65
// Internal methods.
66
//
67
// ===========================================================
68

69     /**
70      * Initialize the generator.
71      **/

72     public void
73     initialize(String JavaDoc outputfile, String JavaDoc app_name)
74     {
75         java.util.List JavaDoc list = new java.util.ArrayList JavaDoc();
76
77         /** Initialize environment **/
78
79         // Templates to use.
80
list.clear();
81         list.add("org/objectweb/openccm/generator/common/common.vm");
82         list.add("org/objectweb/openccm/generator/idl/idl3.vm");
83         list.add("org/objectweb/openccm/generator/psdl/psdl.vm");
84         list.add("org/objectweb/openccm/generator/cidl/cidl.vm");
85         setLibrary(list);
86
87         // The output file
88
open(outputfile, "out");
89
90         // call the common generator init method
91
super.init();
92
93         /** Initialize velocity context **/
94         put("which", app_name);
95         put("gen", this);
96         put("translator", translator_);
97         put("declarator", "");
98         put("limited_types" , new Long JavaDoc(org.objectweb.openccm.ast.api.DeclarationKind.dk_cidl));
99     }
100
101     // ===========================================================
102
//
103
// Useful methods for CIDL Mapping.
104
//
105
// ===========================================================
106

107     /**
108      * Utility method to check forward declarations.
109      *
110      * @return The associated search mask.
111      **/

112     public long
113     forward_check()
114     {
115         return ( DeclarationKind.dk_null );
116     }
117
118     // ===========================================================
119
//
120
// Methods for CIDL Mapping.
121
//
122
// ===========================================================
123

124     /**
125      * Get the number of contained declarations for a scope.
126      *
127      * @param scope - The declaration.
128      *
129      * @return The number of contained declarations.
130      **/

131     public int
132     getContainedDeclsNumber(org.objectweb.openccm.ast.api.Scope scope)
133     {
134         Declaration[] objs = null;
135         objs = scope.getContents(true, DeclarationKind.dk_all);
136
137         return objs.length;
138    }
139
140 }
141
Popular Tags