NAME

idl2xs_c - IDL compiler to extension interface between Perl and C code

SYNOPSIS

idl2xs_c [options] spec.idl

OPTIONS

All options are forwarded to C preprocessor, except -h -i -J -v -x.

With the GNU C Compatible Compiler Processor, useful options are :

-D name
-D name=definition
-I directory
-I-
-nostdinc

Specific options :

-h

Display help.

-i directory

Specify a path for import (only for version 3.0).

-J directory

Specify a path for Perl package importation (use package;).

-v

Display version.

-x

Enable export (only for version 3.0).

DESCRIPTION

idl2xs_c is an alternative to h2xs and XS language when an IDL interface is available.

idl2xs_c parses the given input file (IDL) and generates :

  • a Perl stub spec.pm

    (deals with CDR serialization, and autoload)

  • a C stub spec.c

    (deals with Perl API)

  • a C stub cdr_spec.c

    (deals with CDR serialization)

  • a include file spec.h

    (following the language C mapping rules)

  • a C skeleton skel_spec.c (with automatic merge)

  • Makefile.PL

  • Makefile

    (from Makefile.PL)

  • test.pl

  • MANIFEST

  • Changes

The files Makefile, Makefile.PL, Changes, MANIFEST, test.pl and spec.c are generated only if spec.idl contains operation or attribute.

idl2xs_c is a Perl OO application what uses the visitor design pattern. The parser is generated by Parse::Yapp.

idl2xs_c needs a cpp executable.

idl2xs_c needs CORBA::IDL, CORBA::C and CORBA::Perl modules.

CORBA Specifications, including (IDL : Interface Language Definition and CDR : Common Data Representation) and C Language Mapping are available on <http://www.omg.org/>.

CORBA mapping for Perl [mapping.pod - Draft 1, 7 October 1999] comes with the package CORBA::MICO or CORBA::ORBit.

Exceptions are implemented using the Error module.

TUTORIAL

EXAMPLE 1

The file Calc.idl describes the interface of a simple calculator.

First, run :

idl2xs_c Calc.idl

Second, in skel_Calc.c complete each methode between tag START_EDIT and STOP_EDIT :

// IDL : long Add(in long val1, in long val2);

CORBA_long
Calc_Add(
    Calc _o,
    CORBA_long val1, // in (fixed length)
    CORBA_long val2, // in (fixed length)
    CORBA_Environment * _ev
)
{
/* START_EDIT (Calc_Add) */
    return val1 + val2;
/* STOP_EDIT (Calc_Add) */
}

Third, build :

make
make test
make install

Fourth, if you use Test::Unit, you can continue with :

cd testunit
testrunner suite_calc

Finally, using the extension module :

use Calc;
my $calc = new Calc();
print $calc->Add(2, 3);

EXAMPLE 2

Now, a complex calculator with two IDL files.

Cplx.idl contains :

module Cplx {
    struct Complex {
        float   re;
        float   im;
    };
};

and CalcCplx.idl contains :

#include "Cplx.idl"
interface CalcCplx {
    Cplx::Complex Add(in Cplx::Complex val1, in Cplx::Complex val2);
    Cplx::Complex Sub(in Cplx::Complex val1, in Cplx::Complex val2);
};

First, run :

idl2xs_c Cplx.idl
idl2xs_c CalcCplx.idl

Second, complete skel_CplxCalc.c.

Third, build :

make
make test
make install

EXAMPLE 3

Variante of a complex calculator with two IDL files. This is another decomposition of IDL specification.

Cplx.idl is the same, CalcCplx.idl contains :

#include "Cplx.idl"
module Cplx {
    interface CalcCplx {
        Complex Add(in Complex val1, in Complex val2);
        Complex Sub(in Complex val1, in Complex val2);
    };
};

The build process is the same.

SEE ALSO

cpp, perl, idl2html, idl2c

COPYRIGHT

(c) 2002-2007 Francois PERRAD, France. All rights reserved.

This program and all CORBA::XS modules are distributed under the terms of the Artistic Licence.

AUTHOR

Francois PERRAD, francois.perrad@gadz.org