1 26 27 package org.objectweb.corba.generator.cif_idl.lib; 28 29 import org.objectweb.openccm.ast.api.Declaration; 31 import org.objectweb.openccm.ast.api.Scope; 32 import org.objectweb.openccm.ast.api.CompositionDecl; 33 import org.objectweb.openccm.ast.api.ModuleDecl; 34 import org.objectweb.openccm.ast.api.DeclarationKind; 35 import org.objectweb.corba.generator.cif_idl.api.CompositionMapping; 36 import org.objectweb.openccm.generator.common.lib.GenerationException; 37 import java.util.List ; 38 import java.util.ArrayList ; 39 import java.util.Iterator ; 40 41 46 47 public class CIF_IDLGenerator 48 extends org.objectweb.openccm.generator.common.lib.GeneratorBase 49 implements org.objectweb.corba.generator.cif_idl.api.CIF_IDLGenerator 50 { 51 52 58 59 private List cif_decls_; 60 61 62 private List decls_to_remove_; 63 64 65 private org.objectweb.openccm.ir3.api.ComponentRepository rep_; 66 67 73 80 81 public CIF_IDLGenerator( org.objectweb.openccm.ast.api.AST ast, 82 org.objectweb.openccm.ir3.api.ComponentRepository rep) 83 { 84 super(ast); 86 87 rep_ = rep; 89 cif_decls_ = null; 90 decls_to_remove_ = null; 91 } 92 93 99 107 public List 108 declare_cif(Scope scope) 109 throws GenerationException 110 { 111 List list = null; 112 Declaration[] decls = null; 113 org.objectweb.openccm.ast.api.NativeDecl nativ = null; 114 115 cif_decls_ = new ArrayList (); 116 decls_to_remove_ = new ArrayList (); 117 118 119 list = getAllDeclarations(scope, DeclarationKind.dk_abstract_storage_home); 120 decls = (Declaration[]) list.toArray(new Declaration[0]); 121 for (int i=0; i<decls.length; i++) 122 { 123 nativ = ((org.objectweb.openccm.ast.api.AbstractStorageHomeDecl)decls[i]).getMapping(); 125 cif_decls_.add(nativ); 126 decls_to_remove_.add(nativ); 127 } 128 129 130 list = getAllDeclarations(scope, DeclarationKind.dk_abstract_storage_type); 131 decls = (Declaration[]) list.toArray(new Declaration[0]); 132 for (int i=0; i<decls.length; i++) 133 { 134 nativ = ((org.objectweb.openccm.ast.api.AbstractStorageTypeDecl)decls[i]).getMapping(); 135 cif_decls_.add(nativ); 136 decls_to_remove_.add(nativ); 137 } 138 139 140 list = getAllDeclarations(scope, DeclarationKind.dk_composition); 141 decls = (Declaration[]) list.toArray(new Declaration[0]); 142 143 for (int i=0; i<decls.length; i++) 145 { 146 CompositionMapping comp = null; 147 ModuleDecl module = null; 148 149 comp = new org.objectweb.corba.generator.cif_idl.lib.CompositionMapping( 150 (CompositionDecl) decls[i]); 151 module = comp.declareCIF(); 152 cif_decls_.add(module); 153 decls_to_remove_.add(module); 154 } 155 156 return cif_decls_; 158 } 159 160 161 164 public void 165 remove_decls() 166 { 167 Declaration decl = null; 168 Iterator it = null; 169 170 for(it=decls_to_remove_.iterator(); it.hasNext(); ) 171 { 172 decl = (Declaration) it.next(); 173 if (decl.getDeclKind() == DeclarationKind.dk_module) 174 { 175 org.omg.CORBA.Contained contained = null; 176 177 contained = rep_.lookup_id( decl.getId() ); 179 contained.destroy(); 180 } 181 else 182 { 183 decl.destroy(); 185 } 186 } 187 } 188 } 189 | Popular Tags |