1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.TypeRef; 31 32 33 import org.objectweb.openccm.ast.api.TypeKind; 34 35 36 import org.objectweb.openccm.ast.api.DeclarationKind; 37 38 39 import org.objectweb.openccm.ast.api.Declaration; 40 41 42 import org.objectweb.openccm.ast.api.StructMember; 43 44 45 import org.objectweb.openccm.ast.api.StructMemberList; 46 47 48 import org.omg.CORBA.StructDef ; 49 import org.omg.CORBA.StructDefHelper; 50 51 65 66 public class StructDeclImpl 67 extends ForwardScopeIDLImpl 68 implements org.objectweb.openccm.ast.api.StructDecl, 69 IDLTypeWrapper 70 { 71 77 78 protected StructDef struct_def_; 79 80 81 protected StructMemberListImpl members_; 82 83 89 95 protected 96 StructDeclImpl(Repository rep, 97 ScopeImpl parent) 98 { 99 super(rep, parent); 101 102 struct_def_ = null; 104 members_ = new StructMemberListImpl(); 105 } 106 107 113 119 124 protected void 125 load(org.omg.CORBA.Contained contained) 126 { 127 struct_def_ = StructDefHelper.narrow(contained); 128 org.omg.CORBA.StructMember [] members = struct_def_.members(); 129 130 super.load(contained); 133 134 for (int i=0;i<members.length;i++) 135 members_.addMember(members[i].name, 136 getRepository(). 137 getAsTypeRef(members[i].type_def)); 138 } 139 140 145 protected void 146 loadAsMapping(org.omg.CORBA.Contained contained) 147 { 148 struct_def_ = StructDefHelper.narrow(contained); 149 org.omg.CORBA.StructMember [] members = struct_def_.members(); 150 151 super.loadAsMapping(contained); 154 155 for (int i=0;i<members.length;i++) 156 members_.addMember(members[i].name, 157 getRepository(). 158 getAsMappedTypeRef(members[i].type_def)); 159 } 160 161 166 protected org.omg.CORBA.Contained 167 getContained() 168 { 169 return struct_def_; 170 } 171 172 178 183 protected org.omg.CORBA.Container 184 getContainer() 185 { 186 return struct_def_; 187 } 188 189 195 201 204 protected void 205 createContainer() 206 { 207 struct_def_ = the_parent_.getContainer(). 208 create_struct(getId(), getName(), getVersion(), 209 members_.getStructMemberSeq()); 210 } 211 212 215 protected void 216 completeContainer() 217 { 218 struct_def_.members(members_.getStructMemberSeq()); 219 } 220 221 227 233 241 public Declaration[] 242 getDependencies() 243 { 244 if (dependencies_!=null) 245 return dependencies_; 246 247 dependencies_ = new Declaration[0]; 248 249 java.util.List struct_depend = new java.util.ArrayList (); 251 Declaration[] depend = null; 252 253 StructMember[] members = members_.getStructMembers(); 254 for (int i=0; i<members.length; i++) 255 { 256 TypeRef member_type = members[i].getType(); 257 if (member_type.isDeclaration()) 258 { 259 if ((!containsDecl((Declaration)member_type)) && 260 (struct_depend.indexOf(member_type)==-1)) 261 struct_depend.add(member_type); 262 } 263 264 depend = member_type.getDependencies(); 265 for (int j=0; j<depend.length; j++) 266 { 267 if ((struct_depend.indexOf(depend[j])==-1) && 268 (!containsDecl(depend[j])) && 269 (depend[j]!=this)) 270 struct_depend.add(depend[j]); 271 } 272 } 273 274 dependencies_ = (Declaration[])struct_depend.toArray(new Declaration[0]); 275 return dependencies_; 276 } 277 278 284 289 public long 290 getDeclKind() 291 { 292 return DeclarationKind.dk_struct; 293 } 294 295 301 307 313 320 public String 321 declaratorAt(int index) 322 { 323 return members_.nameAt(index); 324 } 325 326 332 337 public TypeKind 338 getTypeKind() 339 { 340 return TypeKind.tk_struct; 341 } 342 343 349 354 public StructMemberList 355 getMemberList() 356 { 357 return members_; 358 } 359 360 366 371 public org.omg.CORBA.IDLType 372 getIDLType() 373 { 374 return struct_def_; 375 } 376 } 377 | Popular Tags |