#!/usr/bin/perl use strict; use warnings; use CORBA::IDL 2.60; use CORBA::Python; # visitors use CORBA::IDL::RepositoryIdVisitor; use CORBA::IDL::UidVisitor; my $parser = CORBA::IDL::ParserFactory::create('3.0'); $parser->getopts('hi:J:Osvx'); if ($parser->YYData->{opt_v}) { print "CORBA::Python $CORBA::Python::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__idl2py'; 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( '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::IDL::UidVisitor($parser)) if ($parser->YYData->{opt_s}); $root->visit(new CORBA::Python::NameVisitor($parser)); $root->visit(new CORBA::Python::ImportVisitor($parser)); $root->visit(new CORBA::Python::LiteralVisitor($parser)); $root->visit(new CORBA::Python::ClassVisitor($parser)); } __END__ =head1 NAME idl2py - IDL compiler to language Python mapping =head1 SYNOPSIS idl2py [options] I.idl =head1 OPTIONS All options are forwarded to C preprocessor, except -h -i -J -s -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 version 3.0). =item B<-J> I Specify a path for Python package. =item B<-s> Generate a serial uid. =item B<-v> Display version. =item B<-x> Enable export (only for version 3.0). =back =head1 DESCRIPTION B parses the given input file (IDL) and generates : =over 4 =item * a set of Python file with marshal and demarshal methods =back 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) and Python Language Mapping are available on Ehttp://www.omg.org/E. =head1 SEE ALSO cpp, idl2html =head1 COPYRIGHT (c) 2005-2007 Francois PERRAD, France. All rights reserved. This program and all CORBA::Perl modules are distributed under the terms of the Artistic Licence. =head1 AUTHOR Francois PERRAD, francois.perrad@gadz.org =cut