1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class StructDeclImpl 39 extends ForwardScopeImpl 40 implements TypeRef, StructDecl 41 { 42 48 51 protected org.omg.CORBA.StructDef struct_def_; 52 53 56 protected StructMembersImpl members_; 57 58 64 69 protected 70 StructDeclImpl(Repository rep, ScopeImpl parent) 71 { 72 super(rep, parent); 74 75 struct_def_ = null; 77 members_ = new StructMembersImpl(); 78 the_declaration_kind_ = DeclarationKind._dk_struct; 79 } 80 81 87 92 protected void 93 load(org.omg.CORBA.Contained contained) 94 { 95 struct_def_ = org.omg.CORBA.StructDefHelper.narrow(contained); 96 org.omg.CORBA.StructMember [] members = struct_def_.members(); 97 98 super.load(contained); 101 102 for (int i=0;i<members.length;i++) 103 members_.addMember(members[i].name, 104 getRepository().getAsTypeRef(members[i].type_def)); 105 } 106 107 112 protected void 113 loadAsMapping(org.omg.CORBA.Contained contained) 114 { 115 struct_def_ = org.omg.CORBA.StructDefHelper.narrow(contained); 116 org.omg.CORBA.StructMember [] members = struct_def_.members(); 117 118 super.loadAsMapping(contained); 121 122 for (int i=0;i<members.length;i++) 123 members_.addMember(members[i].name, 124 getRepository().getAsMappedTypeRef(members[i].type_def)); 125 } 126 127 133 140 public String 141 declaratorAt(int index) 142 { 143 return members_.nameAt(index); 144 } 145 146 153 public Declaration[] 154 getDependencies() 155 { 156 if (dependencies_!=null) 157 return dependencies_; 158 159 dependencies_ = new Declaration[0]; 160 161 org.objectweb.ccm.util.Vector struct_depend = new org.objectweb.ccm.util.Vector(); 163 Declaration[] depend = null; 164 TypeRef[] member_types = getMembers().getMemberTypes(); 165 166 for (int i=0;i<member_types.length;i++) 167 { 168 if (member_types[i].isDeclaration()) 169 { 170 if ((!containsDecl((Declaration)member_types[i])) && 171 (struct_depend.indexOf(member_types[i])==-1)) 172 struct_depend.add(member_types[i]); 173 } 174 175 depend = member_types[i].getDependencies(); 176 for (int j=0;j<depend.length;j++) 177 { 178 if ((struct_depend.indexOf(depend[j])==-1) && 179 (!containsDecl(depend[j])) && 180 (depend[j]!=this)) 181 struct_depend.add(depend[j]); 182 } 183 } 184 185 dependencies_ = (Declaration[])struct_depend.toArray(new Declaration[0]); 186 return dependencies_; 187 } 188 189 195 201 206 public org.omg.CORBA.IDLType 207 getIDLType() 208 { 209 return struct_def_; 210 } 211 212 215 public int 216 getTypeKind() 217 { 218 return TypeKind._tk_struct; 219 } 220 221 227 232 public StructMembers 233 getMembers() 234 { 235 return members_; 236 } 237 238 244 249 protected org.omg.CORBA.Container 250 getContainer() 251 { 252 return struct_def_; 253 } 254 255 261 264 public void 265 destroy() 266 { 267 members_.destroy(); 268 super.destroy(); 269 } 270 271 276 protected org.omg.CORBA.Contained 277 getContained() 278 { 279 return struct_def_; 280 } 281 282 288 291 protected void 292 createContainer() 293 { 294 struct_def_ = the_parent_.getContainer().create_struct(getId(), getName(), getVersion(), 295 members_.getMemberDefs()); 296 } 297 298 301 protected void 302 completeContainer() 303 { 304 struct_def_.members(members_.getMemberDefs()); 305 } 306 } 307 | Popular Tags |