1 26 27 package org.objectweb.ccm.visitorIDL3.java; 28 29 import org.objectweb.ccm.visitorIDL3.common.*; 30 31 38 39 public class JavaImplPrinter 40 extends JavaPrinterBase 41 { 42 48 54 57 public 58 JavaImplPrinter(Generator gen, 59 java.lang.String indent) 60 throws fr.lifl.cim.jidlscript.lang.JISError 61 { 62 super(gen, '$', '#', indent); 63 64 super.setAlias("self", this); 66 67 super.loadFile("java_impl_common.template"); 69 } 70 71 77 83 86 public java.lang.String 87 modifyCurrentLine(java.lang.String str) 88 { 89 if (str.length()==0) 90 return ""; 91 92 if (str.charAt(0)=='{') 93 return "{\\n$self.inc()$"; 94 95 if (str.charAt(0)=='}') 96 return "$self.dec()$}\\n"; 97 98 if ((str.charAt(0)!=getCallChar()) || (str.charAt(str.length()-1)!=getCallChar())) 99 return str+"\\n"; 100 101 return str; 102 } 103 104 110 113 public java.lang.String 114 which() 115 { 116 return "ir3_jimpl"; 117 } 118 119 122 public java.lang.String 123 visitModule(org.objectweb.ccm.IDL3.ModuleDecl module) 124 { 125 java.lang.String [] aliases = { "obj" }; 126 org.objectweb.ccm.IDL3.Declaration[] components = null; 127 components = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_component); 128 for (int i=0;i<components.length;i++) 129 { 130 java.lang.Object [] objs = { components[i] }; 131 super.map("COMPONENT_MONOLITHIC", aliases, objs); 132 } 133 134 org.objectweb.ccm.IDL3.Declaration[] homes = null; 135 homes = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_home); 136 for (int i=0;i<homes.length;i++) 137 { 138 java.lang.Object [] objs = { homes[i] }; 139 super.map("HOME_IMPL", aliases, objs); 140 } 141 142 org.objectweb.ccm.IDL3.Declaration[] values = null; 143 org.objectweb.ccm.IDL3.ValueDecl value = null; 144 values = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_event+ 145 org.objectweb.ccm.IDL3.DeclarationKind._dk_value); 146 for (int i=0;i<values.length;i++) 147 { 148 value = (org.objectweb.ccm.IDL3.ValueDecl)values[i]; 149 if (value.isAbstract()) 150 continue ; 151 152 java.lang.Object [] objs = { values[i] }; 153 super.map("VALUE_IMPL", aliases, objs); 154 super.map("VALUE_FACTORY_IMPL", aliases, objs); 155 } 156 157 org.objectweb.ccm.IDL3.Declaration[] modules = null; 158 modules = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_module); 159 for (int i=0;i<modules.length;i++) 160 visitModule((org.objectweb.ccm.IDL3.ModuleDecl)modules[i]); 161 162 return ""; 163 } 164 165 168 public java.lang.String 169 packageName(org.objectweb.ccm.IDL3.Declaration decl) 170 { 171 java.lang.String pack_name = getTranslator().getPackage(decl); 172 if (!pack_name.equals("")) 173 return pack_name; 174 175 delete(8); 176 skip(3); 177 return ""; 178 } 179 180 186 196 public java.lang.String 197 providesLocalInterfaces(org.objectweb.ccm.IDL3.ComponentDecl comp) 198 { 199 String itfs = ""; 200 org.objectweb.ccm.IDL3.Declaration[] objs = null; 201 objs = comp.getContents(false,org.objectweb.ccm.IDL3. 202 DeclarationKind._dk_provides); 203 for (int i = 0 ; i<objs.length ; i++) 204 { 205 org.objectweb.ccm.IDL3.ProvidesDecl provides = 206 (org.objectweb.ccm.IDL3.ProvidesDecl) objs[i]; 207 org.objectweb.ccm.IDL3.InterfaceDecl type = 208 provides.getLocalMapping(); 209 itfs += " \n" + 210 " " + 211 getTranslator().getAbsoluteName(type) + ", "; 212 } 213 return itfs; 214 } 215 216 229 public java.lang.String 230 businessOperations(org.objectweb.ccm.IDL3.ComponentDecl comp) 231 { 232 org.objectweb.ccm.IDL3.Declaration[] objs = null; 233 org.objectweb.ccm.IDL3.InterfaceDecl itf = comp.getLocalMonolithicMapping(); 234 objs = itf.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation+ 235 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 236 237 for (int i=0;i<objs.length;i++) 238 { 239 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 240 { 241 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 242 if (attr.isReadonly()) 243 visitContained(attr, "_IMPL_READONLY"); 244 else 245 visitContained(attr, "_IMPL"); 246 } 247 else 248 { 249 org.objectweb.ccm.IDL3.OperationDecl op = (org.objectweb.ccm.IDL3.OperationDecl)objs[i]; 250 if (op.getParent().getAbsoluteName().startsWith("::Components")) 251 continue ; 252 else if (op.getType().getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 253 visitContained(op, "_IMPL_VOID"); 254 else if (op.getName().startsWith("get_")) 255 visitContained(op, "_IMPL_FACET"); 257 else 258 visitContained(op, "_IMPL"); 259 } 260 } 261 262 return ""; 263 } 264 265 272 public java.lang.String 273 facetsOperations(org.objectweb.ccm.IDL3.ComponentDecl comp) 274 { 275 276 org.objectweb.ccm.IDL3.Declaration[] objs = null; 277 objs = comp.getContents(false,org.objectweb.ccm.IDL3. 278 DeclarationKind._dk_provides); 279 for (int i = 0 ; i<objs.length ; i++) 280 { 281 org.objectweb.ccm.IDL3.ProvidesDecl provides = 282 (org.objectweb.ccm.IDL3.ProvidesDecl)objs[i]; 283 visitContained(provides, "_OPERATIONS"); 284 } 285 return ""; 286 } 287 288 295 public java.lang.String 296 facetOperations(org.objectweb.ccm.IDL3.ProvidesDecl provides) 297 { 298 org.objectweb.ccm.IDL3.InterfaceDecl itf = provides.getLocalMapping(); 299 org.objectweb.ccm.IDL3.Declaration[] decls = null; 300 decls = itf.getContents(false, 301 org.objectweb.ccm.IDL3.DeclarationKind. 302 _dk_operation+ 303 org.objectweb.ccm.IDL3.DeclarationKind. 304 _dk_attribute); 305 306 307 for (int i=0;i<decls.length;i++) 308 { 309 if (decls[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 310 { 311 org.objectweb.ccm.IDL3.AttributeDecl attr = 312 (org.objectweb.ccm.IDL3.AttributeDecl)decls[i]; 313 if (attr.isReadonly()) 314 visitContained(attr, "_IMPL_READONLY"); 315 else 316 visitContained(attr, "_IMPL"); 317 } 318 else 319 { 320 org.objectweb.ccm.IDL3.OperationDecl op = 321 (org.objectweb.ccm.IDL3.OperationDecl)decls[i]; 322 if (op.getParent().getAbsoluteName().startsWith("::Components")) 323 continue ; 324 else if (op.getType().getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 325 visitContained(op, "_IMPL_VOID"); 326 else 327 visitContained(op, "_IMPL"); 328 } 329 } 330 return ""; 331 } 332 333 336 public java.lang.String 337 businessOperations(org.objectweb.ccm.IDL3.HomeDecl home) 338 { 339 org.objectweb.ccm.IDL3.Declaration[] objs = null; 340 org.objectweb.ccm.IDL3.InterfaceDecl itf = home.getLocalMapping(); 341 objs = itf.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 342 343 for (int i=0;i<objs.length;i++) 344 { 345 org.objectweb.ccm.IDL3.OperationDecl op = (org.objectweb.ccm.IDL3.OperationDecl)objs[i]; 346 if (op.getParent().getAbsoluteName().startsWith("::Components")) 347 continue ; 348 else if (op.getType().getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 349 visitContained(objs[i], "_IMPL_VOID"); 350 else 351 visitContained(objs[i], "_IMPL"); 352 } 353 354 return ""; 355 } 356 357 360 public java.lang.String 361 initMembers(org.objectweb.ccm.IDL3.ValueDecl value) 362 { 363 org.objectweb.ccm.IDL3.Declaration[] objs = null; 364 objs = value.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_value_member); 365 java.lang.String str = ""; 366 367 for (int i=0;i<objs.length;i++) 368 { 369 org.objectweb.ccm.IDL3.ValueMemberDecl member = (org.objectweb.ccm.IDL3.ValueMemberDecl)objs[i]; 370 str = checkName(member.getName()) + 374 " = " + 375 nullValue(member.getType()) + 376 ";\\n"; 377 super.printImmediately(str); 378 } 379 380 return ""; 381 } 382 383 386 public java.lang.String 387 localOperations(org.objectweb.ccm.IDL3.ValueDecl value) 388 { 389 org.objectweb.ccm.IDL3.Declaration[] objs = null; 390 objs = value.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation+ 391 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 392 java.lang.String str = ""; 393 394 for (int i=0;i<objs.length;i++) 395 { 396 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 397 { 398 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 399 if (attr.isReadonly()) 400 visitContained(attr, "_IMPL_READONLY"); 401 else 402 visitContained(attr, "_IMPL"); 403 } 404 else 405 { 406 org.objectweb.ccm.IDL3.OperationDecl op = (org.objectweb.ccm.IDL3.OperationDecl)objs[i]; 407 if (op.getType().getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 408 visitContained(objs[i], "_IMPL_VOID"); 409 else 410 visitContained(objs[i], "_IMPL"); 411 } 412 } 413 414 415 return ""; 416 } 417 418 421 public java.lang.String 422 baseFactory(org.objectweb.ccm.IDL3.ValueDecl value) 423 { 424 org.objectweb.ccm.IDL3.Initializer[] inits = value.getInitializers(); 425 426 if (inits.length==0) 427 return "org.omg.CORBA.portable.ValueFactory"; 428 429 return checkName(value.getName())+"ValueFactory"; 433 } 434 435 438 public java.lang.String 439 factoriesImpl(org.objectweb.ccm.IDL3.ValueDecl value) 440 { 441 org.objectweb.ccm.IDL3.Initializer[] inits = value.getInitializers(); 442 java.lang.String [] aliases = { "obj", "value" }; 443 444 for (int i=0;i<inits.length;i++) 445 { 446 java.lang.Object [] objs = { inits[i], value }; 447 super.map("INITIALIZER_IMPL", aliases, objs); 448 } 449 450 return ""; 451 } 452 } 453 | Popular Tags |