1 28 package org.coach.reactor; 29 30 import org.objectweb.ccm.visitorIDL3.java.*; 31 import org.objectweb.ccm.visitorIDL3.common.*; 32 import org.objectweb.ccm.IDL3.*; 33 34 41 42 public class ReactorImplPrinter 43 extends JavaPrinterBase 44 { 45 IDLTranslator idlTranslator; 51 ParameterList p; 52 53 59 62 public 63 ReactorImplPrinter(Generator gen, 64 java.lang.String indent) 65 throws fr.lifl.cim.jidlscript.lang.JISError 66 { 67 super(gen, '$', '@', indent); 68 69 super.setAlias("self", this); 71 72 super.loadFile("reactor_component.template"); 75 super.loadFile("reactor_home.template"); 76 super.loadFile("reactor_event.template"); 77 super.loadFile("reactor_core.template"); 78 super.loadFile("reactor_usercode.template"); 79 super.loadFile("reactor_script.template"); 80 81 idlTranslator = new IDLTranslator(); 82 } 83 84 90 96 99 public java.lang.String 100 modifyCurrentLine(java.lang.String str) 101 { 102 if (str.length()==0) 103 return "\\n"; 106 107 if (str.charAt(0)=='{') 108 return "{\\n$self.inc()$"; 109 110 if (str.charAt(0)=='}') 111 return "$self.dec()$}\\n"; 112 113 if ((str.charAt(0)!=getCallChar()) || (str.charAt(str.length()-1)!=getCallChar())) 114 return str+"\\n"; 115 116 return str; 117 } 118 119 125 128 public java.lang.String 129 which() 130 { 131 return "ir3_rimpl"; 132 } 133 134 137 public java.lang.String 138 visitModule(org.objectweb.ccm.IDL3.ModuleDecl module) 139 { 140 org.objectweb.ccm.util.Vector ports = new org.objectweb.ccm.util.Vector(); 141 142 org.objectweb.ccm.IDL3.Declaration[] components = null; 143 components = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_component); 144 for (int i=0;i<components.length;i++) 145 { 146 org.objectweb.ccm.IDL3.ComponentDecl comp = null; 147 org.objectweb.ccm.IDL3.Declaration[] comp_ports = null; 148 149 comp = (org.objectweb.ccm.IDL3.ComponentDecl)components[i]; 150 visitContained(comp, "_SKELETON"); 151 visitContained(comp.getClientMapping(), "_REACTOR_COMPONENT"); 153 visitContained(comp, "_MONOLITHIC_WRAPPER"); 154 comp_ports = comp.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 155 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 156 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 157 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 158 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 159 160 for (int j=0;j<comp_ports.length;j++) 161 { 162 org.objectweb.ccm.IDL3.TypeRef port_type = getType(comp_ports[j]); 163 if (!ports.contains(port_type)) 164 ports.add(port_type); 165 } 166 } 167 168 org.objectweb.ccm.IDL3.Declaration[] ports_arr = null; 169 ports_arr = (org.objectweb.ccm.IDL3.Declaration[])ports.toArray(new org.objectweb.ccm.IDL3.Declaration[0]); 170 for (int i=0;i<ports_arr.length;i++) 171 { 172 if (ports_arr[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_interface) 173 { 174 visitContained(ports_arr[i], "_SKELETON_INTERCEPTOR"); 175 visitContained(ports_arr[i], "_REACTOR_INTERFACE"); 176 visitContained(ports_arr[i], "_TCL"); 177 } 178 else if (ports_arr[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_event) 179 { 180 org.objectweb.ccm.IDL3.EventDecl event = null; 181 event = (org.objectweb.ccm.IDL3.EventDecl)ports_arr[i]; 182 visitContained(event.getClientMapping(),"_SKELETON_INTERCEPTOR"); 183 visitContained(event.getClientMapping(),"_REACTOR_INTERFACE"); 184 } 185 } 186 187 org.objectweb.ccm.IDL3.Declaration[] homes = null; 188 homes = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_home); 189 for (int i=0;i<homes.length;i++) 190 { 191 visitContained(homes[i], "_SKELETON"); 192 visitContained(((org.objectweb.ccm.IDL3.HomeDecl)homes[i]), 195 "_REACTOR_HOME"); 196 } 197 198 org.objectweb.ccm.IDL3.Declaration[] events = null; 199 events = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_event); 200 for (int i=0;i<events.length;i++) 201 { 202 visitContained(events[i], ""); 203 visitContained(events[i], "_CONSUMER_WRAPPER"); 204 } 205 206 org.objectweb.ccm.IDL3.Declaration[] values = null; 207 values = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_value); 208 for (int i=0;i<values.length;i++) 209 { 210 org.objectweb.ccm.IDL3.ValueDecl val = (org.objectweb.ccm.IDL3.ValueDecl)values[i]; 214 if (val.isPrimaryKey()) 215 visitContained(values[i], "_PK"); 216 else 217 visitContained(values[i], ""); 218 } 219 220 org.objectweb.ccm.IDL3.Declaration[] modules = null; 221 modules = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_module); 222 for (int i=0;i<modules.length;i++) 223 visitContained(modules[i], ""); 224 225 return ""; 226 } 227 228 231 public java.lang.String 232 extractSuperName(org.objectweb.ccm.IDL3.Declaration obj, 233 org.objectweb.ccm.IDL3.Declaration mapobj) 234 { 235 java.lang.String res = mapobj.getName(); 236 int idx = res.indexOf(obj.getName()); 237 if (idx==0) 238 return res; 239 240 return res.substring(0, idx-1); 241 } 242 243 246 public java.lang.String 247 packageName(org.objectweb.ccm.IDL3.Declaration decl) 248 { 249 java.lang.String pack_name = getTranslator().getPackage(decl); 250 if (!pack_name.equals("")) 251 return pack_name; 252 253 delete(8); 254 skip(3); 255 return ""; 256 } 257 258 264 public java.lang.String 267 javaPackage(org.objectweb.ccm.IDL3.Declaration type) 268 { 269 java.lang.String packageName = getTranslator().getPackage(type); 270 271 if (packageName.length() != 0) 272 packageName = packageName + '.'; 273 274 return packageName; 275 } 276 277 public java.lang.String 280 javaType(org.objectweb.ccm.IDL3.Declaration type, 281 java.lang.String prefix, 282 java.lang.String postfix) 283 { 284 return javaPackage(type) + prefix + type.getName() + postfix; 285 } 286 287 public java.lang.String 290 javaCCMConsumer(org.objectweb.ccm.IDL3.Declaration type) 291 { 292 return javaType(type, "CCM_", "Consumer"); 293 } 294 295 public java.lang.String 297 executorWrapperAttributes(org.objectweb.ccm.IDL3.Scope scope) 298 { 299 org.objectweb.ccm.IDL3.Declaration[] objs = 300 scope.getContents(false, 301 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 302 303 java.lang.String res = ""; 304 for (int i=0; i<objs.length; i++) 305 { 306 java.lang.String name = objs[i].getName(); 307 308 res = res + 309 "/** Wrapper for port " + name + ". */\n " + 310 "protected " + name + "_ConsumerWrapper " + 311 name + "_wrapper_ =\n new " + 312 name + "_ConsumerWrapper();\n\n"; 313 } 314 315 return res; 316 } 317 318 321 public java.lang.String 322 obtainExecutorWrapper(org.objectweb.ccm.IDL3.Scope scope) 323 { 324 org.objectweb.ccm.IDL3.Declaration[] objs = null; 325 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 326 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 327 328 java.lang.String [] aliases = { "name" , "impl" }; 329 for (int i=0;i<objs.length;i++) 330 { 331 java.lang.String impl = ""; 332 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 333 impl = "_monolithic_executor.get_"+objs[i].getName()+"()"; 334 else 335 impl = objs[i].getName()+"_wrapper_"; 336 337 java.lang.Object [] objs2 = { objs[i].getName(), impl }; 338 super.map("COMPONENT_MONOLITHIC_EXECUTOR_WRAPPER", aliases, objs2); 339 } 340 341 return ""; 342 } 343 344 347 public java.lang.String 348 monolithicEventWrapperClasses(org.objectweb.ccm.IDL3.Scope scope) 349 { 350 org.objectweb.ccm.IDL3.Declaration[] objs = 351 scope.getContents(false, 352 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 353 354 java.lang.String res = ""; 355 for (int i=0; i<objs.length; i++) 356 { 357 org.objectweb.ccm.IDL3.InterfaceDecl itf = 358 ((org.objectweb.ccm.IDL3.EventDecl)getType(objs[i])). 359 getLocalConsumerMapping(); 360 361 org.objectweb.ccm.IDL3.Declaration[] ops = 362 itf.getContents(false, 363 org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 364 365 for (int j=0; j<ops.length; j++) 366 visitContainedWithMapping(objs[i], ops[j], 367 "_EVENT_CONSUMER_MONOLITHIC_WRAPPER"); 368 } 369 370 return ""; 371 } 372 373 376 public java.lang.String 377 portDeclarations(org.objectweb.ccm.IDL3.Scope scope) 378 { 379 org.objectweb.ccm.IDL3.Declaration[] objs = null; 380 java.lang.String res = ""; 381 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 382 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 383 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 384 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 385 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 386 387 388 for (int i=0;i<objs.length;i++) 389 { 390 java.lang.String port_info = ""; 391 org.objectweb.ccm.IDL3.Declaration type = null; 392 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 393 394 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 395 port_info = "ProvidesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\")"; 396 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 397 { 398 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 399 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 400 port_info = "ConsumesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 401 } 402 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) 403 { 404 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 405 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 406 port_info = "EmitsInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 407 } 408 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 409 { 410 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 411 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 412 port_info = "PublishesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 413 } 414 else 415 { 416 org.objectweb.ccm.IDL3.UsesDecl uses = (org.objectweb.ccm.IDL3.UsesDecl)objs[i]; 417 if (uses.isMultiple()) 418 port_info = "UsesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\", "+ 419 java.lang.Integer.toString(java.lang.Integer.MAX_VALUE)+")"; 420 else 421 port_info = "UsesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\")"; 422 } 423 424 res = res+"_declare_port(new org.objectweb.openccm.Components."+port_info+");\\n"; 425 } 426 427 return res; 428 } 429 430 433 public java.lang.String 434 computeComponentOpName(org.objectweb.ccm.IDL3.Declaration obj, 435 org.objectweb.ccm.IDL3.Declaration mapobj) 436 { 437 java.lang.String str = ""; 438 439 if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 440 str = "provide_facet"; 441 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 442 { 443 str = "_"+extractSuperName(obj, mapobj); 444 org.objectweb.ccm.IDL3.UsesDecl uses = (org.objectweb.ccm.IDL3.UsesDecl)obj; 445 if (!uses.isMultiple()) 446 str = str+"_simple_receptacle"; 447 } 448 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 449 str = "_get_consumer"; 450 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) 451 str = "_"+extractSuperName(obj, mapobj)+"_emitter"; 452 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 453 str = "_"+extractSuperName(obj, mapobj); 454 455 return str; 456 } 457 458 463 public java.lang.String 464 contextOperations(org.objectweb.ccm.IDL3.Scope scope) 465 { 466 org.objectweb.ccm.IDL3.Declaration[] objs = null; 467 objs = scope.getContents(false, 468 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 469 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 470 471 java.lang.String [] aliases = { "obj", "event_abs_name", "port_name", "event" }; 472 for (int i=0;i<objs.length;i++) 473 { 474 org.objectweb.ccm.IDL3.OperationDecl[] ops = null; 475 java.lang.String id = ""; 476 477 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 478 { 479 ops = ((org.objectweb.ccm.IDL3.PublishesDecl)objs[i]).getLocalContextMapping(); 480 id = "COMPONENT_CONTEXT_PUBLISHES"; 481 } 482 else 483 { 484 ops = ((org.objectweb.ccm.IDL3.EmitsDecl)objs[i]).getLocalContextMapping(); 485 id = "COMPONENT_CONTEXT_EMITS"; 486 } 487 488 for (int j=0;j<ops.length;j++) 489 { 490 java.lang.Object [] objs2 = { ops[j], 491 getTranslator().getAbsoluteName( 492 (org.objectweb.ccm.IDL3.Declaration)getType(objs[i])), 493 objs[i].getName(), 494 getType(objs[i]) }; 495 super.map(id, aliases, objs2); 496 } 497 } 498 499 return ""; 500 } 501 502 505 public java.lang.String 506 connectionOperations(org.objectweb.ccm.IDL3.Scope scope) 507 { 508 org.objectweb.ccm.IDL3.Declaration[] objs = null; 509 objs = scope.getContents(false, 510 org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 511 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 512 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 513 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 514 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 515 516 for (int i=0;i<objs.length;i++) 517 { 518 org.objectweb.ccm.IDL3.OperationDecl[] ops = null; 519 java.lang.String id = ""; 520 521 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 522 ops = ((org.objectweb.ccm.IDL3.ProvidesDecl)objs[i]).getClientMapping(); 523 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 524 ops = ((org.objectweb.ccm.IDL3.UsesDecl)objs[i]).getClientMapping(); 525 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 526 ops = ((org.objectweb.ccm.IDL3.ConsumesDecl)objs[i]).getClientMapping(); 527 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 528 ops = ((org.objectweb.ccm.IDL3.PublishesDecl)objs[i]).getClientMapping(); 529 else 530 ops = ((org.objectweb.ccm.IDL3.EmitsDecl)objs[i]).getClientMapping(); 531 532 java.lang.String [] aliases = { "obj", "narrow", "super_op_name", 533 "port_name", "param_names", 534 "port_abs_name", "struct_abs_name" }; 535 for (int j=0;j<ops.length;j++) 536 { 537 id = "COMPONENT_CONNECTION"; 538 java.lang.String narrow = ""; 539 java.lang.String param_names = paramNames(ops[j]); 540 java.lang.String port_abs_name = getTranslator().getAbsoluteName(objs[i]); 541 java.lang.String struct_abs_name = ""; 542 if (!param_names.equals("")) 543 param_names = ", "+param_names; 544 if (ops[j].getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_void) 545 { 546 if (ops[j].getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_value) 549 { 550 id = id+"_DEFAULT"; 551 narrow = type(ops[j].getType())+"Helper.narrow"; 552 } 553 else 554 id = id+"_NO_NARROW"; 555 } 556 else 557 id = id+"_VOID"; 558 559 if ((objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) && 561 (ops[j].getName().startsWith("get_connections_"))) 562 { 563 id = "COMPONENT_CONNECTION_USES_MULTIPLE"; 564 org.objectweb.ccm.IDL3.AliasDecl alias = null; 565 org.objectweb.ccm.IDL3.TypeRefImpl sequence = null; 566 org.objectweb.ccm.IDL3.StructDecl struct = null; 567 alias = (org.objectweb.ccm.IDL3.AliasDecl)ops[j].getType(); 568 sequence = (org.objectweb.ccm.IDL3.TypeRefImpl)alias.getType(); 569 struct = (org.objectweb.ccm.IDL3.StructDecl)sequence.getContentType(); 570 struct_abs_name = getTranslator().getAbsoluteName(struct); 571 narrow = type(getType(objs[i]))+"Helper.narrow"; 572 } 573 574 java.lang.Object [] objs2 = { ops[j], narrow, 575 computeComponentOpName(objs[i], ops[j]), 576 objs[i].getName(), 577 param_names, 578 port_abs_name, 579 struct_abs_name }; 580 super.map(id, aliases, objs2); 581 } 582 } 583 584 return ""; 585 } 586 587 588 594 597 public java.lang.String 598 homeHelper(org.objectweb.ccm.IDL3.TypeRef type) 599 { 600 java.lang.String res = getTranslator().toJava(type); 601 if (type.getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_interface) 603 res = res + "Factory"; 604 605 return res; 606 } 607 608 611 public java.lang.String 612 hasPK(org.objectweb.ccm.IDL3.HomeDecl home) 613 { 614 if (home.getPrimaryKey()==null) 615 return "false"; 616 617 return "true"; 618 } 619 620 623 public java.lang.String 624 baseHome(org.objectweb.ccm.IDL3.HomeDecl home) 625 { 626 if (home.getPrimaryKey()==null) 627 return "CCMHomeImpl"; 628 629 return "CCMHomeWithPKImpl"; 630 } 631 632 635 public java.lang.String 636 implementedHomeExecutor(org.objectweb.ccm.IDL3.HomeDecl home) 637 { 638 if (home.getPrimaryKey()==null) 639 return "HomeExecutor"; 640 641 return "HomeExecutorWithPK"; 642 } 643 644 647 public java.lang.String 648 homeExecutorOps(org.objectweb.ccm.IDL3.HomeDecl home) 649 { 650 java.lang.String id = "HOME_EXECUTOR_OPS"; 651 java.lang.String key_abs_name = ""; 652 if (home.getPrimaryKey()!=null) 653 { 654 id = id + "_WITH_PK"; 655 key_abs_name = getTranslator().getAbsoluteName(home.getPrimaryKey()); 656 } 657 658 java.lang.String [] aliases = { "key_abs_name" }; 659 java.lang.Object [] objs = { key_abs_name }; 660 super.map(id, aliases, objs); 661 662 663 return ""; 664 } 665 666 669 public java.lang.String 670 primaryKeyOperations(org.objectweb.ccm.IDL3.HomeDecl home) 671 { 672 org.objectweb.ccm.IDL3.InterfaceDecl itf = null; 673 org.objectweb.ccm.IDL3.Declaration[] ops = null; 674 675 itf = home.getClientImplicitMapping(); 676 ops = itf.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 677 678 java.lang.String id = ""; 679 java.lang.String [] aliases = { "obj" }; 680 for (int i=0;i<ops.length;i++) 681 { 682 id = "HOME_OPERATION_SUPER"; 683 if (getType(ops[i]).getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 684 id = id + "_VOID"; 685 686 java.lang.Object [] objs = { ops[i] }; 687 super.map(id, aliases, objs); 688 } 689 690 return ""; 691 } 692 693 696 public java.lang.String 697 factoryFinderOperations(org.objectweb.ccm.IDL3.HomeDecl home) 698 { 699 org.objectweb.ccm.IDL3.Declaration[] objs = null; 700 701 objs = home.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_factory + 702 org.objectweb.ccm.IDL3.DeclarationKind._dk_finder); 703 704 java.lang.String id = ""; 705 org.objectweb.ccm.IDL3.Declaration[] ops = null; 706 org.objectweb.ccm.IDL3.FactoryDecl factory = null; 707 org.objectweb.ccm.IDL3.FinderDecl finder = null; 708 java.lang.String [] aliases = { "obj" }; 709 for (int i=0;i<objs.length;i++) 710 { 711 id = "HOME"; 712 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_factory) 713 { 714 factory = (org.objectweb.ccm.IDL3.FactoryDecl)objs[i]; 715 ops = factory.getClientMapping(); 716 id = id + "_FACTORY_SUPER"; 717 } 718 else 719 { 720 finder = (org.objectweb.ccm.IDL3.FinderDecl)objs[i]; 721 ops = finder.getClientMapping(); 722 id = id + "_FINDER_SUPER"; 723 } 724 725 for (int j=0;j<ops.length;j++) 726 { 727 java.lang.Object [] objs2 = { ops[j] }; 728 super.map(id, aliases, objs2); 729 } 730 } 731 732 return ""; 733 } 734 735 738 public java.lang.String 739 portInterceptors(org.objectweb.ccm.IDL3.Scope scope) 740 { 741 org.objectweb.ccm.IDL3.Declaration[] objs = null; 742 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 743 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 744 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 745 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 746 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 747 748 java.lang.String res = ""; 749 org.objectweb.ccm.IDL3.Declaration type = null; 750 java.lang.String ext = ""; 751 for (int i=0;i<objs.length;i++) 752 { 753 if ((objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) || 754 (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes)) 755 ext = "ConsumerStub"; 756 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 757 ext = "ConsumerSkeleton"; 758 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 759 ext = "Stub"; 760 else 761 ext = "Skeleton"; 762 763 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 764 res = "if (uid.equals(\""+objs[i].getId()+ 765 "\"))\\n"+ 766 getIndentation()+"return new "+getTranslator().getAbsoluteName(type)+ext+"Interceptor();\\n"; 767 768 super.printImmediately(res); 769 } 770 771 return ""; 772 } 773 774 777 public java.lang.String 778 portUids(org.objectweb.ccm.IDL3.Scope scope) 779 { 780 org.objectweb.ccm.IDL3.Declaration[] objs = null; 781 java.lang.String res = ""; 782 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 783 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 784 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 785 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 786 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 787 788 for (int i=0;i<objs.length;i++) 789 res = res+"\""+objs[i].getId()+"\", "; 790 791 if (!res.equals("")) 792 res = res.substring(0, res.length()-2); 793 794 return res; 795 } 796 797 800 public java.lang.String 801 portTypeUid(org.objectweb.ccm.IDL3.Scope scope) 802 { 803 org.objectweb.ccm.IDL3.Declaration[] objs = null; 804 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 805 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 806 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 807 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 808 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 809 810 java.lang.String res = ""; 811 org.objectweb.ccm.IDL3.Declaration type = null; 812 for (int i=0;i<objs.length;i++) 813 { 814 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 815 816 res = "if (port_uid.equals(\""+objs[i].getId()+ 817 "\"))\\n"+ 818 getIndentation()+"return \""; 819 820 java.lang.String type_id = type.getId(); 821 if ((objs[i].getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) && 822 (objs[i].getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_uses)) 823 { 824 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 825 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 826 type_id = itf.getId(); 827 } 828 829 res = res+type_id+"\";\\n"; 830 831 super.printImmediately(res); 832 } 833 834 return ""; 835 } 836 837 840 public java.lang.String 841 executorWrappers(org.objectweb.ccm.IDL3.ComponentDecl comp) 842 { 843 org.objectweb.ccm.IDL3.Declaration[] objs = null; 844 objs = comp.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 845 846 java.lang.String [] aliases = { "obj", "pack_name", "port_id" }; 847 for (int i=0;i<objs.length;i++) 848 { 849 org.objectweb.ccm.IDL3.ConsumesDecl cons = (org.objectweb.ccm.IDL3.ConsumesDecl)objs[i]; 850 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)cons.getType(); 851 852 java.lang.Object [] objs2 = { event, javaPackage(event), 853 cons.getId() }; 854 super.map("COMPONENT_EVENT_WRAPPER", aliases, objs2); 855 } 856 857 return ""; 858 } 859 860 866 869 public java.lang.String 870 eventConsumerOpWrapper(org.objectweb.ccm.IDL3.EventDecl event) 871 { 872 org.objectweb.ccm.IDL3.InterfaceDecl itf = null; 873 org.objectweb.ccm.IDL3.Declaration[] ops = null; 874 itf = event.getClientMapping(); 875 ops = itf.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 876 877 for (int i=0;i<ops.length;i++) 878 { 879 if (!ops[i].getName().equals("push_event")) 880 visitContainedWithMapping(event, ops[i], "_EVENT_CONSUMER_WRAPPER"); 881 } 882 883 return ""; 884 } 885 886 892 895 public java.lang.String 896 delegateOperations(org.objectweb.ccm.IDL3.Scope scope) 897 { 898 org.objectweb.ccm.IDL3.Declaration[] objs = null; 899 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 900 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 901 902 for (int i=0;i<objs.length;i++) 903 { 904 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 905 { 906 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 907 if (attr.isReadonly()) 908 visitContained(attr, "_READONLY_DELEGATE"); 909 else 910 visitContained(attr, "_DELEGATE"); 911 } 912 else 913 visitContained(objs[i], "_DELEGATE"); 914 } 915 916 return ""; 917 } 918 919 922 public java.lang.String 923 interceptorDelegateWrapper(org.objectweb.ccm.IDL3.Declaration obj, 924 java.lang.String name) 925 { 926 if (obj.getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 927 return name; 928 929 return "new "+name(obj)+"EventWrapper("+name+")"; 930 } 931 932 935 public java.lang.String 936 interceptorIState(org.objectweb.ccm.IDL3.Scope scope) 937 { 938 org.objectweb.ccm.IDL3.Declaration[] objs = null; 939 java.lang.String str = ""; 940 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 941 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 942 943 for (int i=0;i<objs.length;i++) 944 { 945 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 946 { 947 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_get_"+ 948 objs[i].getName()+" = null;\\n\\n"; 949 950 super.printImmediately(str); 951 952 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 953 if (!attr.isReadonly()) 954 { 955 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_set_"+ 956 objs[i].getName()+" = null;\\n\\n"; 957 super.printImmediately(str); 958 } 959 } 960 else 961 { 962 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_"+ 963 objs[i].getName()+" = null;\\n\\n"; 964 super.printImmediately(str); 965 } 966 967 } 968 969 return ""; 970 } 971 972 975 public java.lang.String 976 facetOperations(org.objectweb.ccm.IDL3.Scope scope) 977 { 978 org.objectweb.ccm.IDL3.Declaration[] objs = null; 979 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 980 981 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 982 for (int i=0;i<objs.length;i++) 983 { 984 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 985 { 986 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 987 if (attr.isReadonly()) 988 visitContained(attr, "_READONLY_FACET"); 989 else 990 visitContained(attr, "_FACET"); 991 } 992 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_operation) 993 visitContained(objs[i], "_FACET"); 995 else 996 visitContained(objs[i], "_PROVIDES"); 997 } 998 1008 return ""; 1009 } 1010 public java.lang.String 1012 pound() 1013 { 1014 return "$"; 1015 } 1016 1017 public java.lang.String 1018 getManagedComponentName(org.objectweb.ccm.IDL3.InterfaceDecl obj) 1019 { 1020 return name(((org.objectweb.ccm.IDL3.HomeDecl)obj).getManagedComponent()); 1021 } 1022 1023 1026 public java.lang.String 1027 componentOperations(org.objectweb.ccm.IDL3.Scope scope) 1028 { 1029 org.objectweb.ccm.IDL3.Declaration[] objs = null; 1030 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 1031 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 1032 for (int i=0;i<objs.length;i++) 1033 { 1034 if (objs[i].getParent().getAbsoluteName().startsWith("::Components")) 1035 continue ; 1036 if (objs[i].getName().equals("create")) 1037 continue ; 1038 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 1039 { 1040 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 1041 if (attr.isReadonly()) 1042 visitContained(attr, "_READONLY_COMPONENT"); 1043 else 1044 visitContained(attr, "_COMPONENT"); 1045 } 1046 else if (objs[i].getName().startsWith("provide_")) 1047 visitContained(objs[i], "_GET_FACET"); 1049 else visitContained(objs[i], "_COMPONENT"); 1051 } 1052 1053 return ""; 1054 } 1055 1056 public java.lang.String 1057 replace(java.lang.String source, java.lang.String from, java.lang.String to) 1058 { 1059 return source.replaceFirst(from, to); 1060 } 1061 1062 1065 public java.lang.String 1066 interceptorUserOperations(org.objectweb.ccm.IDL3.Scope scope) 1067 { 1068 org.objectweb.ccm.IDL3.Declaration[] objs = null; 1069 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 1070 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 1071 for (int i=0;i<objs.length;i++) 1072 { 1073 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 1074 { 1075 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 1076 if (attr.isReadonly()) 1077 visitContained(attr, "_READONLY_USER_INTERCEPTOR"); 1078 else 1079 visitContained(attr, "_USER_INTERCEPTOR"); 1080 } 1081 else 1082 visitContained(objs[i], "_USER_INTERCEPTOR"); 1083 } 1084 1085 return ""; 1086 } 1087 1088 1091 public java.lang.String 1092 interceptorTclOperations(org.objectweb.ccm.IDL3.Scope scope) 1093 { 1094 org.objectweb.ccm.IDL3.Declaration[] objs = null; 1095 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 1096 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 1097 for (int i=0;i<objs.length;i++) 1098 { 1099 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 1100 { 1101 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 1102 if (attr.isReadonly()) 1103 visitContained(attr, "_READONLY_TCL"); 1104 else 1105 visitContained(attr, "_TCL"); 1106 } 1107 else 1108 visitContained(objs[i], "_TCL"); 1109 } 1110 1111 return ""; 1112 } 1113 public java.lang.String 1114 toStringMode(int mode) 1115 { 1116 if (mode==org.objectweb.ccm.IDL3.OperationDecl.PARAM_IN) 1117 return "in"; 1118 else if (mode==org.objectweb.ccm.IDL3.OperationDecl.PARAM_OUT) 1119 return "out"; 1120 else 1121 return "inout"; 1122 } 1123 1124 public java.lang.String 1125 createParameterArray (org.objectweb.ccm.IDL3.OperationDecl op) { 1126 1127 ExceptionDecl[] raises = op.getExceptions(); 1128 p = op.getParameters(); 1129 int inCount = 0; 1130 int outCount = 0; 1131 int [] parameterModes = p.getParamModes(); 1132 TypeRef [] ptRef =p.getParamTypes(); 1133 String [] pnames = p.getParamNames(); 1134 StringBuffer sb = new StringBuffer (" par = new Parameter[] {\n"); 1135 String comma = " "; 1136 String id = null; 1137 1138 1139 for (int j = 0; j < ptRef.length; j++) { 1140 if (isPrimitive(ptRef[j])) 1141 id = toJava(ptRef[j]); 1142 else { 1143 try { 1144 id = ptRef[j].getIDLType().type().id(); }catch (Exception e) { 1146 sb.append("EXCEPTION RAISED\n"+pnames[j]); } 1148 } 1149 1150 sb.append(comma + "new Parameter(\"" + toStringMode(parameterModes[j]) + "\", \"" + id + "\", \"" + pnames[j] + "\")"); 1151 comma = ",\n "; 1152 } 1153 1154 if (op.getType().getTypeKind() != org.objectweb.ccm.IDL3.TypeKind._tk_void) { 1155 if (isPrimitive(op.getType())) 1157 id = toJava(op.getType()); 1158 else { 1159 try { 1160 id = op.getType().getIDLType().type().id(); }catch (Exception e) { 1162 sb.append("EXCEPTION RAISED in return value"); } 1164 } 1165 1166 sb.append(comma + "new Parameter(\"return\", \"" + id + "\", \"return\")"); 1167 } 1168 sb.append("\n};\n"); 1169 sb.append(" val = new org.omg.CORBA.Any[par.length];\n"); 1170 sb.append(" for (int i = 0; i < val.length; i++) {\n"); 1171 sb.append(" val[i] = m_orb.create_any();\n"); 1172 sb.append(" }\n"); 1173 1174 for (int j = 0; j < parameterModes.length; j++) { 1175 sb.append(" "); 1176 if (parameterModes[j] == org.objectweb.ccm.IDL3.OperationDecl.PARAM_IN) { 1177 sb.append(getInsertExpression(ptRef[j], "val[" + j + "]", pnames[j]) + ";\n"); 1178 } 1179 if (parameterModes[j] == org.objectweb.ccm.IDL3.OperationDecl.PARAM_INOUT) { 1180 sb.append(getInsertExpression(ptRef[j], "val[" + j + "]", pnames[j] + ".value") + ";\n"); 1181 } 1182 if (parameterModes[j] == org.objectweb.ccm.IDL3.OperationDecl.PARAM_OUT) { 1183 sb.append("val[" + j + "] = IdlNode.create(" + getTypeCodeExpression(ptRef[j]) + ").toAny();\n"); 1184 } 1185 } 1186 1187 if (op.getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_void) { 1188 sb.append(" val[" + parameterModes.length + "] = IdlNode.create(" + getTypeCodeExpression(op.getType()) + ").toAny();\n"); 1189 } 1190 1191 if (raises.length > 0) { 1192 sb.append(" String[] exceptions = new String[] {\n"); 1193 comma = ""; 1194 for (int j = 0; j < raises.length; j++) { 1195 sb.append(comma + " \"" + raises[j].getName() + "\""); 1196 comma = ",\n"; 1197 } 1198 sb.append("\n };\n"); 1199 sb.append(" org.omg.CORBA.TypeCode[] exceptionTypes = new org.omg.CORBA.TypeCode[] {\n"); 1200 comma = " "; 1201 for (int j = 0; j < raises.length; j++) { 1202 sb.append(comma + getHelperName(raises[j]) + ".type()"); 1203 comma = ",\n "; 1204 } 1205 sb.append("\n };\n"); 1206 sb.append(" IdlReply opr = new IdlReply(\"" + op.getParent().getId() + "\", \"" + op.getName() + "\", par, val, exceptions, exceptionTypes);\n"); 1207 } else { 1208 sb.append(" IdlReply opr = new IdlReply(\"" + op.getParent().getId() + "\", \"" + op.getName() + "\", par, val);\n"); 1209 } 1210 return sb.toString(); 1211 } 1212 1213 public java.lang.String 1214 processReturnValue(org.objectweb.ccm.IDL3.OperationDecl op) 1215 { 1216 StringBuffer sb = new StringBuffer (""); 1217 ExceptionDecl [] excepts = null; 1218 ExceptionList el = null; 1219 org.omg.CORBA.ExceptionDef [] ced = null; 1220 1221 if (op == null) { 1222 return "oops"; 1223 } 1224 1225 excepts = op.getExceptions(); 1226 el = op.getExceptionList(); 1227 ced = el.getExceptionDefs(); 1228 1229 String comma = ""; 1230 1231 int [] parameterModes = null; 1232 TypeRef [] ptRef = null; 1233 String [] pnames = null; 1234 1235 if ( p != null) { 1236 parameterModes = p.getParamModes(); 1237 ptRef =p.getParamTypes(); 1238 pnames = p.getParamNames(); 1239 } 1240 1241 1242 if (excepts.length > 0) { 1243 sb.append(" if (opr.isException()) {\n"); 1244 sb.append(" String _ex_id = opr.getException().getId();\n"); 1245 1246 for (int j = 0; j < excepts.length; j++) { 1247 sb.append(" if (_ex_id.equals(\"" + excepts[j].getId() + "\")) {\n"); 1248 sb.append(" throw " + getHelperName(excepts[j]) + ".extract(opr.getException().toAny());\n"); 1249 sb.append(" }\n"); 1250 } 1251 sb.append(" }\n"); 1252 } 1253 1254 sb.append(" opr.getValues(val);\n"); 1255 sb.append("}\n"); 1256 for (int j = 0; j < ptRef.length; j++) { 1259 if (parameterModes[j] != org.objectweb.ccm.IDL3.OperationDecl.PARAM_IN) { 1260 sb.append(pnames[j] + ".value = " + getExtractExpression(ptRef[j], "val[" + j + "]") + ";\n"); 1261 } 1262 } 1263 if (op.getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_void) { 1264 sb.append(getTranslator().toJava(op.getType()) + " _result = " + getExtractExpression(op.getType(), "val[" + ptRef.length + "]") + ";\n"); 1265 sb.append(" return _result;\n"); 1266 } 1267 1268 return sb.toString(); 1269 } 1270 1271 public String 1272 getExtractExpression(org.objectweb.ccm.IDL3.TypeRef type, String any) { 1273 1274 String expr = null; 1275 1276 if (isPrimitive(type)) { 1277 expr = any + ".extract_"+ toJava(type)+"()"; 1278 } else { 1279 expr = toJava(type)+"Helper.extract(" + any + ")"; 1280 } 1281 1282 return expr; 1283 1284 } 1286 1287 public String 1288 getInsertExpression(org.objectweb.ccm.IDL3.TypeRef type, String any, String var) { 1289 1290 String expr = null; 1291 1292 if (isPrimitive(type)) { 1293 expr = any + ".insert_"+ toJava(type)+"(" + var + ")"; 1294 } else { 1295 expr = toJava(type)+"Helper.insert(" + any + ", " + var + ")"; 1296 } 1297 1298 return expr; 1299 1300 1305 } 1307 1308 1309 boolean 1310 isPrimitive(org.objectweb.ccm.IDL3.TypeRef typeref) 1311 { 1312 switch(typeref.getTypeKind()) 1313 { 1314 case org.objectweb.ccm.IDL3.TypeKind._tk_short : 1315 case org.objectweb.ccm.IDL3.TypeKind._tk_ushort : 1316 case org.objectweb.ccm.IDL3.TypeKind._tk_long : 1317 case org.objectweb.ccm.IDL3.TypeKind._tk_ulong : 1318 case org.objectweb.ccm.IDL3.TypeKind._tk_longlong : 1319 case org.objectweb.ccm.IDL3.TypeKind._tk_ulonglong : 1320 case org.objectweb.ccm.IDL3.TypeKind._tk_float : 1321 case org.objectweb.ccm.IDL3.TypeKind._tk_double : 1322 case org.objectweb.ccm.IDL3.TypeKind._tk_longdouble : 1323 case org.objectweb.ccm.IDL3.TypeKind._tk_boolean : 1324 case org.objectweb.ccm.IDL3.TypeKind._tk_char : 1325 case org.objectweb.ccm.IDL3.TypeKind._tk_wchar : 1326 case org.objectweb.ccm.IDL3.TypeKind._tk_octet : 1327 case org.objectweb.ccm.IDL3.TypeKind._tk_any : 1328 case org.objectweb.ccm.IDL3.TypeKind._tk_objref : 1329 case org.objectweb.ccm.IDL3.TypeKind._tk_string : 1330 case org.objectweb.ccm.IDL3.TypeKind._tk_wstring : 1331 return true; 1332 default: 1333 return false; 1334 } 1335 } 1336 1337 public java.lang.String 1338 toJava(org.objectweb.ccm.IDL3.TypeRef typeref) 1339 { 1340 switch(typeref.getTypeKind()) 1341 { 1342 case org.objectweb.ccm.IDL3.TypeKind._tk_short : 1343 return "short"; 1344 case org.objectweb.ccm.IDL3.TypeKind._tk_ushort : 1345 return "ushort"; 1346 case org.objectweb.ccm.IDL3.TypeKind._tk_long : 1347 return "long"; 1348 case org.objectweb.ccm.IDL3.TypeKind._tk_ulong : 1349 return "ulong"; 1350 case org.objectweb.ccm.IDL3.TypeKind._tk_longlong : 1351 return "longlong"; 1352 case org.objectweb.ccm.IDL3.TypeKind._tk_ulonglong : 1353 return "ulonglong"; 1354 case org.objectweb.ccm.IDL3.TypeKind._tk_float : 1355 return "float"; 1356 case org.objectweb.ccm.IDL3.TypeKind._tk_double : 1357 return "double"; 1358 case org.objectweb.ccm.IDL3.TypeKind._tk_longdouble : 1359 return "doubledouble"; 1360 case org.objectweb.ccm.IDL3.TypeKind._tk_boolean : 1361 return "boolean"; 1362 case org.objectweb.ccm.IDL3.TypeKind._tk_char : 1363 return "char"; 1364 case org.objectweb.ccm.IDL3.TypeKind._tk_wchar : 1365 return "wchar"; 1366 case org.objectweb.ccm.IDL3.TypeKind._tk_octet : 1367 return "octet"; 1368 case org.objectweb.ccm.IDL3.TypeKind._tk_any : 1369 return "any"; 1370 1376 case org.objectweb.ccm.IDL3.TypeKind._tk_objref : 1377 return "Object"; 1378 case org.objectweb.ccm.IDL3.TypeKind._tk_string : 1379 return "string"; 1380 case org.objectweb.ccm.IDL3.TypeKind._tk_wstring : 1381 return "wstring"; 1382 1386 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 1387 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 1388 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 1389 case org.objectweb.ccm.IDL3.TypeKind._tk_exception : 1390 case org.objectweb.ccm.IDL3.TypeKind._tk_value_box : 1391 case org.objectweb.ccm.IDL3.TypeKind._tk_value : 1392 case org.objectweb.ccm.IDL3.TypeKind._tk_native : 1393 case org.objectweb.ccm.IDL3.TypeKind._tk_abstract_interface : 1394 case org.objectweb.ccm.IDL3.TypeKind._tk_local_interface : 1395 case org.objectweb.ccm.IDL3.TypeKind._tk_interface : 1396 case org.objectweb.ccm.IDL3.TypeKind._tk_component : 1397 case org.objectweb.ccm.IDL3.TypeKind._tk_home : 1398 case org.objectweb.ccm.IDL3.TypeKind._tk_event : 1399 org.objectweb.ccm.IDL3.Declaration decl = (org.objectweb.ccm.IDL3.Declaration)typeref; 1400 return getTranslator().getAbsoluteName(decl); 1401 1402 case org.objectweb.ccm.IDL3.TypeKind._tk_alias : 1403 org.objectweb.ccm.IDL3.AliasDecl alias = (org.objectweb.ccm.IDL3.AliasDecl)typeref; 1404 return getTranslator().getAbsoluteName(alias); 1405 1406 case org.objectweb.ccm.IDL3.TypeKind._tk_sequence : 1407 case org.objectweb.ccm.IDL3.TypeKind._tk_array : 1408 org.objectweb.ccm.IDL3.TypeRefImpl impl= (org.objectweb.ccm.IDL3.TypeRefImpl)typeref; 1409 java.lang.String str = toJava(impl.getContentType()); 1410 return str+"[:-)]"; 1411 default : 1412 return ""; 1413 } 1414 } 1415 1416 public String 1417 getTypeCodeExpression(org.objectweb.ccm.IDL3.TypeRef type) { 1418 1419 String expr; 1420 if (isPrimitive(type)) 1421 expr = "org.omg.CORBA.ORB.init().get_primitive_tc("+tkToString(type.getIDLType().type())+")"; 1422 else 1423 expr = toJava(type) + "Helper.type()"; 1424 1425 return expr; 1426 1427 1459 } 1461 1462 public java.lang.String 1463 tkToString(org.omg.CORBA.TypeCode tc) { 1464 1465 try { 1466 switch (tc.kind().value()) { 1467 case org.omg.CORBA.TCKind._tk_boolean: { return "org.omg.CORBA.TCKind.tk_boolean";} 1468 case org.omg.CORBA.TCKind._tk_octet: { return "org.omg.CORBA.TCKind.tk_octet";} 1469 case org.omg.CORBA.TCKind._tk_short: { return "org.omg.CORBA.TCKind.tk_short";} 1470 case org.omg.CORBA.TCKind._tk_ushort: { return "org.omg.CORBA.TCKind.tk_ushort";} 1471 case org.omg.CORBA.TCKind._tk_long: { return "org.omg.CORBA.TCKind.tk_long";} 1472 case org.omg.CORBA.TCKind._tk_ulong: { return "org.omg.CORBA.TCKind.tk_ulong";} 1473 case org.omg.CORBA.TCKind._tk_longlong: { return "org.omg.CORBA.TCKind.tk_longlong";} 1474 case org.omg.CORBA.TCKind._tk_ulonglong: { return "org.omg.CORBA.TCKind.tk_ulonglong";} 1475 case org.omg.CORBA.TCKind._tk_float: { return "org.omg.CORBA.TCKind.tk_float";} 1476 case org.omg.CORBA.TCKind._tk_double: { return "org.omg.CORBA.TCKind.tk_double";} 1477 case org.omg.CORBA.TCKind._tk_longdouble: { return "org.omg.CORBA.TCKind.tk_longdouble";} 1478 case org.omg.CORBA.TCKind._tk_char: { return "org.omg.CORBA.TCKind.tk_char";} 1479 case org.omg.CORBA.TCKind._tk_string: { return "org.omg.CORBA.TCKind.tk_string";} 1480 case org.omg.CORBA.TCKind._tk_wchar: { return "org.omg.CORBA.TCKind.tk_wchar";} 1481 case org.omg.CORBA.TCKind._tk_wstring: { return "org.omg.CORBA.TCKind.tk_wstring";} 1482 case org.omg.CORBA.TCKind._tk_objref: { return "org.omg.CORBA.TCKind.tk_objref";} 1483 case org.omg.CORBA.TCKind._tk_fixed: { return "org.omg.CORBA.TCKind.tk_fixed";} 1484 case org.omg.CORBA.TCKind._tk_any: { return "org.omg.CORBA.TCKind.tk_any";} 1485 case org.omg.CORBA.TCKind._tk_void: { return "org.omg.CORBA.TCKind.tk_void";} 1486 default: { return tc.id(); } 1487 } 1488 } catch (Exception e) { 1489 e.printStackTrace(); 1490 } 1491 return null; 1492 } 1493 1494 1495 public String getHelperName(org.objectweb.ccm.IDL3.Declaration decl) { 1496 1497 return getTranslator().getAbsoluteName(decl)+"Helper"; 1498 } 1499 1500 public String getHelperName(org.objectweb.ccm.IDL3.TypeRef typeref) { 1501 1502 switch(typeref.getTypeKind()) 1503 { 1504 case org.objectweb.ccm.IDL3.TypeKind._tk_short : 1505 case org.objectweb.ccm.IDL3.TypeKind._tk_ushort : 1506 return "org.omg.CORBA.ShortHelper"; 1507 case org.objectweb.ccm.IDL3.TypeKind._tk_long : 1508 case org.objectweb.ccm.IDL3.TypeKind._tk_ulong : 1509 return "org.omg.CORBA.LongLongHelper"; 1510 case org.objectweb.ccm.IDL3.TypeKind._tk_longlong : 1511 case org.objectweb.ccm.IDL3.TypeKind._tk_ulonglong : 1512 return "org.omg.CORBA.LongLongHelper"; 1513 case org.objectweb.ccm.IDL3.TypeKind._tk_float : 1514 return "org.omg.CORBA.FloatHelper"; 1515 case org.objectweb.ccm.IDL3.TypeKind._tk_double : 1516 case org.objectweb.ccm.IDL3.TypeKind._tk_longdouble : 1517 return "org.omg.CORBA.DoubleHelper"; 1518 case org.objectweb.ccm.IDL3.TypeKind._tk_boolean : 1519 return "org.omg.CORBA.BooleanHelper"; 1520 case org.objectweb.ccm.IDL3.TypeKind._tk_char : 1521 return "org.omg.CORBA.CharHelper"; 1522 case org.objectweb.ccm.IDL3.TypeKind._tk_wchar : 1523 return "org.omg.CORBA.WcharHelper"; 1524 case org.objectweb.ccm.IDL3.TypeKind._tk_octet : 1525 return "org.omg.CORBA.OctetHelper"; 1526 case org.objectweb.ccm.IDL3.TypeKind._tk_any : 1527 return "any"; 1528 1534 case org.objectweb.ccm.IDL3.TypeKind._tk_objref : 1535 return "org.omg.CORBA.ObjectHelper"; 1536 case org.objectweb.ccm.IDL3.TypeKind._tk_string : 1537 return "org.omg.CORBA.StringHelper"; 1538 case org.objectweb.ccm.IDL3.TypeKind._tk_wstring : 1539 return "org.omg.CORBA.WideStringHelper"; 1540 1544 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 1545 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 1546 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 1547 case org.objectweb.ccm.IDL3.TypeKind._tk_exception : 1548 case org.objectweb.ccm.IDL3.TypeKind._tk_value_box : 1549 case org.objectweb.ccm.IDL3.TypeKind._tk_value : 1550 case org.objectweb.ccm.IDL3.TypeKind._tk_native : 1551 case org.objectweb.ccm.IDL3.TypeKind._tk_abstract_interface : 1552 case org.objectweb.ccm.IDL3.TypeKind._tk_local_interface : 1553 case org.objectweb.ccm.IDL3.TypeKind._tk_interface : 1554 case org.objectweb.ccm.IDL3.TypeKind._tk_component : 1555 case org.objectweb.ccm.IDL3.TypeKind._tk_home : 1556 case org.objectweb.ccm.IDL3.TypeKind._tk_event : 1557 org.objectweb.ccm.IDL3.Declaration decl = (org.objectweb.ccm.IDL3.Declaration)typeref; 1558 return getTranslator().getAbsoluteName(decl)+"Helper"; 1559 1560 case org.objectweb.ccm.IDL3.TypeKind._tk_sequence : 1561 case org.objectweb.ccm.IDL3.TypeKind._tk_array : 1562 return toJava(typeref)+"qHelper"; 1563 1564 1569 case org.objectweb.ccm.IDL3.TypeKind._tk_alias : 1570 org.objectweb.ccm.IDL3.AliasDecl alias = (org.objectweb.ccm.IDL3.AliasDecl)typeref; 1571 return getHelperName(alias.getType()); 1572 1573 1580 default: 1581 System.err.println("unknown type: " + idlTranslator.toIDL(typeref)); 1582 } 1583 return ""; 1584 } 1585 1586} 1587 | Popular Tags |