On Tue, 9 May 2000, andrew.j.mcgowan wrote:
> Ciaran
>
> I'm new to this group and unfortunately cannot answer your question, but I
> an very interested in the visibroker idl2java task, as I had just started to
> develop one myself.
>
> Would you share your code with me, or point me in the direction of its new
> location.
>
> Thanks in advance
>
> Andy
FYI here's the visibroker 4 idl2java task I wrote - it's visibroker 4
specific, and has all the options as attributes, not as just one big
string.
Cheerio
--
Tom Cook - Software Engineer
"The brain is a wonderful organ. It starts functioning the moment you get
up in the morning, and does not stop until you get into the office."
- Robert Frost
LISAcorp - www.lisa.com.au
--------------------------------------------------
38 Greenhill Rd. Level 3, 228 Pitt Street
Wayville, SA, 5034 Sydney, NSW, 2000
Phone: +61 8 8272 1555 Phone: +61 2 9283 0877
Fax: +61 8 8271 1199 Fax: +61 2 9283 0866
--------------------------------------------------
/*
* Copyright (c) 2000 LISA Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by
* LISA Corporation (http://www.lisa.com.au)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. The names "LISA Corporation", and "LISAcorp" must not be used
* to endorse or promote products derived from this software
* without prior written permission. For written permission,
* please contact [EMAIL PROTECTED]
* 6. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS LISA CORPORATION OR ITS EMPLOYEES BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
*/
package au.com.lisa.saw.anttasks;
import org.apache.tools.ant.*;
import java.util.*;
import java.io.File;
public class Idl2java extends Task
{
/* Miscellaneous options */
public File source = null;
public File dest = null;
public Vector includes = null;
public Vector undefines = null;
public String compiler = null;
public String compiler_flags = null;
public String jpackage = null;
/* Boolean options; these are either on the command line, or off. */
public boolean no_line_directives = false;
public boolean list_includes = false;
public boolean retain_comments = false;
public boolean gen_included_files = false;
public boolean list_files = false;
public boolean dynamic_marshal = false;
public boolean stream_marshal = true;
public boolean strict = false;
public boolean version = false;
/* Pairs of maps, ie. mapping an idl module to a java package. */
private boolean ipmap = false;
public String idl_package_map = null;
public Vector idl_modules = null;
public Vector java_packages = null;
private boolean kwmap = false;
public String keyword_map = null;
public Vector orig_keywords = null;
public Vector java_replacements = null;
/* Boolean options; these are like -idl_strict or -no_idl_strict. */
public boolean idl_strict = false;
public boolean warn_unrecognized_pragmas = false;
public boolean back_compat_mapping = false;
public boolean boa = false;
public boolean comments = true;
public boolean obj_wrapper = false;
public boolean servant = true;
public boolean tie = true;
public boolean warn_missing_define = false;
public boolean bind = true;
public boolean compile = false;
public boolean copy_local_values = false;
public boolean examples = false;
public void setSource( String sourceString )
{
source = project.resolveFile( sourceString );
}
public void setDest( String destString )
{
dest = project.resolveFile( destString );
}
public void setIncludes( String includeString )
{
StringTokenizer tokens = new StringTokenizer( includeString,
"," );
try
{
while( true )
{
includes.addElement(
tokens.nextToken() );
}
}
catch( NoSuchElementException nsee )
{ ; }
return;
}
public void setUndefines( String undefineString )
{
StringTokenizer tokens = new StringTokenizer( undefineString,
"," );
try
{
while( true )
{
undefines.addElement(
tokens.nextToken() );
}
}
catch( NoSuchElementException nsee )
{ ; }
return;
}
public void setCompiler( String compiler )
{
this.compiler = compiler;
}
public void setCompiler_flags( String flags )
{
compiler_flags = flags;
}
public void setPackage( String jpack )
{
jpackage = jpack;
}
public void setNo_line_directives( String flag )
{
no_line_directives = Project.toBoolean( flag );
}
public void setList_includes( String flag )
{
list_includes = Project.toBoolean( flag );
}
public void setRetain_comments( String flag )
{
retain_comments = Project.toBoolean( flag );
}
public void setGen_included_files( String flag )
{
gen_included_files = Project.toBoolean( flag );
}
public void setList_files( String flag )
{
list_files = Project.toBoolean( flag );
}
public void setDynamic_marshal( String flag )
{
dynamic_marshal = Project.toBoolean( flag );
}
public void setStream_marshal( String flag )
{
stream_marshal = Project.toBoolean( flag );
}
public void setStrict( String flag )
{
strict = Project.toBoolean( flag );
}
public void setVersion( String flag )
{
version = Project.toBoolean( flag );
}
public void setIdl_package_map( String map )
{
idl_package_map = map;
ipmap = true;
}
public void setKeyword_map( String map )
{
keyword_map = map;
kwmap = true;
}
public void setIdl_strict( String flag )
{
idl_strict = Project.toBoolean( flag );
}
public void setWarn_unrecognized_pragmas( String flag )
{
warn_unrecognized_pragmas = Project.toBoolean( flag );
}
public void setBack_compat_mapping( String flag )
{
back_compat_mapping = Project.toBoolean( flag );
}
public void setBoa( String flag )
{
boa = Project.toBoolean( flag );
}
public void setComments( String flag )
{
comments = Project.toBoolean( flag );
}
public void setObj_wrapper( String flag )
{
obj_wrapper = Project.toBoolean( flag );
}
public void setTie( String flag )
{
tie = Project.toBoolean( flag );
}
public void setWarn_missing_define( String flag )
{
warn_missing_define = Project.toBoolean( flag );
}
public void setBind( String bind )
{
this.bind = Project.toBoolean( bind );
}
public void setCompile( String flag )
{
compile = Project.toBoolean( flag );
}
public void setCopy_local_values( String flag )
{
copy_local_values = Project.toBoolean( flag );
}
public void setExamples( String flag )
{
examples = Project.toBoolean( flag );
}
public Idl2java()
{
setDescription( "Compile IDL using the Visibroker IDL2JAVA." );
}
public void init()
throws BuildException
{ ; }
public void execute()
throws BuildException
{
if( !source.exists() )
throw new BuildException( "[Idl2java]Source file does
not exist." );
File lock = new File( source.getAbsolutePath() + ".done" );
if( lock.exists() )
if( lock.lastModified() > source.lastModified() )
return;
/* Build the maps */
StringTokenizer tokens = null;
String token = null;
if( ipmap )
{
tokens = new StringTokenizer( idl_package_map,
"," );
orig_keywords = new Vector();
String module = null;
String jpackage = null;
while( tokens.hasMoreTokens() )
{
token = tokens.nextToken();
if( token.indexOf( "=" ) == -1 )
{
project.log(
"Warning: mis-formatted idl to package mapping string.\n" );
ipmap = false;
break;
}
module = token.substring( 0,
token.indexOf( "=" ) );
jpackage = token.substring(
token.indexOf( "=" ) + 1, token.length() );
idl_modules.addElement( module
);
java_packages.addElement(
jpackage );
}
}
if( kwmap )
{
tokens = new StringTokenizer( keyword_map, ","
);
java_replacements = new Vector();
String origkw = null;
String newkw = null;
while( tokens.hasMoreTokens() )
{
token = tokens.nextToken();
if( token.indexOf( "=" ) == -1 )
{
project.log(
"Warning: mis-formatted keyword mapping string." );
kwmap = false;
break;
}
origkw = token.substring( 0,
token.indexOf( "=" ) );
newkw = token.substring(
token.indexOf( "=" ) + 1, token.length() );
orig_keywords.addElement(
origkw );
java_replacements.addElement(
newkw );
}
}
Vector argList = new Vector( );
argList.addElement( "idl2java" );
argList.addElement( "-fe" );
argList.addElement(
"com.inprise.vbroker.compiler.tools.idl2XXX" );
argList.addElement( "-be" );
argList.addElement(
"com.inprise.vbroker.compiler.backends.java.JavaBackend" );
if( no_line_directives )
argList.addElement( "-no_line_directives" );
if( list_includes )
argList.addElement( "-list_includes" );
if( retain_comments )
argList.addElement( "-retain_comments" );
if( gen_included_files )
argList.addElement( "-gen_included_files" );
if( list_files )
argList.addElement( "-list_files" );
if( dynamic_marshal )
argList.addElement( "-dynamic_marshal" );
if( stream_marshal )
argList.addElement( "-stream_marshal" );
if( strict )
argList.addElement( "-strict" );
if( version )
argList.addElement( "-version" );
if( ipmap )
{
Enumeration idlmod = idl_modules.elements();
Enumeration jpack = java_packages.elements();
while( jpack.hasMoreElements() )
{
argList.addElement(
"-idl2package" );
argList.addElement(
(String)idlmod.nextElement() );
argList.addElement(
(String)jpack.nextElement() );
}
}
if( kwmap )
{
Enumeration origkws = orig_keywords.elements();
Enumeration newkws =
java_replacements.elements();
while( newkws.hasMoreElements() )
{
argList.addElement(
"-map_keyword" );
argList.addElement(
(String)origkws.nextElement() );
argList.addElement(
(String)newkws.nextElement() );
}
}
if( idl_strict )
argList.addElement( "-idl_strict" );
else
argList.addElement( "-no_idl_strict" );
if( warn_unrecognized_pragmas )
argList.addElement( "-warn_unrecognized_pragmas" );
else
argList.addElement( "-no_warn_unrecognized_pragmas" );
if( back_compat_mapping )
argList.addElement( "-back_compat_mapping" );
else
argList.addElement( "-no_back_compat_mapping" );
if( boa )
argList.addElement( "-boa" );
else
argList.addElement( "-no_boa" );
if( comments )
argList.addElement( "-comments" );
else
argList.addElement( "-no_comments" );
if( obj_wrapper )
argList.addElement( "-obj_wrapper" );
else
argList.addElement( "-no_obj_wrapper" );
if( servant )
argList.addElement( "-servant" );
else
argList.addElement( "-no_servant" );
if( tie )
argList.addElement( "-tie" );
else
argList.addElement( "-no_tie" );
if( warn_missing_define )
argList.addElement( "-warn_missing_define" );
else
argList.addElement( "-no_warn_missing_define" );
if( bind )
argList.addElement( "-bind" );
else
argList.addElement( "-no_bind" );
if( compile )
argList.addElement( "-compile" );
else
argList.addElement( "-no_compile" );
if( copy_local_values )
argList.addElement( "-copy_local_values" );
else
argList.addElement( "-no_copy_local_values" );
if( examples )
argList.addElement( "-examples" );
else
argList.addElement( "-no_examples" );
if( dest != null )
{
argList.addElement( "-root_dir" );
argList.addElement( dest.getAbsolutePath() );
}
if( includes != null )
{
Enumeration inc = includes.elements();
while( inc.hasMoreElements() )
{
argList.addElement( "-include"
);
argList.addElement(
inc.nextElement() );
}
}
if( undefines != null )
{
Enumeration undef = undefines.elements();
while( undef.hasMoreElements() )
{
argList.addElement( "-undefine"
);
argList.addElement(
undef.nextElement() );
}
}
if( compiler != null )
{
argList.addElement( "-compiler" );
argList.addElement( compiler );
}
if( compiler_flags != null )
{
argList.addElement( "-compiler_flags" );
argList.addElement( compiler_flags );
}
if( jpackage != null )
{
argList.addElement( "-package" );
argList.addElement( jpackage );
}
argList.addElement( source.getAbsolutePath() );
String[] args = new String[argList.size()];
Enumeration argenum = argList.elements();
for( int i = 0; argenum.hasMoreElements(); i++ )
{
args[i] = (String)argenum.nextElement();
}
com.inprise.vbroker.compiler.tools.tool.main( args );
try
{
lock.createNewFile();
lock.setLastModified( source.lastModified() );
}
catch( java.io.IOException e )
{
project.log( "Warninng: error creating or
updating IDL lockfile. The IDL will be automatically rebuilt on next build
independant of timestamps." );
}
return;
}
}