[prev in list] [next in list] [prev in thread] [next in thread]
List: openorb-commits
Subject: [openorb-commits] CVS: PersistentStateService/src/main/org/openorb/pss/compiler/taskdefs package.htm
From: Erik Putrycz <putrycz () users ! sourceforge ! net>
Date: 2003-02-28 14:54:46
[Download RAW message or body]
Update of /cvsroot/openorb/PersistentStateService/src/main/org/openorb/pss/compiler/taskdefs
In directory sc8-pr-cvs1:/tmp/cvs-serv10201/src/main/org/openorb/pss/compiler/taskdefs
Added Files:
package.html Psdl2Java.java
Log Message:
added a psdl2java ant task + documentation
--- NEW FILE: package.html ---
<body>
<p>
This package contains all classes that concern the ANT Stdl2Java task.
</p>
</body>
--- NEW FILE: Psdl2Java.java ---
/*
* Copyright (C) The Community OpenORB Project. All rights reserved.
*
* This software is published under the terms of The OpenORB Community Software
* License version 1.0, a copy of which has been included with this distribution
* in the LICENSE.txt file.
*/
package org.openorb.pss.compiler.taskdefs;
import java.io.File;
import java.util.StringTokenizer;
import org.openorb.compiler.object.IdlImport;
import org.openorb.compiler.object.IdlObject;
import org.openorb.compiler.taskdefs.CacheFileNameMapper;
import org.openorb.compiler.taskdefs.GenericTask;
import org.openorb.compiler.taskdefs.Idl2JavaListener;
import org.openorb.pss.compiler.PsdlCompiler;
import org.openorb.pss.compiler.generator.psdlToJava;
import org.openorb.pss.compiler.parser.PsdlParser;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path;
/**
* This class is the AntTask for the OpenORB PSDL Compiler
* @author Erik Putrycz
* @version $Revision: 1.1 $ $Date: 2003/02/28 14:54:44 $
*/
public class Psdl2Java extends GenericTask
{
/**
* file name for the cache
*/
private final String m_cache_name = "psdl2java.cache";
private boolean m_export = true;
private PsdlParser m_parser = null;
protected static Psdl2Java s_singleton = null;
private static final int s_PERSISTENCY_MEMORY = 0;
private static final int s_PERSISTENCY_FILE = 1;
private static final int s_PERSISTENCY_DATABASE = 2;
private boolean m_generate_api = true;
private boolean m_generate_wrapper = true;
private boolean m_default_include = true;
private String m_external_wrapper = null;
private int m_persistence_type;
/**
* Constructor for Stdl2Java.
*/
public Psdl2Java()
{
if ( s_singleton == null )
{
s_singleton = this;
m_cache = new CacheFileNameMapper( this, new File( m_cache_name ) );
// setup the callback on new Java file creation
// to the singleton instance
new Idl2JavaListener();
}
}
public void setExport( boolean export )
{
m_export = export;
}
/*
* Beginning of setters for the Idl 2Java ant task
*/
public void setQuiet( boolean silent )
{
m_silentMode = silent;
}
public void setVerbose( boolean verbose )
{
this.m_verbose = verbose;
}
public void setGenerateAll( boolean gen_all )
{
this.m_map_all = gen_all;
}
public void setPIDL( boolean pidl )
{
if ( pidl )
{
this.m_pidl = true;
this.m_map_stub = false;
this.m_map_skeleton = false;
this.m_map_tie = false;
}
}
public void setJDK14Code( boolean jdk14 )
{
this.m_jdk1_4 = jdk14;
}
public void setUptodateChecks( boolean uptodate )
{
this.m_uptodate_check = uptodate;
}
public void setSrcdir( Path srcDir )
{
if ( m_src_path == null )
{
m_src_path = srcDir;
}
else
{
m_src_path.append( srcDir );
}
}
/**
* Set the include path ("-I" param)
* @param path
*/
public void setIncludePath( String path )
{
StringTokenizer st = new StringTokenizer( path, ";, " );
while ( st.hasMoreTokens() )
{
m_includeList.addElement( st.nextToken() );
}
}
public void setImportLink( String import_link_name )
{
this.m_importLink.addElement( import_link_name );
}
public void setDestDir( File dest_dir )
{
if ( m_packageName == null )
{
m_packageName = "";
m_use_package = false;
}
this.m_destdir = dest_dir;
}
public void setPersistenceType( PersistenceType pt )
{
String val = pt.getValue();
m_persistence_type = s_PERSISTENCY_MEMORY;
if ( "database".equals( val ) )
{
m_persistence_type = s_PERSISTENCY_DATABASE;
}
else if ( "file".equals( val ) )
{
m_persistence_type = s_PERSISTENCY_FILE;
}
}
public void setGenerateApi( boolean api )
{
m_generate_api = api;
}
public void setGenerateWrapper( boolean wrapper )
{
m_generate_wrapper = wrapper;
}
public void setExternalWrapper( String wrapper_name )
{
m_external_wrapper = wrapper_name;
}
public void setPackage( String package_name )
{
this.m_use_package = false;
this.m_packageName = package_name;
}
/**
* @see org.openorb.compiler.taskdefs.GenericTask#validateAttributes()
*/
protected void validateAttributes() throws BuildException
{
PsdlCompiler.database_persistence = false;
PsdlCompiler.file_persistence = false;
switch ( m_persistence_type )
{
case s_PERSISTENCY_DATABASE:
PsdlCompiler.database_persistence = true;
break;
case s_PERSISTENCY_FILE:
PsdlCompiler.file_persistence = true;
break;
}
PsdlCompiler.generate_api = m_generate_api;
PsdlCompiler.generate_wrapper = m_generate_wrapper;
PsdlCompiler.external_wrapper = m_external_wrapper;
PsdlCompiler.default_include = m_default_include;
}
/**
* @see org.openorb.compiler.taskdefs.GenericTask#prepare()
*/
protected void prepare()
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init( new String[0], null );
Idl2JavaListener.setCurrentListener( this );
if ( m_default_include )
{
m_importLink.addElement("CosPersistentState:CosPersistentState.idl");
}
// -- Welcome message --
if ( !m_silentMode )
{
log( "OpenORB PSDL Compiler" );
}
m_displayBadFlag = false;
m_use_package = false;
m_parser = new PsdlParser();
// ----------------
// Enhance compiler
// ----------------
org.openorb.pss.compiler.parser.PsdlSymbole.loadPsdlSymbole();
if ( m_default_include )
includePSS( m_parser, orb );
}
/**
* @see org.openorb.compiler.taskdefs.GenericTask#compile_file
*/
protected void compile_file( String filename )
{
IdlObject CompilationGraph = m_parser.compile_idl( filename );
if ( m_parser.totalError != 0 )
{
throw new BuildException(
"there are errors..." + "compilation process stopped !" );
}
// -------------------------
// translate to Data to Java
// -------------------------
psdlToJava toJava = new psdlToJava();
if ( m_export )
{
toJava.translateData( CompilationGraph, org.openorb.compiler.IdlCompiler.packageName );
}
}
/**
* Inport CosPersistentState
*/
public void includePSS( PsdlParser p, org.omg.CORBA.ORB orb )
{
org.openorb.pss.compiler.ir.IdlFromIR fromIR = new org.openorb.pss.compiler.ir.IdlFromIR();
fromIR.set_parser( p );
IdlImport importPSS = new IdlImport( p.root, "::CosPersistentState" );
importPSS._map = false;
p.root.addIdlObject( importPSS );
p.ctx = p.new_compilation_context();
try
{
p.ctx.sourceURL = new java.io.File( "" ).getCanonicalFile().toURL();
}
catch ( java.io.IOException ex )
{
// This should be impossible.
ex.printStackTrace();
System.exit( 0 );
}
org.openorb.compiler.parser.IdlParser.include_level = 1;
fromIR.getDescriptionFromIR( "::CosPersistentState", p.root );
org.openorb.compiler.parser.IdlParser.include_level = 0;
}
/**
* @see org.openorb.compiler.taskdefs.GenericTask#getSingleton()
*/
protected GenericTask getSingleton()
{
return s_singleton;
}
/**
* The list of possible PersistenceTypes
*/
public static class PersistenceType extends EnumeratedAttribute
{
/**
* @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
*/
public String[] getValues()
{
return new String[] {"memory", "file" ,"database"};
}
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
openorb-commits mailing list
openorb-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openorb-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic