1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.TypeKind; 31 32 33 import org.objectweb.openccm.ast.api.DeclarationKind; 34 35 36 import org.objectweb.openccm.ast.api.Declaration; 37 38 39 import org.objectweb.openccm.ast.api.InterfaceDecl; 40 41 42 import org.objectweb.openccm.ast.api.InterfaceList; 43 44 45 import org.objectweb.openccm.ast.api.AttributeDecl; 46 47 48 import org.objectweb.openccm.ast.api.OperationDecl; 49 50 51 import org.omg.CORBA.InterfaceDef ; 52 53 54 import org.omg.CORBA.ExtInterfaceDef; 55 import org.omg.CORBA.ExtInterfaceDefHelper; 56 57 73 74 public class InterfaceDeclImpl 75 extends ForwardScopeIDLImpl 76 implements InterfaceDecl, 77 IDLTypeWrapper 78 { 79 85 86 private ExtInterfaceDef ext_interface_def_; 87 88 89 protected InterfaceListImpl inherited_interfaces_; 90 91 97 103 protected 104 InterfaceDeclImpl(Repository rep, 105 ScopeImpl parent) 106 { 107 super(rep, parent); 109 110 ext_interface_def_ = null; 112 inherited_interfaces_ = new InterfaceListImpl(); 113 } 114 115 121 127 132 protected void 133 load(org.omg.CORBA.Contained contained) 134 { 135 ext_interface_def_ = ExtInterfaceDefHelper.narrow(contained); 136 InterfaceDef [] base_interfaces = ext_interface_def_.base_interfaces(); 137 138 for (int i=0; i<base_interfaces.length; i++) 139 inherited_interfaces_.add((InterfaceDecl) 141 getRepository().lookupId(base_interfaces[i].id())); 142 143 super.load(contained); 144 } 145 146 151 protected void 152 loadAsMapping(org.omg.CORBA.Contained contained) 153 { 154 ext_interface_def_ = ExtInterfaceDefHelper.narrow(contained); 155 InterfaceDef [] base_interfaces = ext_interface_def_.base_interfaces(); 156 157 for (int i=0; i<base_interfaces.length; i++) 158 inherited_interfaces_.add((InterfaceDecl) 160 getRepository().lookupMappedId(base_interfaces[i].id())); 161 162 super.loadAsMapping(contained); 163 } 164 165 171 protected org.omg.CORBA.Contained 172 getContained() 173 { 174 return ext_interface_def_; 175 } 176 177 183 195 protected org.omg.CORBA.ExtAttributeDef 196 createExtAttribute(AttributeDecl attribute, 197 org.omg.CORBA.IDLType type, 198 org.omg.CORBA.AttributeMode mode, 199 org.omg.CORBA.ExceptionDef [] get_exceptions, 200 org.omg.CORBA.ExceptionDef [] set_exceptions) 201 { 202 org.omg.CORBA.ExtAttributeDef ext_attribute_def = 204 getExtInterfaceDef().create_ext_attribute(attribute.getId(), 205 attribute.getName(), 206 attribute.getVersion(), 207 type, mode, 208 get_exceptions, 209 set_exceptions); 210 return ext_attribute_def; 211 } 212 213 226 protected org.omg.CORBA.OperationDef 227 createOperation(OperationDecl operation, 228 org.omg.CORBA.IDLType type, 229 org.omg.CORBA.OperationMode mode, 230 org.omg.CORBA.ParameterDescription [] params, 231 org.omg.CORBA.ExceptionDef [] exceptions, 232 String [] contexts) 233 { 234 org.omg.CORBA.OperationDef operation_def = 236 getExtInterfaceDef().create_operation(operation.getId(), 237 operation.getName(), 238 operation.getVersion(), 239 type, mode, 240 params, 241 exceptions, 242 contexts); 243 return operation_def; 244 } 245 246 252 protected org.omg.CORBA.Container 253 getContainer() 254 { 255 return ext_interface_def_; 256 } 257 258 264 270 273 protected void 274 createContainer() 275 { 276 ext_interface_def_ = the_parent_.getContainer(). 277 create_ext_interface(getId(), getName(), getVersion(), 278 inherited_interfaces_.getInterfaceDefSeq()); 279 } 280 281 284 protected void 285 completeContainer() 286 { 287 InterfaceDef [] inherited_interfaces = inherited_interfaces_.getInterfaceDefSeq(); 288 if (inherited_interfaces.length != 0) 289 getExtInterfaceDef().base_interfaces(inherited_interfaces); 290 } 291 292 298 304 public ExtInterfaceDef 305 getExtInterfaceDef() 306 { 307 return ext_interface_def_; 308 } 309 310 316 public InterfaceDef 317 getInterfaceDef() 318 { 319 return ext_interface_def_; 320 } 321 322 328 336 public Declaration[] 337 getDependencies() 338 { 339 if (dependencies_!=null) 340 return dependencies_; 341 342 dependencies_ = new Declaration[0]; 343 java.util.List itf_depend = new java.util.ArrayList (); 344 Declaration[] depend = null; 345 346 InterfaceDecl[] bases = inherited_interfaces_.getInterfaces(); 348 for (int i=0; i<bases.length; i++) 349 { 350 itf_depend.add(bases[i]); 351 depend = bases[i].getDependencies(); 352 for (int j=0;j<depend.length;j++) 353 { 354 if ((depend[j]!=this) && 355 (itf_depend.indexOf(depend[j])==-1)) 356 itf_depend.add(depend[j]); 357 } 358 } 359 360 Declaration[] decls = getContents(true, DeclarationKind.dk_all); 362 for (int i=0; i<decls.length; i++) 363 { 364 depend = decls[i].getDependencies(); 365 for (int j=0;j<depend.length;j++) 366 { 367 if ((!containsDecl(depend[j])) && 368 (depend[j]!=this) && 369 (itf_depend.indexOf(depend[j])==-1)) 370 itf_depend.add(depend[j]); 371 } 372 } 373 374 dependencies_ = (Declaration[])itf_depend.toArray(new Declaration[0]); 375 return dependencies_; 376 } 377 378 384 389 public long 390 getDeclKind() 391 { 392 return DeclarationKind.dk_interface; 393 } 394 395 401 412 public Declaration 413 find(String name) 414 { 415 Declaration decl = super.find(name); 417 418 if(decl != null) return decl; 420 421 return inherited_interfaces_.find(name); 423 } 424 425 434 public Declaration[] 435 getContents(boolean exclude_inherited, 436 long limited_types) 437 { 438 if (exclude_inherited) 439 return super.getContents(exclude_inherited, limited_types); 440 441 if (is_mapping_) 444 getRepository().useIDL2Repository(); 445 446 Declaration[] res = super.getContents(exclude_inherited, limited_types); 447 InterfaceDecl[] itfs = inherited_interfaces_.getInterfaces(); 448 for (int i=0; i<itfs.length; i++) 449 { 450 Declaration[] tmp1 = itfs[i].getContents(exclude_inherited, limited_types); 451 Declaration[] tmp2 = res; 452 res = new Declaration[tmp1.length+tmp2.length]; 453 System.arraycopy(tmp2, 0, res, 0, tmp2.length); 454 System.arraycopy(tmp1, 0, res, tmp2.length, tmp1.length); 455 } 456 457 if (is_mapping_) 459 getRepository().useIDL3Repository(); 460 461 return res; 462 } 463 464 470 476 481 public TypeKind 482 getTypeKind() 483 { 484 return TypeKind.tk_interface; 485 } 486 487 493 498 public InterfaceList 499 getInheritedInterfaceList() 500 { 501 return inherited_interfaces_; 502 } 503 504 510 515 public org.omg.CORBA.IDLType 516 getIDLType() 517 { 518 return ext_interface_def_; 519 } 520 } 521 | Popular Tags |