#!/usr/bin/perl use strict; use warnings; use CORBA::IDL 2.61; use CORBA::JAVA; # visitors use CORBA::IDL::RepositoryIdVisitor; use CORBA::JAVA::NameXmlVisitor; use CORBA::JAVA::ClassXmlVisitor; use CORBA::XMLSchemas::NameVisitor; my $parser = CORBA::IDL::ParserFactory::create('3.0'); $parser->getopts('hi:p:t:vx'); if ($parser->YYData->{opt_v}) { print "CORBA::JAVA $CORBA::JAVA::VERSION\n"; print "CORBA::IDL $CORBA::IDL::VERSION\n"; print "IDL $CORBA::IDL::Parser::IDL_VERSION\n"; print "$0\n"; print "Perl $] on $^O\n"; exit; } if ($parser->YYData->{opt_h}) { use Pod::Usage; pod2usage(-verbose => 1); } my $cflags = '-D__idl2javaxml'; if ($CORBA::IDL::Parser::IDL_VERSION lt '3.0') { $cflags .= ' -D_PRE_3_0_COMPILER_'; } my $preprocessor; if ($^O eq 'MSWin32') { $preprocessor = 'cpp -C ' . $cflags; # $preprocessor = 'CL /E /C /nologo ' . $cflags; # Microsoft VC } else { $preprocessor = 'cpp -C ' . $cflags; } $parser->Configure( 'forward_constructed_forbidden' => 1, 'preprocessor' => $preprocessor, 'verbose_error' => 1, # 0, 1 'verbose_warning' => 1, # 0, 1 'verbose_info' => 1, # 0, 1 'verbose_deprecated' => 0, # 0, 1 (concerns only version '2.4' and upper) # 'collision_allowed' => 1, ); $parser->Run(@ARGV); $parser->DisplayStatus(); my $root = $parser->getRoot(); if (defined $root) { $root->visit(new CORBA::IDL::RepositoryIdVisitor($parser)); if ($parser->YYData->{opt_x}) { $parser->Export(); } $root->visit(new CORBA::JAVA::NameVisitor($parser, $parser->YYData->{opt_p}, $parser->YYData->{opt_t})); $root->visit(new CORBA::JAVA::LiteralVisitor($parser)); $root->visit(new CORBA::JAVA::Name2Visitor($parser)); $root->visit(new CORBA::JAVA::NameXmlVisitor($parser)); $root->visit(new CORBA::JAVA::UidVisitor($parser)); $root->visit(new CORBA::XMLSchemas::NameVisitor($parser)); $root->visit(new CORBA::JAVA::ClassXmlVisitor($parser)); } __END__ =head1 NAME idl2javaxml - IDL compiler to language Java mapping & XML binding =head1 SYNOPSIS idl2javaxml [options] I.idl =head1 OPTIONS All options are forwarded to C preprocessor, except -h -i -v -x. With the GNU C Compatible Compiler Processor, useful options are : =over 8 =item B<-D> I =item B<-D> I=I =item B<-I> I =item B<-I-> =item B<-nostdinc> =back Specific options : =over 8 =item B<-h> Display help. =item B<-i> I Specify a path for import (only for IDL version 3.0). =item B<-p> "I=I;..." Specify a list of prefix (gives full qualified Java package names). =item B<-t> "I=I;..." Specify a list of name translation (gives full qualified Java package names). =item B<-v> Display version. =item B<-x> Enable export (only for IDL version 3.0). =back =head1 DESCRIPTION B parses the given input file (IDL) and generates the same files as B and a IHelperXML.java file that contains XML marshal/demarshal methods. The XML binding follows the CORBA to WSDL/SOAP Interworking Specification (WS-I comformant soap binding). B is a Perl OO application what uses the visitor design pattern. The parser is generated by Parse::Yapp. B needs a B executable. CORBA Specifications, including IDL (Interface Language Definition) , the JAVA Language Mapping and CORBA to WSDL/SOAP Interworking are available on Ehttp://www.omg.org/E. =head1 EXAMPLE // IDL struct StructType { long field1; string field2; }; // Java public class test { public static void main (String[] args) throws Exception { XMLOutputStreamImpl os = new XMLOutputStreamImpl (new FileOutputStream ("out.xml")); StructType obj = new StructType (1, "toto"); StructTypeHelperXML.write (os, obj); os.close (); } } The class StructType and StructTypeHelperXML are generated by B. The class XMLOutputStreamImpl and XMLInputStreamImpl are an example of the run-time support; there derive from XMLOutputStream ans XMLInputStream that define the interface. // XML 1toto This XML document is valid against the Schema generated by B (Do you really want write by hand W3C Schema ?). // XSD The class PYXOutputStreamImpl and PYXInputStreamImpl are an example of the run-time support for Pyxie format (see Ehttp://www.pyxie.org/E); there derive from XMLOutputStream and XMLInputStream. // PYX (StructType (field1 -1 )field1 (field2 -toto )field2 )StructType =head1 SEE ALSO cpp, idl2html, idl2java, idl2xsd, idl2rng =head1 COPYRIGHT (c) 2004-2007 Francois PERRAD, France. All rights reserved. This program and all CORBA::JAVA modules and all Java class (run-time support) are distributed under the terms of the Artistic Licence. =head1 AUTHOR Francois PERRAD, francois.perrad@gadz.org =cut