diff --git a/CVSROOT/checkoutlist b/CVSROOT/checkoutlist deleted file mode 100644 index 2921bff..0000000 --- a/CVSROOT/checkoutlist +++ /dev/null @@ -1,13 +0,0 @@ -# The "checkoutlist" file is used to support additional version controlled -# administrative files in $CVSROOT/CVSROOT, such as template files. -# -# The first entry on a line is a filename which will be checked out from -# the corresponding RCS file in the $CVSROOT/CVSROOT directory. -# The remainder of the line is an error message to use if the file cannot -# be checked out. -# -# File format: -# -# [][] -# -# comment lines begin with '#' diff --git a/CVSROOT/commitinfo b/CVSROOT/commitinfo deleted file mode 100644 index b19e7b7..0000000 --- a/CVSROOT/commitinfo +++ /dev/null @@ -1,15 +0,0 @@ -# The "commitinfo" file is used to control pre-commit checks. -# The filter on the right is invoked with the repository and a list -# of files to check. A non-zero exit of the filter program will -# cause the commit to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/config b/CVSROOT/config deleted file mode 100644 index 92c150b..0000000 --- a/CVSROOT/config +++ /dev/null @@ -1,21 +0,0 @@ -# Set this to "no" if pserver shouldn't check system users/passwords -#SystemAuth=no - -# Put CVS lock files in this directory rather than directly in the repository. -#LockDir=/var/lock/cvs - -# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top -# level of the new working directory when using the `cvs checkout' -# command. -#TopLevelAdmin=no - -# Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the -# history file, or a subset as needed (ie `TMAR' logs all write operations) -#LogHistory=TOEFWUPCGMAR - -# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg -# script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra -# second per directory being committed, so it is not recommended for large -# repositories. Set it to `never' (the previous CVS behavior) to prevent -# verifymsg scripts from changing the log message. -#RereadLogAfterVerify=always diff --git a/CVSROOT/cvswrappers b/CVSROOT/cvswrappers deleted file mode 100644 index e989b75..0000000 --- a/CVSROOT/cvswrappers +++ /dev/null @@ -1,19 +0,0 @@ -# This file affects handling of files based on their names. -# -# The -m option specifies whether CVS attempts to merge files. -# -# The -k option specifies keyword expansion (e.g. -kb for binary). -# -# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) -# -# wildcard [option value][option value]... -# -# where option is one of -# -f from cvs filter value: path to filter -# -t to cvs filter value: path to filter -# -m update methodology value: MERGE or COPY -# -k expansion mode value: b, o, kkv, &c -# -# and value is a single-quote delimited value. -# For example: -#*.gif -k 'b' diff --git a/CVSROOT/editinfo b/CVSROOT/editinfo deleted file mode 100644 index d78886c..0000000 --- a/CVSROOT/editinfo +++ /dev/null @@ -1,21 +0,0 @@ -# The "editinfo" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/CVSROOT/loginfo b/CVSROOT/loginfo deleted file mode 100644 index 537607d..0000000 --- a/CVSROOT/loginfo +++ /dev/null @@ -1,27 +0,0 @@ -# The "loginfo" file controls where "cvs commit" log information -# is sent. The first entry on a line is a regular expression which must match -# the directory that the change is being made to, relative to the -# $CVSROOT. If a match is found, then the remainder of the line is a filter -# program that should expect log information on its standard input. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name ALL appears as a regular expression it is always used -# in addition to the first matching regex or DEFAULT. -# -# You may specify a format string as part of the -# filter. The string is composed of a `%' followed -# by a single format character, or followed by a set of format -# characters surrounded by `{' and `}' as separators. The format -# characters are: -# -# s = file name -# V = old version number (pre-checkin) -# v = new version number (post-checkin) -# t = tag or branch name -# -# For example: -#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog -# or -#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog diff --git a/CVSROOT/modules b/CVSROOT/modules deleted file mode 100644 index cb9e9ef..0000000 --- a/CVSROOT/modules +++ /dev/null @@ -1,26 +0,0 @@ -# Three different line formats are valid: -# key -a aliases... -# key [options] directory -# key [options] directory files... -# -# Where "options" are composed of: -# -i prog Run "prog" on "cvs commit" from top-level of module. -# -o prog Run "prog" on "cvs checkout" of module. -# -e prog Run "prog" on "cvs export" of module. -# -t prog Run "prog" on "cvs rtag" of module. -# -u prog Run "prog" on "cvs update" of module. -# -d dir Place module in directory "dir" instead of module name. -# -l Top-level directory only -- do not recurse. -# -# NOTE: If you change any of the "Run" options above, you'll have to -# release and re-checkout any working directories of these modules. -# -# And "directory" is a path to a directory relative to $CVSROOT. -# -# The "-a" option specifies an alias. An alias is interpreted as if -# everything on the right of the "-a" had been typed on the command line. -# -# You can encode a module within a module by using the special '&' -# character to interpose another module into the current module. This -# can be useful for creating a module that consists of many directories -# spread out over the entire source repository. diff --git a/CVSROOT/notify b/CVSROOT/notify deleted file mode 100644 index 74ae6f9..0000000 --- a/CVSROOT/notify +++ /dev/null @@ -1,12 +0,0 @@ -# The "notify" file controls where notifications from watches set by -# "cvs watch add" or "cvs edit" are sent. The first entry on a line is -# a regular expression which is tested against the directory that the -# change is being made to, relative to the $CVSROOT. If it matches, -# then the remainder of the line is a filter program that should contain -# one occurrence of %s for the user to notify, and information on its -# standard input. -# -# "ALL" or "DEFAULT" can be used in place of the regular expression. -# -# For example: -#ALL mail -s "CVS notification" %s diff --git a/CVSROOT/rcsinfo b/CVSROOT/rcsinfo deleted file mode 100644 index 49e59f4..0000000 --- a/CVSROOT/rcsinfo +++ /dev/null @@ -1,13 +0,0 @@ -# The "rcsinfo" file is used to control templates with which the editor -# is invoked on commit and import. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being made to, relative to the -# $CVSROOT. For the first match that is found, then the remainder of the -# line is the name of the file that contains the template. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/taginfo b/CVSROOT/taginfo deleted file mode 100644 index 274a46d..0000000 --- a/CVSROOT/taginfo +++ /dev/null @@ -1,20 +0,0 @@ -# The "taginfo" file is used to control pre-tag checks. -# The filter on the right is invoked with the following arguments: -# -# $1 -- tagname -# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d -# $3 -- repository -# $4-> file revision [file revision ...] -# -# A non-zero exit of the filter program will cause the tag to be aborted. -# -# The first entry on a line is a regular expression which is tested -# against the directory that the change is being committed to, relative -# to the $CVSROOT. For the first match that is found, then the remainder -# of the line is the name of the filter to run. -# -# If the repository name does not match any of the regular expressions in this -# file, the "DEFAULT" line is used, if it is specified. -# -# If the name "ALL" appears as a regular expression it is always used -# in addition to the first matching regex or "DEFAULT". diff --git a/CVSROOT/verifymsg b/CVSROOT/verifymsg deleted file mode 100644 index 86f747c..0000000 --- a/CVSROOT/verifymsg +++ /dev/null @@ -1,21 +0,0 @@ -# The "verifymsg" file is used to allow verification of logging -# information. It works best when a template (as specified in the -# rcsinfo file) is provided for the logging procedure. Given a -# template with locations for, a bug-id number, a list of people who -# reviewed the code before it can be checked in, and an external -# process to catalog the differences that were code reviewed, the -# following test can be applied to the code: -# -# Making sure that the entered bug-id number is correct. -# Validating that the code that was reviewed is indeed the code being -# checked in (using the bug-id number or a seperate review -# number to identify this particular code set.). -# -# If any of the above test failed, then the commit would be aborted. -# -# Actions such as mailing a copy of the report to each reviewer are -# better handled by an entry in the loginfo file. -# -# One thing that should be noted is the the ALL keyword is not -# supported. There can be only one entry that matches a given -# repository. diff --git a/JacobGeneratorEngine/.classpath b/JacobGeneratorEngine/.classpath deleted file mode 100644 index 87f1e21..0000000 --- a/JacobGeneratorEngine/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/JacobGeneratorEngine/.cvsignore b/JacobGeneratorEngine/.cvsignore deleted file mode 100644 index 216e6b0..0000000 --- a/JacobGeneratorEngine/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -JacobGen-*.zip diff --git a/JacobGeneratorEngine/.jetproperties b/JacobGeneratorEngine/.jetproperties deleted file mode 100644 index cf694b2..0000000 --- a/JacobGeneratorEngine/.jetproperties +++ /dev/null @@ -1,4 +0,0 @@ - - - templates - diff --git a/JacobGeneratorEngine/.project b/JacobGeneratorEngine/.project deleted file mode 100644 index c15501d..0000000 --- a/JacobGeneratorEngine/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - JacobGeneratorEngine - - - - - - org.eclipse.emf.codegen.JETBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.emf.codegen.jet.IJETNature - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/JacobGeneratorEngine/META-INF/MANIFEST.MF b/JacobGeneratorEngine/META-INF/MANIFEST.MF deleted file mode 100644 index bd1d228..0000000 --- a/JacobGeneratorEngine/META-INF/MANIFEST.MF +++ /dev/null @@ -1,28 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Jacob Generator Plug-in -Bundle-SymbolicName: JacobGenerator;singleton:=true -Bundle-Version: 1.0.02 -Bundle-Activator: plug.Activator -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.core.resources, - org.eclipse.emf, - org.eclipse.emf.codegen, - org.eclipse.emf.codegen.ecore, - org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xmi -Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Bundle-ClassPath: lib/jacob.jar, - lib/jacobgen.jar, - lib/log4j-1.2.15.jar, - . -Export-Package: com.jacob.activeX;uses:="com.jacob.com", - com.jacob.com;uses:="com.jacob.test", - com.jacob.jacobgen, - net.sourceforge.jacob.generator, - net.sourceforge.jacob.generator.adapters;uses:="org.eclipse.emf.ecore", - net.sourceforge.jacob.generator.adapters.classInfo;uses:="net.sourceforge.jacob.generator.adapters,org.eclipse.emf.ecore", - plug;uses:="org.eclipse.jface.resource,org.eclipse.ui.plugin,org.osgi.framework", - plug.popup.actions;uses:="org.eclipse.jface.action,org.eclipse.ui,org.eclipse.jface.viewers" diff --git a/JacobGeneratorEngine/build.properties b/JacobGeneratorEngine/build.properties deleted file mode 100644 index 03671b1..0000000 --- a/JacobGeneratorEngine/build.properties +++ /dev/null @@ -1,11 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = plugin.xml,\ - META-INF/,\ - .,\ - lib/jacob.jar,\ - lib/log4j-1.2.15.jar,\ - lib/jacobgen.jar,\ - templates/,\ - plugin.properties,\ - build.properties diff --git a/JacobGeneratorEngine/build2.xml b/JacobGeneratorEngine/build2.xml deleted file mode 100644 index 43801df..0000000 --- a/JacobGeneratorEngine/build2.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - model="model/company.ecore" - genmodel="model/company.genmodel" - - reconcileGenModel="reload" - - generateJavaCode="true" - generateModelProject="false" - generateEditProject="false" - generateEditorProject="false" - - modelProject="D:/workspace/sourceforge/JacobGeneratorEngine" - modelProjectFragmentPath="genSrc" - > - - - - - - - Make sure you have changed the manifest file as well !!! ${Bundle-Version} - - - - - diff --git a/JacobGeneratorEngine/lib/jacob-1.14.1-x64.dll b/JacobGeneratorEngine/lib/jacob-1.14.1-x64.dll deleted file mode 100644 index 044de5b..0000000 Binary files a/JacobGeneratorEngine/lib/jacob-1.14.1-x64.dll and /dev/null differ diff --git a/JacobGeneratorEngine/lib/jacob-1.14.1-x86.dll b/JacobGeneratorEngine/lib/jacob-1.14.1-x86.dll deleted file mode 100644 index 5e6bc8f..0000000 Binary files a/JacobGeneratorEngine/lib/jacob-1.14.1-x86.dll and /dev/null differ diff --git a/JacobGeneratorEngine/lib/jacob.jar b/JacobGeneratorEngine/lib/jacob.jar deleted file mode 100644 index 3d59cdc..0000000 Binary files a/JacobGeneratorEngine/lib/jacob.jar and /dev/null differ diff --git a/JacobGeneratorEngine/lib/jacobgen.dll b/JacobGeneratorEngine/lib/jacobgen.dll deleted file mode 100644 index 9ff83af..0000000 Binary files a/JacobGeneratorEngine/lib/jacobgen.dll and /dev/null differ diff --git a/JacobGeneratorEngine/lib/jacobgen.jar b/JacobGeneratorEngine/lib/jacobgen.jar deleted file mode 100644 index 719cd8c..0000000 Binary files a/JacobGeneratorEngine/lib/jacobgen.jar and /dev/null differ diff --git a/JacobGeneratorEngine/lib/junit-4.4.jar b/JacobGeneratorEngine/lib/junit-4.4.jar deleted file mode 100644 index 649b0b3..0000000 Binary files a/JacobGeneratorEngine/lib/junit-4.4.jar and /dev/null differ diff --git a/JacobGeneratorEngine/lib/log4j-1.2.15.jar b/JacobGeneratorEngine/lib/log4j-1.2.15.jar deleted file mode 100644 index c930a6a..0000000 Binary files a/JacobGeneratorEngine/lib/log4j-1.2.15.jar and /dev/null differ diff --git a/JacobGeneratorEngine/plugin.properties b/JacobGeneratorEngine/plugin.properties deleted file mode 100644 index 920303a..0000000 --- a/JacobGeneratorEngine/plugin.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# -# -# $Id$ - -# ==================================================================== -# To code developer: -# Do NOT change the properties between this line and the -# "%%% END OF TRANSLATED PROPERTIES %%%" line. -# Make a new property name, append to the end of the file and change -# the code to use the new property. -# ==================================================================== - -# ==================================================================== -# %%% END OF TRANSLATED PROPERTIES %%% -# ==================================================================== - -pluginName = JACOB JAVA Generator -providerName = jacob-project.sourceforge.net diff --git a/JacobGeneratorEngine/plugin.xml b/JacobGeneratorEngine/plugin.xml deleted file mode 100644 index dacb5b5..0000000 --- a/JacobGeneratorEngine/plugin.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java b/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java deleted file mode 100644 index ec9c6af..0000000 --- a/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * TypeLibInspector.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * 2007 modified by Robert Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -/** - * The wrapper for the jni code that generates the tokenized representatation of - * the DLL that is used by the java classes to generate the stubs - * - * @version $Id$ - * - */ -public class TypeLibInspector { - - static { - System.loadLibrary("Jacobgen"); - } - - public static void main(final String[] argv) { - byte buf[]; - - final TypeLibInspector dll = new TypeLibInspector(); - - if (argv.length > 0) { - buf = dll.queryInterface(argv[0]); - - for (int i = 0; i < buf.length; i++) { - System.out.print((char) buf[i]); - } - } else { - System.out.println("TypeLibInspector "); - } - } - - /** - * the front for the actual jni code that is the working guts of this thing - * - * @param filename - * @return - */ - public native byte[] queryInterface(String filename); - -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java deleted file mode 100644 index a664aa3..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.LineNumberReader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterEnumerator; -import net.sourceforge.jacob.generator.adapters.AdapterEnumeratorValues; -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; -import net.sourceforge.jacob.generator.adapters.BaseAdapter; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClass; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassExtends; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassGUID; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassMethod; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassPropertyGet; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassPropertyPut; - -import org.apache.log4j.Logger; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; - -import com.jacob.jacobgen.TypeLibInspector; - -public class TLBtoECOREtoCODE { - private final String fileLocation ; - - private final static Logger log = Logger.getLogger(TLBtoECOREtoCODE.class); - - private AdapterClass classAdapter; - - private AdapterEnumerator classEnumeration; - private EPackage companyPackage = null; - private final java.util.List firstPassCommands = new ArrayList(); - private final EPackage superPackage = EcoreFactory.eINSTANCE.createEPackage(); - private final String typelibFilename; - - public TLBtoECOREtoCODE(final String destinationPackage, final String typelibFilename, final String fileLocation) { - this.typelibFilename = typelibFilename; - this.fileLocation = fileLocation; - - // create a package that represents company - final StringTokenizer packageTokenizer = new StringTokenizer(destinationPackage.trim(), "."); - final String superPackageName = packageTokenizer.nextToken(); - - superPackage.setName(superPackageName); - superPackage.setNsPrefix(superPackageName + "NS"); - superPackage.setNsURI("http://generator.jacob.sourceforge.net/" + superPackageName); - - if (packageTokenizer.countTokens() > 1) { - EPackage sup = superPackage; - EPackage sub = superPackage; - while (packageTokenizer.hasMoreTokens()) { - sup = sub; - final String subPackageName = packageTokenizer.nextToken(); - sub = AdapterUtilities.createSubPackage(sup, subPackageName); - } - companyPackage = sub; - } else { - companyPackage = superPackage; - } - } - - private void addAttributesParameters(final LineNumberReader lnr) throws IOException { - String firstLine = lnr.readLine();// skip TYPELIB - firstLine = lnr.readLine(); - EClass classModel = null; - EEnum enumModel = null; - while (firstLine != null) { - firstLine = firstLine.trim(); - log.debug(firstLine); - boolean accepted = false; - if (classAdapter.isAccepted(firstLine)) { - classModel = null; - enumModel = null; - accepted = true; - classModel = classAdapter.getCreateClass(); - } else if (classEnumeration.isAccepted(firstLine)) { - classModel = null; - enumModel = null; - accepted = true; - enumModel = classEnumeration.getCreateEEnum(); - } else { - for (final BaseAdapter typesAdapter : firstPassCommands) { - accepted = typesAdapter.isAccepted(firstLine); - if (accepted) { - classModel = null; - enumModel = null; - break; - } - } - if ((null != enumModel) && (false == accepted)) { - // FIXME does an Enum have a GUID??? - accepted = firstLine.startsWith("GUID;{"); - - } - if ((null != classModel) && (false == accepted)) { // method or - // attribute - final List secondPassCommands = new ArrayList(); - secondPassCommands.clear(); - secondPassCommands.add(new AdapterClassMethod(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassPropertyGet(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassPropertyPut(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassExtends(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassGUID(companyPackage, classModel)); - for (final BaseAdapter command : secondPassCommands) { - accepted = command.isAccepted(firstLine); - if (accepted) { - command.process(firstLine); - break; - } - } - } - - } - if (false == accepted) { - log.fatal("Problem with \t'" + firstLine + "'"); - System.exit(-1); - } - firstLine = lnr.readLine(); - } - } - - /** - * @see http://www.devx.com/Java/Article/29093/1954?pf=true - * @throws FileNotFoundException - * @throws IOException - */ - public void generate() throws FileNotFoundException, IOException { - // readFile(typelibFilename); - final TypeLibInspector lib = new TypeLibInspector(); - assert null != typelibFilename; - final byte[] queryInterface = lib.queryInterface(typelibFilename); - System.out.flush(); - System.err.flush(); - final String st = new String(queryInterface); - final String typeLib = new LineNumberReader(new StringReader(st)).readLine().substring("TYPELIB ".length()).trim(); - - { - final String subPackageName = typeLib; - companyPackage = AdapterUtilities.createSubPackage(companyPackage, subPackageName); - } - - packageAdapatersFactory(); - structureOnly(new LineNumberReader(new StringReader(st))); - - addAttributesParameters(new LineNumberReader(new StringReader(st))); - save(superPackage); - - final File xmiFile = new File(fileLocation + ".xmi"); - final File ecoreFile = new File(fileLocation + ".ecore"); - if (ecoreFile.exists()) - ecoreFile.delete(); - xmiFile.renameTo(ecoreFile); - } - - private void packageAdapatersFactory() { - firstPassCommands.clear(); - classAdapter = new AdapterClass(companyPackage); - firstPassCommands.add(classAdapter); - classEnumeration = new AdapterEnumerator(companyPackage); - firstPassCommands.add(classEnumeration); - firstPassCommands.add(new AdapterEnumeratorValues(companyPackage, classEnumeration)); - } - - private void save(final EObject company) throws IOException { - // create resource set and resource - final ResourceSet resourceSet = new ResourceSetImpl(); - - // Register XML resource factory - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); - - final Resource resource = resourceSet.createResource(URI.createFileURI(fileLocation + ".xmi")); - // add the root object to the resource - resource.getContents().add(company); - // serialize resource – you can specify also serialization - // options which defined on org.eclipse.emf.ecore.xmi.XMIResource - resource.save(null); - } - - private void structureOnly(final LineNumberReader lnr) throws IOException { - String firstLine; - do { - firstLine = lnr.readLine(); - boolean accepted = false; - for (final BaseAdapter command : firstPassCommands) { - accepted = command.isAccepted(firstLine); - if (accepted) { - command.process(firstLine); - break; - } - } - } while (firstLine != null); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java deleted file mode 100644 index d607c08..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.apache.log4j.Logger; - -/** - * This is the root class for Jacobgen. It generates Jacob wrapper class for - * windows DLLs. Run this class with no command line parameters to get a list of - * the valid command line options - * - * - * %JRE% -Xint com.jacob.jacobgen.Jacobgen %1 %2 %3 %4 %5 - * - * - * @version $Id$ - * @author Robert Searle - */ -public class TestGenerator { - public static final String MODEL = "model"; - - public static final String MODEL_COMPANY = MODEL + java.io.File.separatorChar + "company"; - - final static private Logger log = Logger.getLogger(TestGenerator.class); - - public static void main(final String[] args) { - org.apache.log4j.BasicConfigurator.configure(); - - if (args.length == 0) { - System.out.println("JacobGen [options] typelibfile\n"); - System.out.println("Options:"); - System.out.println("\t-package:"); - System.out.println(); - System.exit(0); - } else { - final TestGenerator g = new TestGenerator(args); - g.parseOptions(args); - if (g.typelibFilename == null) { - System.out.println("Jacobgen you need to specify an input file"); - } else { - final TLBtoECOREtoCODE gener = new TLBtoECOREtoCODE(g.destinationPackage, g.typelibFilename, MODEL_COMPANY); - try { - gener.generate(); - } catch (final FileNotFoundException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final IOException e) { - System.out.flush(); - e.printStackTrace(); - } - System.out.println("Done"); - } - System.exit(0); - } - } - - String destinationPackage; - - String typelibFilename; - - public TestGenerator(final String[] args) { - parseOptions(args); - } - - private void parseOptions(final String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].startsWith("-package:")) { - destinationPackage = args[i].substring("-package:".length()); - } else { - typelibFilename = args[i]; - } - } - log.debug("destinationPackage = '" + destinationPackage + "'"); - log.debug("typelibFilename = '" + typelibFilename + "'"); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java deleted file mode 100644 index 25586ee..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterEnumerator extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterEnumerator.class); - private EEnum createEEnum; - private String enumName; - - public AdapterEnumerator(final EPackage companyPackage) { - super("CLASS ", companyPackage); - } - - public EEnum getCreateEEnum() { - assert null != createEEnum; - return createEEnum; - } - - @Override - public boolean isAccepted(final String line) { - if (!super.isAccepted(line)) { - return false; - } - final StringTokenizer st = new StringTokenizer(line.substring(begining().length()).trim(), ";"); - if (st.countTokens() != 2) { - return false; - } - enumName = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final String parameters = st.nextToken().trim(); - return "TKIND_ENUM".equals(parameters); - } - - @Override - public void process(final String textLine) { - log.debug(enumName); - createEEnum = EcoreFactory.eINSTANCE.createEEnum(); - createEEnum.setName(enumName); - companyPackage.getEClassifiers().add(createEEnum); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java deleted file mode 100644 index e96eb3e..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EEnumLiteral; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterEnumeratorValues extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterEnumeratorValues.class); - private final AdapterEnumerator enumerationClass; - - public AdapterEnumeratorValues(final EPackage companyPackage, final AdapterEnumerator enumerationClass) { - super("VAR_CONST;", companyPackage); - this.enumerationClass = enumerationClass; - } - - @Override - public void process(final String textLine) { - /* - * VAR_CONST;wbemImpersonationLevelAnonymous;VT_I4;1 - * VAR_CONST;wbemImpersonationLevelIdentify;VT_I4;2 - * VAR_CONST;wbemImpersonationLevelImpersonate;VT_I4;3 - * VAR_CONST;wbemImpersonationLevelDelegate;VT_I4;4 - */ - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String name = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final int ordal = Integer.parseInt(st.nextToken().trim()); - final EEnumLiteral createEEnumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral(); - createEEnumLiteral.setValue(ordal); - createEEnumLiteral.setName(name); - createEEnumLiteral.setLiteral(name); - - enumerationClass.getCreateEEnum().getELiterals().add(createEEnumLiteral); - } - -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java deleted file mode 100644 index f2b29c8..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EParameter; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.EcorePackage; - -import com.jacob.com.Dispatch; -import com.jacob.com.Variant; - -public class AdapterUtilities { - private static EPackage comJacobComPackage; - - final public static Set ignoreAttributeList = new HashSet(); - - final static private Logger log = Logger.getLogger(AdapterUtilities.class); - static final public String UNDERSCORE_REPLACEMENT = "JACOB"; - private static EDataType vtDispatchType = null; - - private static EDataType vtVariantType = null; - - static { - ignoreAttributeList.add("defaultValue"); // FIXME Is it safe to - // ignore this? - ignoreAttributeList.add("DefaultValue"); // FIXME Is it safe to - // ignore this? - ignoreAttributeList.add("Name"); // FIXME Is it safe to ignore this? - ignoreAttributeList.add("_NewEnum"); // FIXME Is it safe to ignore - // this? - ignoreAttributeList.add(""); - ignoreAttributeList.add(null); - } - - public static String changeUnderscoredName(String className) { - className = className.trim(); - if (className.startsWith("_")) { // FIXME - className = AdapterUtilities.UNDERSCORE_REPLACEMENT + className; - } - return className; - } - - public static EStructuralFeature createAttribute(final String type, final String name, final EPackage companyPackage, final EClass classModel) { - final EClassifier classifier; - classifier = getClassifier(type, companyPackage); - if (classifier instanceof EClass) { - // Attribute is a different class - final EReference createEReference = EcoreFactory.eINSTANCE.createEReference(); - createEReference.setChangeable(false); - createEReference.setVolatile(true); - createEReference.setDerived(true); - createEReference.setName(name); - createEReference.setEType(classifier); - classModel.getEStructuralFeatures().add(createEReference); - return createEReference; - } else { - // Basic Attribute. - final EAttribute createEAttribute = AdapterUtilities.createEAttribute(name, classifier); - assert (null != classifier); - classModel.getEStructuralFeatures().add(createEAttribute); - return createEAttribute; - } - } - - public static EAttribute createEAttribute(final String name, final EClassifier classifier) { - final EAttribute createEAttribute = EcoreFactory.eINSTANCE.createEAttribute(); - createEAttribute.setDerived(true); // no need for a class attribute - createEAttribute.setTransient(true); - createEAttribute.setVolatile(true); - createEAttribute.setChangeable(false); - createEAttribute.setName(name); - createEAttribute.setEType(classifier); - return createEAttribute; - } - - public static void createMethod(final String textLine, final String returnType, final String functionName, final String parameters, final EPackage companyPackage, - final EClass classModel) { - log.debug(classModel.getName() + "\t" + functionName); - final EOperation method = EcoreFactory.eINSTANCE.createEOperation(); - final EClassifier classifier = AdapterUtilities.getClassifier(returnType, companyPackage); - method.setEType(classifier); - method.setName(functionName); - classModel.getEOperations().add(method); - - final String substring = parameters.substring(1, parameters.length() - 1); - log.debug("\t" + substring); - if (substring.length() != 0) { - final StringTokenizer paramterTokens = new StringTokenizer(substring, ","); - do { - final String paramterValues = paramterTokens.nextToken().trim(); - log.debug("\t\t" + paramterValues); - final StringTokenizer paramterToken = new StringTokenizer(paramterValues, ",} "); - - final String inOut; - final String type; - final String name; - if (paramterToken.countTokens() == 3) { - inOut = paramterToken.nextToken().trim(); - type = paramterToken.nextToken().trim(); - name = paramterToken.nextToken().trim(); - } else if (paramterToken.countTokens() == 2) { - inOut = null; - type = paramterToken.nextToken().trim(); - name = paramterToken.nextToken().trim(); - } else { - // log.error(paramterValues); - throw new RuntimeException("Could not process this line" + textLine); - } - - final EParameter createEParameter = EcoreFactory.eINSTANCE.createEParameter(); - createEParameter.setName(name); - - final EClassifier parameterClassifier = AdapterUtilities.getClassifier(type, companyPackage); - createEParameter.setEType(parameterClassifier); - method.getEParameters().add(createEParameter); - } while (paramterTokens.hasMoreTokens()); - } - }; - - /** - * @param packageTokenizer - * @param sup - * @param subPackageName - * @return - */ - public static EPackage createSubPackage(final EPackage sup, final String subPackageName) { - EPackage sub; - sub = EcoreFactory.eINSTANCE.createEPackage(); - sub.setName(subPackageName); - sub.setNsPrefix(subPackageName + "NS"); - sub.setNsURI("http://generator.jacob.sourceforge.net/" + subPackageName); - sup.getESubpackages().add(sub); - return sub; - } - - /** - * - * @param returnType - * @param companyPackage - * @return - */ - public static EClassifier getClassifier(final String returnType, final EPackage companyPackage) { - final EClassifier classifier; - - /* - * Eclipse Development using the Graphical Editing Framework and the - * Eclipse Modeling Framework - * - * Declaring datatypes EMF provides datatypes such as EString and EInt, - * which represent the basic Java types that you can use for simple - * attributes. If you need to use a different Java type, you need to - * create an EDataType to represent it. For example, we use EString to - * represent attributes such as condition of ConditionalOutputPort and - * whileCondition for LoopTask from the WorkflowModel for the sample - * application. If we wanted to represent these conditions with a - * specific existing Java type instead, we would declare an EDataType - * corresponding to that type, as follows: - */ - - if ("VT_VOID".equals(returnType)) { - classifier = null; - } else if ("VT_BOOL".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEBoolean(); - } else if ("VT_UI2".equals(returnType) || "VT_UINT".equals(returnType) || "VT_INT".equals(returnType) || "VT_UI4".equals(returnType) || "VT_I4".equals(returnType) - || "VT_HRESULT".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEInt(); - } else if ("VT_R4".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEFloat(); - } else if ("VT_R8".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEDouble(); - } else if ("VT_DATE".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEDate(); - } else if ("VT_BSTR".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEString(); - } else if ("GUID".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getELong(); - } else if ("VT_UNKNOWN".equals(returnType) || "EXCEPINFO".equals(returnType) || "DISPPARAMS".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEObject(); - } else { - if ("VT_VARIANT".equals(returnType)) { - classifier = getVariant(companyPackage); - } else if ("VT_PTR".equals(returnType)) { - // FIXME Is a VT_PTR really a object? - classifier = EcorePackage.eINSTANCE.getEJavaObject(); - } else if ("IDispatch".equals(returnType) || "Dispatch".equals(returnType) || "VT_DISPATCH".equals(returnType)) { - classifier = getDispatch(companyPackage); - } else { - final EClassifier possibleValue = companyPackage.getEClassifier(returnType); - if (possibleValue == null) { - log.warn(returnType + "\t" + "Cannot be mapped"); - classifier = EcorePackage.eINSTANCE.getEJavaObject(); - } else - classifier = possibleValue; - } - } - return classifier; - } - - private static EPackage getComJacobComPackage(final EPackage companyPackage) { - if (null == comJacobComPackage) { - EPackage comPackage = companyPackage; - while (!comPackage.getName().equals("com")) { - comPackage = comPackage.getESuperPackage(); - } - final EPackage comJacobPackage = EcoreFactory.eINSTANCE.createEPackage(); - comJacobPackage.setName("jacob"); - comJacobPackage.setNsPrefix("jacob2" + "NS"); - comJacobPackage.setNsURI("http://generator.jacob.sourceforge.net/" + "jacob2"); - comPackage.getESubpackages().add(comJacobPackage); - - comJacobComPackage = EcoreFactory.eINSTANCE.createEPackage(); - comJacobComPackage.setName("com"); - comJacobComPackage.setNsPrefix("com2" + "NS"); - comJacobComPackage.setNsURI("http://generator.jacob.sourceforge.net/" + "com2"); - comJacobPackage.getESubpackages().add(comJacobComPackage); - } - return comJacobComPackage; - } - - public static EDataType getDispatch(final EPackage companyPackage) { - if (vtDispatchType == null) { - vtDispatchType = EcoreFactory.eINSTANCE.createEDataType(); - final Class dispatchClass = Dispatch.class; - vtDispatchType.setInstanceClassName(dispatchClass.getCanonicalName()); - vtDispatchType.setInstanceClass(dispatchClass); - vtDispatchType.setName(dispatchClass.getSimpleName()); - getComJacobComPackage(companyPackage).getEClassifiers().add(vtDispatchType); - } - return vtDispatchType; - } - - static public Set getIgnoreAttributeList() { - return ignoreAttributeList; - } - - public static EDataType getVariant(final EPackage companyPackage) { - if (vtVariantType == null) { - vtVariantType = EcoreFactory.eINSTANCE.createEDataType(); - final Class variantClass = Variant.class; - vtVariantType.setInstanceClassName(variantClass.getCanonicalName()); - vtVariantType.setInstanceClass(variantClass); - vtVariantType.setName(variantClass.getSimpleName()); - - getComJacobComPackage(companyPackage).getEClassifiers().add(vtVariantType); - } - return vtVariantType; - } - -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java deleted file mode 100644 index 4e411d7..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import org.eclipse.emf.ecore.EPackage; - -public abstract class BaseAdapter { - protected final EPackage companyPackage; - final private String TEXT; - - public BaseAdapter(final String text, final EPackage companyPackage) { - this.TEXT = text; - this.companyPackage = companyPackage; - } - - public String begining() { - return TEXT; - } - - public boolean isAccepted(final String line) { - if (line == null) { - return false; - } - if (line.length() < begining().length()) { - return false; - } - return line.startsWith(begining()); - } - - abstract public void process(final String textLine); -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java deleted file mode 100644 index e406b03..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; -import net.sourceforge.jacob.generator.adapters.BaseAdapter; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterClass extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterClass.class); - private String className; - private EClass createClass; - private EPackage implPackage; - private boolean isInterface; - - public AdapterClass(final EPackage companyPackage) { - super("CLASS ", companyPackage); - assert null != companyPackage; - } - - public EClass getCreateClass() { - assert null != createClass; - return createClass; - } - - @Override - public boolean isAccepted(final String line) { - if (!super.isAccepted(line)) { - return false; - } - final StringTokenizer st = new StringTokenizer(line.substring(begining().length()).trim(), ";"); - if (st.countTokens() != 2) { - return false; - } - className = st.nextToken().trim(); - className = AdapterUtilities.changeUnderscoredName(className); - final String parameters = st.nextToken().trim(); - isInterface = "TKIND_DISPATCH".equals(parameters) || "TKIND_INTERFACE".equals(parameters); - final boolean isClass = "TKIND_COCLASS".equals(parameters) || isInterface; - if (isClass) { - log.debug(className); - createClass = (EClass) companyPackage.getEClassifier(className); - } else - createClass = null; - return isClass; - } - - @Override - public void process(final String textLine) { - createClass = null; - createClass = EcoreFactory.eINSTANCE.createEClass(); - createClass.setInterface(isInterface); - createClass.setAbstract(isInterface); - createClass.setName(className); - log.debug(className + "\t Yes its an interface: " + isInterface); - if (isInterface) { - companyPackage.getEClassifiers().add(createClass); - final EClass createClass2 = EcoreFactory.eINSTANCE.createEClass(); - createClass2.setInterface(false); - createClass2.setAbstract(false); - createClass2.getESuperTypes().add(createClass); - createClass2.setName(className); - - final EStructuralFeature createAttribute2 = AdapterUtilities.createAttribute("Dispatch", "Dispatch", companyPackage, createClass2); - createAttribute2.setDerived(false); - createAttribute2.setChangeable(true); - createAttribute2.setVolatile(false); - if (companyPackage.getESubpackages().size() == 0) { - implPackage = AdapterUtilities.createSubPackage(companyPackage, "jacobimpl"); - } - implPackage.getEClassifiers().add(createClass2); - } else { - final EStructuralFeature createAttribute = AdapterUtilities.createAttribute("Dispatch", "Dispatch", companyPackage, createClass); - createAttribute.setDerived(false); - createAttribute.setChangeable(true); - createAttribute.setVolatile(false); - companyPackage.getEClassifiers().add(createClass); - } - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java deleted file mode 100644 index 60f4b88..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; - -public class AdapterClassExtends extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassExtends.class); - - public AdapterClassExtends(final EPackage companyPackage, final EClass classModel) { - super("EXTENDS;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String superClass = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - - log.debug("\t" + superClass); - EClass classifier = (EClass) companyPackage.getEClassifier(superClass); - assert (classifier != null); - if ("IDispatch".equals(superClass)) { - final EClassifier disClassifier = AdapterUtilities.getClassifier(superClass, companyPackage); - classifier = disClassifier.eClass(); - } - assert (classifier != null); - if (classifier != null) - classModel.getESuperTypes().add(classifier); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java deleted file mode 100644 index 77942e1..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; - -public class AdapterClassGUID extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassGUID.class); - - public AdapterClassGUID(final EPackage companyPackage, final EClass classModel) { - super("GUID;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - if (classModel.isInterface()) - return; - // FIXME Nothing is done with the GUID!! - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String classGUID = st.nextToken(); - log.debug("\t" + classGUID); - final EAttribute guidEAttribute = AdapterUtilities.createEAttribute( // FIXME - "_GUID", EcorePackage.eINSTANCE.getEString()); - guidEAttribute.setDerived(false); // no need for a class attribute - guidEAttribute.setTransient(false); - guidEAttribute.setVolatile(false); - guidEAttribute.setChangeable(false); - guidEAttribute.setDefaultValue(classGUID); - classModel.getEStructuralFeatures().add(guidEAttribute); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java deleted file mode 100644 index 37a521f..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; - -public class AdapterClassMethod extends BaseAdapterClass { - final static Set ignoreList = new HashSet(); - final static private Logger log = Logger.getLogger(AdapterClassMethod.class); - - static { - ignoreList.add("QueryInterface"); - ignoreList.add("AddRef"); - ignoreList.add("Release"); - ignoreList.add("GetTypeInfoCount"); - ignoreList.add("GetTypeInfo"); - ignoreList.add("GetIDsOfNames"); - ignoreList.add("Invoke"); - ignoreList.add(""); - ignoreList.add(null); - }; - - public AdapterClassMethod(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_FUNC;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - // log.debug(textLine); - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String returnType = st.nextToken().trim(); - final String functionName = st.nextToken().trim(); - final String parameters = st.nextToken().trim(); - - if (!ignoreList.contains(functionName)) { - AdapterUtilities.createMethod(textLine, returnType, functionName, parameters, companyPackage, classModel); - } - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java deleted file mode 100644 index 2de92cc..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; - -public class AdapterClassPropertyGet extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassPropertyGet.class); - - public AdapterClassPropertyGet(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_PROPERTYGET;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - String name = st.nextToken().trim(); - final String inOut = st.nextToken().trim(); - log.debug(classModel.getName() + "\t" + name + "\t" + type + "\t" + inOut); - if (inOut.startsWith("[")) { - log.warn(inOut); - } - - if (AdapterUtilities.getIgnoreAttributeList().contains(name)) {// FIXME - log.warn("Can not add '" + name + "' to" + classModel.getName()); - return; - } - name = AdapterUtilities.changeUnderscoredName(name); - - final EStructuralFeature structuralFeature = classModel.getEStructuralFeature(name); - - if (!"[]".equals(inOut)) { - // Could already exist because of put - if (null == structuralFeature) { - final EStructuralFeature createAttribute = AdapterUtilities.createAttribute(type, name, companyPackage, classModel); - } - AdapterUtilities.createMethod(textLine, type, "get" + name, inOut, companyPackage, classModel); - } else { - AdapterUtilities.createAttribute(type, name, companyPackage, classModel); - } - } - -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java deleted file mode 100644 index 0f85d84..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; - -public class AdapterClassPropertyPut extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassPropertyPut.class); - - public AdapterClassPropertyPut(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_PROPERTYPUT;", companyPackage, classModel); - } - - /* - * (non-Javadoc) - * - * @see net.sourceforge.jacob.generator.adapters.BaseAdapter#isAccepted(java.lang.String) - */ - @Override - public boolean isAccepted(final String line) { - if (super.isAccepted(line)) - return true; - else - return line.startsWith("INVOKE_PROPERTYPUTREF;"); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine, ";"); - final String value = st.nextToken().trim(); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - String name = st.nextToken().trim(); - log.debug(classModel.getName() + "\t" + name + "\t" + type); - if (AdapterUtilities.getIgnoreAttributeList().contains(name)) {// FIXME - log.warn("Can not add '" + name + "' to" + classModel.getName()); - return; - } - name = AdapterUtilities.changeUnderscoredName(name); - - EStructuralFeature structuralFeature = classModel.getEStructuralFeature(name); - if (null == structuralFeature) { - log.fatal("Attribute\t" + name); - final EClassifier classifier = AdapterUtilities.getDispatch(companyPackage); -// final EClassifier classifier = AdapterUtilities.getClassifier(type, companyPackage); - structuralFeature = AdapterUtilities.createEAttribute(name, classifier); - structuralFeature.setChangeable(false); - structuralFeature.setVolatile(true); - structuralFeature.setDerived(true); - classModel.getEStructuralFeatures().add(structuralFeature); - } - structuralFeature.setChangeable(true); - } -} diff --git a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java b/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java deleted file mode 100644 index 72c5d32..0000000 --- a/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import net.sourceforge.jacob.generator.adapters.BaseAdapter; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; - -public abstract class BaseAdapterClass extends BaseAdapter { - protected final EClass classModel; - - public BaseAdapterClass(final String text, final EPackage companyPackage, final EClass classModel) { - super(text, companyPackage); - this.classModel = classModel; - } - -} diff --git a/JacobGeneratorEngine/src/plug/Activator.java b/JacobGeneratorEngine/src/plug/Activator.java deleted file mode 100644 index a25e902..0000000 --- a/JacobGeneratorEngine/src/plug/Activator.java +++ /dev/null @@ -1,61 +0,0 @@ -package plug; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "JacobGenerator"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } -} diff --git a/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java b/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java deleted file mode 100644 index e9c7320..0000000 --- a/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java +++ /dev/null @@ -1,86 +0,0 @@ -package plug.popup.actions; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URI; - -import net.sourceforge.jacob.generator.TLBtoECOREtoCODE; -import net.sourceforge.jacob.generator.TestGenerator; - -import org.eclipse.core.internal.resources.File; -import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -import sun.rmi.runtime.Log; - -public class NewAction implements IObjectActionDelegate { - - private File selectedFile; - - /** - * Constructor for Action1. - */ - public NewAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } - - /** - * @see IActionDelegate#run(IAction) - */ - @SuppressWarnings("restriction") - public void run(IAction action) { - try { - final String output = selectedFile.getLocation().toFile().getAbsoluteFile().getParent() + java.io.File.separatorChar + TestGenerator.MODEL_COMPANY; - final TLBtoECOREtoCODE gener = new TLBtoECOREtoCODE("com.sourceforge.jacobGenerated", - selectedFile.getLocation().toFile().getAbsolutePath(), - output); - gener.generate(); - selectedFile.getProject().getFolder(TestGenerator.MODEL).refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (RuntimeException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final FileNotFoundException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final IOException e) { - System.out.flush(); - e.printStackTrace(); - } catch (CoreException e) { - System.out.flush(); - e.printStackTrace(); - } - System.out.println("Done"); - - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { -// TreeSelection treeSelection= (TreeSelection)selection; - StructuredSelection ss = (StructuredSelection) selection; - Object firstElement2 = ss.getFirstElement(); - selectedFile = (File) firstElement2; - } - -} diff --git a/JacobGeneratorEngine/templates/Header.javajetinc b/JacobGeneratorEngine/templates/Header.javajetinc deleted file mode 100644 index 54b582a..0000000 --- a/JacobGeneratorEngine/templates/Header.javajetinc +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This file is auto generated. DO NOT ALTER IT!!! - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ diff --git a/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc b/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc deleted file mode 100644 index 6ff7ec4..0000000 --- a/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,66 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//basicGetGenFeature.TODO.override.javajetinc - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.get(dispatchComponent, funcName); - <% - String className = genFeature.getImportedType(genClass); - if (className.lastIndexOf('.')>0){ - className = className.substring(className.lastIndexOf('.')+1); - } - final org.eclipse.emf.ecore.EClass classifier; - if (genPackage.getEcorePackage().getName().equals("jacobimpl")) - classifier = (org.eclipse.emf.ecore.EClass) genPackage.getEcorePackage().getESuperPackage().getEClassifier(className); - else - classifier = (org.eclipse.emf.ecore.EClass) genPackage.getEcorePackage().getEClassifier(className); - - if ( null == classifier ) { - %> - //there is no class name here <%= className %> - return retInvoke.toJavaObject(); - <% } else if ( classifier.isInterface()) { - String classType = null; - classType = genFeature.getType().trim(); - final int lastIndexOf = classType.lastIndexOf('.'); - classType = classType.substring(0, lastIndexOf) + ".jacobimpl" + classType.substring(lastIndexOf); - %> - //is an interface <%= genFeature.getImportedType(genClass) %> - final <%= classType %> retVal = new <%= classType %>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } else { %> - //is a class - final <%=genFeature.getType().trim()%> retVal = new <%=genFeature.getType().trim()%>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } %> - - diff --git a/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc b/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc deleted file mode 100644 index 750a3b0..0000000 --- a/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,70 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - - -//getGenFeature.TODO.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.get(dispatchComponent, funcName); - -<%@ include file="returnTypes.javajetinc" %> -<% - final String returnType = genFeature.getType().trim(); - final String func = map.get(returnType); - - if ("void".equals(returnType) ){ - } else if (null != func) { - stringBuffer.append("\n\t\treturn retInvoke"); - stringBuffer.append(func); - stringBuffer.append(";"); - } else if ("com.jacob.com.Variant".equals(returnType) ) { - stringBuffer.append("\n\t\treturn retInvoke;"); - } else if (genFeature.isEnumType()) { - stringBuffer.append("\n\t\tfinal int int1 = retInvoke.getInt();"); - stringBuffer.append("\n\t\treturn " + returnType + ".get(int1);"); - - } else { - stringBuffer.append("\n\t\treturn ("); - stringBuffer.append(returnType); - stringBuffer.append(")retInvoke."); - stringBuffer.append("toJavaObject();"); - } - stringBuffer.append("\n"); -%> diff --git a/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc b/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc deleted file mode 100644 index 0407d08..0000000 --- a/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc +++ /dev/null @@ -1,140 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//implementedGenOperation.todo.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - -<% -final int wFlags; -String funcName = genOperation.getName().trim(); - if (funcName.startsWith("get")){ - funcName = funcName.substring(3); - wFlags = 2 ;/*com.jacob.com.Dispatch.Get;*/ - } else { - wFlags = 1 ;/*com.jacob.com.Dispatch.Method;*/ - } -%> -final int wFlags = <%= wFlags %>; - - - String funcName = "<% -if (funcName.startsWith("JACOB")) - stringBuffer.append(funcName.substring("JACOB".length())); -else - stringBuffer.append(funcName); -%>"; - - -<%@ include file="returnTypes.javajetinc" %> -<% -{ - final org.eclipse.emf.codegen.ecore.genmodel.GenOperation i = genOperation; - final org.eclipse.emf.common.util.EList genParameters = i.getGenParameters(); - - if (0 == genParameters.size()){ - stringBuffer.append("final com.jacob.com.Variant o[] = new com.jacob.com.Variant[0];"); - stringBuffer.append("final int uArgErr[] = new int[0];"); - } else { - stringBuffer.append("final int uArgErr[] = new int["+genParameters.size()+"];"); - stringBuffer.append("final com.jacob.com.Variant o[] = new com.jacob.com.Variant[]{"); - for (int j = 0; j < genParameters.size(); j++) { - final GenParameter genParameter = genParameters.get(j); - if (j !=0) - stringBuffer.append(" ,"); - if (genParameter.getType().trim().equals("com.jacob.com.Variant")){ - stringBuffer.append(genParameter.getName()); - }else { - stringBuffer.append(" new com.jacob.com.Variant("); - stringBuffer.append(genParameter.getName()); - stringBuffer.append(")"); - } - } - stringBuffer.append("};"); - } - stringBuffer.append("\n"); -} - final String returnType = genOperation.getType().trim(); - - final String func = map.get(returnType); -%> - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.invoke(dispatchComponent, funcName, wFlags, o, uArgErr); - - <% - String className = returnType; - if (className.lastIndexOf('.')>0){ - className = className.substring(className.lastIndexOf('.')+1); - } - final org.eclipse.emf.ecore.EClass classifier; - if (genPackage.getEcorePackage().getName().equals("jacobimpl")){ - org.eclipse.emf.ecore.EClassifier classifier2 = null; - classifier2 = genPackage.getEcorePackage().getESuperPackage().getEClassifier(className); - if (classifier2 instanceof org.eclipse.emf.ecore.EClass ) - classifier = (org.eclipse.emf.ecore.EClass) classifier2; - else - classifier=null; - }else{ - org.eclipse.emf.ecore.EClassifier classifier2 = null; - classifier2 = genPackage.getEcorePackage().getEClassifier(className); - if (classifier2 instanceof org.eclipse.emf.ecore.EClass ) - classifier = (org.eclipse.emf.ecore.EClass) classifier2; - else - classifier=null; - } - - if (returnType.equals("void") ) { - } else if ( null == classifier) { - if ( null == func ) { - if (genOperation.isEnumType()) { - stringBuffer.append("\n\t\tfinal int int1 = retInvoke.getInt();"); - stringBuffer.append("\n\t\treturn " + genOperation.getType().trim() + ".get(int1);"); - } else { %> - //there is no class name here <%= className %> in implementedGenOperation - return retInvoke<%= func %>; - <% } - } else { %> - return retInvoke<%= func %>; - <% } - } else if ( classifier.isInterface()) { - String classType = null; - classType = genOperation.getType().trim(); - final int lastIndexOf = classType.lastIndexOf('.'); - classType = classType.substring(0, lastIndexOf) + ".jacobimpl" + classType.substring(lastIndexOf); - %> - //is an interface <%= genOperation.getImportedType(genClass) %> - final <%= classType %> retVal = new <%= classType %>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } else { %> - //is a class - final <%=genOperation.getType().trim()%> retVal = new <%=genOperation.getType().trim()%>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } %> - diff --git a/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc b/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc deleted file mode 100644 index beef3a4..0000000 --- a/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc +++ /dev/null @@ -1,20 +0,0 @@ -<% - final HashMap map = new HashMap(); - map.put("java.util.Date", ".getJavaDate()"); - map.put("java.lang.String", ".getString()"); - map.put("boolean", ".getBoolean()"); - map.put("int", ".getInt()"); - map.put("java.lang.Float", ".getFloat()"); - map.put("float", ".getFloat()"); - map.put("double", ".getDouble()"); - map.put("java.lang.Double", ".getDouble()"); - map.put("com.jacob.com.Dispatch", ".getDispatch()"); - map.put("Dispatch", ".getDispatch()"); - map.put("Variant", ".toVariant()"); - map.put("com.jacob.com.Variant", ".toVariant()"); - map.put("Object", ".toJavaObject()"); - map.put("java.lang.Object", ".toJavaObject()"); - map.put("Date", ".toJavaDate()"); - map.put("java.util.Date", ".toJavaDate()"); -%> - diff --git a/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc b/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc deleted file mode 100644 index 1731a3c..0000000 --- a/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,49 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//setGenFeature.TODO.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); -<% if (genFeature.isEnumType()) { - stringBuffer.append("\n\t\tfinal Object o = new" + genFeature.getName().trim() + ".getValue();"); - } else { - stringBuffer.append("\n\t\tfinal Object o = new" + genFeature.getName().trim() + ";"); - } -%> - com.jacob.com.Dispatch.put(dispatchComponent, funcName, o); diff --git a/JacobGeneratorEngine/text/description.txt b/JacobGeneratorEngine/text/description.txt deleted file mode 100644 index 2b529e7..0000000 --- a/JacobGeneratorEngine/text/description.txt +++ /dev/null @@ -1,8 +0,0 @@ -Model Company - -This model description is not a real EMF artifact. It was generated by the -org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's -code generator can be extended. -This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. - -Package com diff --git a/TestHarness/.classpath b/TestHarness/.classpath deleted file mode 100644 index 9eec048..0000000 --- a/TestHarness/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/TestHarness/.project b/TestHarness/.project deleted file mode 100644 index ee99457..0000000 --- a/TestHarness/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - TestHarness - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/TestHarness/build.properties b/TestHarness/build.properties deleted file mode 100644 index 66d9c2d..0000000 --- a/TestHarness/build.properties +++ /dev/null @@ -1,14 +0,0 @@ - -# -# -# -# $Id$ - -bin.includes = .,\ - model/,\ - META-INF/,\ - plugin.xml,\ - plugin.properties -jars.compile.order = . -source.. = src/ -output.. = bin/ diff --git a/TestHarness/build.xml b/TestHarness/build.xml deleted file mode 100644 index 519685f..0000000 --- a/TestHarness/build.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - description - - - - - - - - - - - - - - - - - - diff --git a/TestHarness/src/TestExcel11.java b/TestHarness/src/TestExcel11.java deleted file mode 100644 index 8234e5c..0000000 --- a/TestHarness/src/TestExcel11.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -import junit.framework.TestCase; - -import com.Excel.Application; -import com.Excel.Range; -import com.Excel.Workbook; -import com.Excel.Workbooks; -import com.Excel.Worksheet; -import com.Excel.XlWindowState; -import com.Excel.XlXmlImportResult; -import com.jacob.activeX.ActiveXComponent; -import com.jacob.com.Dispatch; -import com.jacob.com.Variant; -import com.sun.java.swing.plaf.windows.resources.windows; - -public class TestExcel11 extends TestCase { - private ActiveXComponent activeXcomponent; - private Application excelApp; - private Workbook workbook; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - activeXcomponent = new ActiveXComponent("Excel.Application"); - excelApp = new Application(); - excelApp.setDispatch(activeXcomponent); - } - - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (workbook != null){ - workbook.Close(Variant.VT_FALSE, Variant.VT_MISSING, Variant.VT_MISSING); - workbook = null; - } - excelApp.Quit(); - activeXcomponent.safeRelease(); - } - - - public void testLoad() { - excelApp.setVisible(true); - assertEquals("11.0", excelApp.getVersion()); - } - - public void testWorkbook() throws Exception { - testLoad(); - final Workbooks workbooks = excelApp.getWorkbooks(); - workbook = workbooks.Add(Variant.VT_MISSING); - } - - public void testWorksheet() throws Exception { - testWorkbook(); - final Worksheet sheet = new Worksheet(); - final Variant activeSheet = new Variant( workbook.getActiveSheet()); - sheet.setDispatch(activeSheet.toDispatch()); - final Range range_A1 = (Range) sheet.getRange(new Variant("a1"),new Variant("a1")); - range_A1.setValue(new Variant("123.456")); - final Range range_A2 = (Range) sheet.getRange(new Variant("a2"),new Variant("a2")); - range_A2.setFormula(new Variant("=A1*2")); - assertEquals(123.456, range_A1.getValue().getDouble()); - assertEquals(246.912, range_A2.getValue().getDouble()); - } - - public void testWindowState() throws Exception { - testWorkbook(); - final Worksheet sheet = new Worksheet(); - final Variant activeSheet = new Variant( workbook.getActiveSheet()); - sheet.setDispatch(activeSheet.toDispatch()); - - XlWindowState windowState ; - - excelApp.getActiveWindow().setWindowState(XlWindowState.XL_NORMAL); - windowState = excelApp.getActiveWindow().getWindowState(); - assertEquals(XlWindowState.XL_NORMAL, windowState); - - excelApp.getActiveWindow().setWindowState(XlWindowState.XL_MAXIMIZED); - windowState = excelApp.getActiveWindow().getWindowState(); - assertEquals(XlWindowState.XL_MAXIMIZED, windowState); - - } - -} diff --git a/TestHarness/src/TestWord11.java b/TestHarness/src/TestWord11.java deleted file mode 100644 index 61cce66..0000000 --- a/TestHarness/src/TestWord11.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -import junit.framework.TestCase; - -import com.Word.Application; -import com.Word.Document; -import com.Word.Documents; -import com.Word.Selection; -import com.jacob.activeX.ActiveXComponent; -import com.jacob.com.Variant; - -public class TestWord11 extends TestCase { - private ActiveXComponent activeXcomponent; - private Application wordApp; - private Document document; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - activeXcomponent = new ActiveXComponent("Word.Application"); - wordApp = new Application(); - wordApp.setDispatch(activeXcomponent); - } - - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (document != null){ - document.Close(new Variant(false), null, null); - document = null; - } - wordApp.Quit(); - activeXcomponent.safeRelease(); - } - - - public void testLoad() { - wordApp.setVisible(true); - assertEquals("11.0", wordApp.getVersion()); - } - - public void testNewDocument() { - testLoad(); - wordApp.Activate(); - - Documents documents = wordApp.getDocuments(); - - Document add = documents.Add(Variant.VT_MISSING, Variant.VT_MISSING, Variant.VT_MISSING, Variant.VT_MISSING); - add.Activate(); - Selection selection = wordApp.getSelection(); - selection.TypeText("This is a simple test"); - selection.TypeParagraph(); - selection.TypeParagraph(); - selection.TypeParagraph(); - selection.TypeParagraph(); - selection.TypeText("This is a simple test"); - selection.TypeParagraph(); - selection.TypeParagraph(); - selection.TypeParagraph(); - - add.PrintPreview(); - add.ClosePrintPreview(); - add.Close(Variant.VT_FALSE, Variant.VT_MISSING, Variant.VT_MISSING); - } - -} diff --git a/TestHarness/text/description.txt b/TestHarness/text/description.txt deleted file mode 100644 index 2b529e7..0000000 --- a/TestHarness/text/description.txt +++ /dev/null @@ -1,8 +0,0 @@ -Model Company - -This model description is not a real EMF artifact. It was generated by the -org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's -code generator can be extended. -This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. - -Package com diff --git a/jacobgen/.cvsignore b/jacobgen/.cvsignore deleted file mode 100644 index ebf9efe..0000000 --- a/jacobgen/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -jacob.dll -jacob.jar -jacobdll.jar -*.zip -RELEASE.txt -.project -.classpath -compilation_tools.properties -version.properties -release -.externalToolBuilders -.cdtproject - diff --git a/jacobgen/LICENSE.txt b/jacobgen/LICENSE.txt deleted file mode 100644 index b6f92f3..0000000 --- a/jacobgen/LICENSE.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/jacobgen/README.txt b/jacobgen/README.txt deleted file mode 100644 index 20181c5..0000000 --- a/jacobgen/README.txt +++ /dev/null @@ -1,29 +0,0 @@ -======================================================= -Jacobgen basic readme.txt -Most documentation is being moved to the docs directory -======================================================= - -Description ------------ -Jacobgen generates java class wrappers microsoft DLLs -that make them callable from java programs. The class -are built on top of the Jacob (Java-COM Bridge) project. -This library is ONLY useful if you are running Jacob. - -Running Jacobgen ----------------- -See docs/run_jacobgen.bat for an example script that -runs jacobgen - -ReleaseNotes and Technical Issues ---------------------------------- -see docs/ReleaseNotes.html - -Credits -------- -see docs/credits.txt - -History -------- -See docs/ReleaseNotes.html - \ No newline at end of file diff --git a/jacobgen/build.xml b/jacobgen/build.xml deleted file mode 100644 index 38bb265..0000000 --- a/jacobgen/build.xml +++ /dev/null @@ -1,488 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Building Jacob classes in ${release.dir.java} - - Building sample classes in ${release.dir.java} - - Building Jacob test classes in ${release.dir.java} using junit jar ${junit.jar} - - - - - - Removing old jars - - Packaging java classes... - Version File is ${release.dir.java.meta.inf}/${generated.filename.version} - - - - - - - - - - - -
- - - - -
-
-
-
- - - Clean up the (x86) target folders and file, for safety - - Compiling (x86) C++ classes with JDK JNI library ${JDK} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Clean up the (AMD64) target folders and file, for safety - - Compiling C++ (AMD64) classes with JDK JNI library ${JDK} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Clean up the target folders and file, for safety - Using ${library.x86} - - Creating ${release.file.x86.dll} - - - - - - - - - - - - - - - - - - - - - - - - Clean up the target folders and file, for safety - - Creating {$release.file.AMD64.dll} - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${application.title}]]> - ${application.vendor}]]> - - - - - - - - - - - Packaging release... ${release.file.jar} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- diff --git a/jacobgen/docs/HowToBuild.txt b/jacobgen/docs/HowToBuild.txt deleted file mode 100644 index 6cdf963..0000000 --- a/jacobgen/docs/HowToBuild.txt +++ /dev/null @@ -1,48 +0,0 @@ -To build and run: - -Unpack the source archive or check the files out of CVS into d:\jacobgen - -Install the following tools - Microsoft Visual Studio, a stripped down version is available from the MS web site. - Eclipse from www.eclipse.org. - Java jdk 1.5 (this was built using 1.4.2.09) - -The following configuration was used by most of the development team: - JDK=d:\\jdk1.5.0_11 - MSDEV_DIR=d:\\apps\\Microsoft Visual Studio 8\\VC - MSDEV_IDE_DIR=d:\\apps\\Microsoft Visual Studio 8\\Common7\\IDE - -This project has been converted completely over to ANT. You can -run ANT from inside of eclipse or from the command line. -The ant process is driven off of a configuration file -compilation_tools.properties. Instructions on the information required -in that file are contained in build.xml in the root directory. - -Ant, via build.xml will do the following with teh default target. - Build the Java code - Build the jni code - create the dll - create jar file - -The package target creates the - javadoc and - zip files - -ECLIPSE - -Eclipse users will have to do some minor tweaks to their project if they -want to use the integrated build process. This is because the unit -tests are files located in the "unittest" directory while -the project source files themselves are in "src" the root directory. - Eclipse automatically adds the whole project as a source directory - Remove the root of the project from the build path - Add folders samples, src and unittest to the build path - Exclude *.txt from each of the newly added folders. - -The Servlet examples that required j2ee libraries to compile have temporarily -been removed. - -The java code is in .\src -The C++ code is in .\jni. - -Last Modified 11/2007 diff --git a/jacobgen/docs/ReleaseNotes.html b/jacobgen/docs/ReleaseNotes.html deleted file mode 100644 index cd90491..0000000 --- a/jacobgen/docs/ReleaseNotes.html +++ /dev/null @@ -1,121 +0,0 @@ - - -Jacobgen Release Notes - - -This document descibes the known changes made to Jacobgen across releases. -(Dates in this document are in the format yy/mm/dd) - -

Version 0.10 08/02/02)

-
    -
  • BUG-FIX: 1885990 setMethods missing passed in paramenters in generated code.
  • -
- -

Version 0.9 (08/01/25)

-
    -
  • BUG-FIX: 1880909 Methods returning java.util.Date should call - Variant.getJavaDate() instead of Variant.getDate() -
- -

Version 0.8 (07/11/20)

-
    -
  • PROJECT: Now built with Visual Studio 8 and Java 5. -
  • PATCHES: (SF1650138) Numerous changes including VariantVariant and GUID support. - This is not complete but appears to do no damage. -
  • UPGRADE: (SF151405) Jacobgen causes R6002 - floating point not loaded
  • -
  • UPGRADE: (SF1651565) Support searching for typelibfile relative path
  • -
- -

Version 0.7 (06/04/28)

-
    -
  • BUG-FIX: 1460974 Replaced samskivert.jar with viztool.jar for jdk1.5 compatibility. -
  • BUT-FIX: 1478303 Fixed jacobgen to now generate compilable Date related code. -
- -

Version 0.6 (05/12/07)

-
    -
  • BUG-FIX: changed code generator for in/out parameters toVariant() and putVariantRef() -
- -

Version 0.5 (05/10/14)

-
    -
  • PROJECT: source code moved to jacob-project on sourceforge -
  • PROJECT: converted from makefile to ant -
  • PROJECT: compiles on XP -
- -

Version 0.4 (04/03/02)

-
    -
  • UPGRADE: support for middle argument list optional parameters (with Variant.noParam()) -
  • UPGRADE: support for out-parameters (thanks to Hannes Reisinger) -
  • UPGRADE: MSMQ 2.0 support. Almost. -
  • UPGRADE: now you can check tlbs using TypeLibInspector.main(), see testJacobgendll.bat -
  • BUG-FIX: corrected class attributes (only for VAR_CONST) -
  • BUG-FIX: corrected return code for SafeArray type (thanks to Bill Kelemen) -
  • UPGRADE: added AliasGenerator to create TKIND_ALIAS classes (reported by Richard Range) -
  • UPGRADE: alias of enums support -
- -

Version 0.3 (04/01/02)

-
    -
  • BUG-FIX: change to Dispatch.call() to support more than 8 method parameters -
  • UPGRADE: COM Date support (thanks to rev) -
  • UPGRADE: CLASSPATH searching for type referenced outside the component. - Warning: classes searching is based on class name. If different jars or - packgages contains the same class the result is unknown. -
  • BUG-FIX: better Enum identification. Now works with Excel8 -
  • BUG-FIX: Excel8 caused VM crash due to buffer size limitations -
  • BUG-FIX: the generator didn't produce last class in TLB file (thanks to Liz Heine) -
-

Version 0.2

-

Version 0.1

- -(**) Dates are in italian format (dd/mm/yy) - -
-

Known Issues

-
    -
  • The wrapper classes will require a little hand tweaking - in most situations to get them to compile. -
  • Some methods will be generated more than once if they are - detected in a "class" more than once. -
  • This will generate the wrappers for most of a DLL but - will sometimes run into problems with unrecognized types. - A good example is MSWord. It will generate a lot of classes - but will have problems with some so the wrappers will have - to be hand tweaked in roder to work. -
  • EVENTS and STRUCTURES. Not supported -
  • VT_PTR type is not well supported -
- - -

Features

-
    -
  • TLB/OLB/DLL inspection via native code -
  • IN/OUT/OPTIONAL parameters support -
- -
    -
  • Office8/Excel8/Word8 wrapper generation -
  • MSMQ 2.0 wrapper generation (Almost) -
  • Lotus Domino wrapper generation (Almost) -
- - -

Data Mapping Notes

-
    -
  • SafeArray by reference are passed as arrays -
  • MsoRGBType mapped to int -
  • Enum types mapped to int -
- - - -

Application LIMITATIONS

-
    -
  • Acrobat Reader. Jacobgen is unable to parse Acrobat Reader OCX. I'm still investigating - this issue. By now you need to wrap it inside an another COM component. -
- - - \ No newline at end of file diff --git a/jacobgen/docs/credits.txt b/jacobgen/docs/credits.txt deleted file mode 100644 index c7cc577..0000000 --- a/jacobgen/docs/credits.txt +++ /dev/null @@ -1,6 +0,0 @@ -This is the brainchild of Massimiliano Bigatti. All original work copyright -Massimiliano Bigatti and licensed under LGPL by Massimiliano Bigatti - -+ Jacobgen out parameters are contrib of Hannes Reisinger -+ Jacobgen now depends on Sam Skivert library and viztool (only some classes are - provided with Jacobgen - license is GPL and LGPL) diff --git a/jacobgen/docs/run_jacobgen.bat b/jacobgen/docs/run_jacobgen.bat deleted file mode 100644 index 03adec3..0000000 --- a/jacobgen/docs/run_jacobgen.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -cls - -REM run this from the root directory of the Jacobgen project -REM it will spit out the interface classes for a dll you pass in as a parameter -REM sample command line while sitting in the JACOBGEN project directory -REM -REM The following command built a sample in the jacob directory I have -REM installed near my jacobgen project directory. -REM $ docs/run_jacobgen.bat -destdir:"..\jacob\samples" -listfile:"jacobgenlog.txt" -package:com.jacobgen.microsoft.msword "C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB" -REM -REM -set JAVA_HOME=D:\jdk1.5.0_11 -set JRE=%JAVA_HOME%\bin\java - -set JACOBGEN_HOME=. -set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\dt.jar;%JACOBGEN_HOME%\release\java\jacobgen.jar;%JACOBGEN_HOME%\lib\viztool.jar -REM put the dll in the path where we can find it -set PATH=%PATH%;%JACOBGEN_HOME%\release\x86 - -rem echo %CLASSPATH% - -%JRE% -Xint com.jacob.jacobgen.Jacobgen %1 %2 %3 %4 %5 -pause diff --git a/jacobgen/docs/todo.txt b/jacobgen/docs/todo.txt deleted file mode 100644 index ce460e2..0000000 --- a/jacobgen/docs/todo.txt +++ /dev/null @@ -1,5 +0,0 @@ -Upgrade javadoc comments generation -Events -Structures -Better Array support -VT_PTR support diff --git a/jacobgen/jni/TypeLibInspector.cpp b/jacobgen/jni/TypeLibInspector.cpp deleted file mode 100644 index f4d6f8d..0000000 --- a/jacobgen/jni/TypeLibInspector.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/* - * Jacobgen.cpp - * Copyright (C) 2000 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -#include -#include -#include -#include -// W2A conversion for converting BSTR to LPCTSTR -#include -#include -#include "TypeLibInspector.h" - -extern "C" -{ -LPTSTR buffer; -LPTSTR current_position; -// SF 1515405 added floting point reference to force load of floting point library -// the append2 down below uses floating point but the compiler doesn't recognize that -float f=1.0f; - - -/** - * Java_com_jacob_jacobgen_TypeLibInspector_queryInterface - * - * Main Java function - */ -JNIEXPORT jbyteArray JNICALL Java_com_jacob_jacobgen_TypeLibInspector_queryInterface -(JNIEnv *env, jobject jobj, jstring name) { - - jbyteArray jb; - jboolean iscopy; - LPWSTR wname; - LPCSTR sname; - - buffer = NULL; - // could we just get the unicode characters to bein with? - sname = env->GetStringUTFChars( name, &iscopy ); - - const int size = MultiByteToWideChar(CP_ACP, 0, sname, -1, NULL, 0); - wname = (LPWSTR) malloc(sizeof(WCHAR)*size); - - memset(wname, 0, sizeof(WCHAR)*size); - - MultiByteToWideChar(CP_ACP, 0, sname, -1, wname, size); - - printf("converted %s to %ls\n",sname,wname); - - CoInitialize( 0 ); - printf("calling ExtractTypeLib with %ls\n",wname); - ExtractTypeLib( wname ); - CoUninitialize(); - - if( buffer == NULL ) { - buffer = (char * )malloc( 1 ); - if( buffer != NULL ){ - *buffer = '\0'; - } - } - - //Construct return Java byte array - size_t dim = strlen( buffer ); - jb = env->NewByteArray( dim ); - env->SetByteArrayRegion( jb, 0, dim, (jbyte *)buffer ); - - fflush(stdout); - fflush(stderr); - - return jb; -} -/** - * ExtractTypeLib - * - * Extract type lib information from specified file. It produces - * formatted output that the Generator is able to convert in source - * java files. - * - */ -void ExtractTypeLib( LPWSTR pszFileName ) -{ - LPTYPELIB pITypeLib; - - printf("Starting: Extract of library %ls\n", pszFileName); - buffer = (LPTSTR )malloc( BUF_SIZE ); - if( buffer == NULL ) - { - _tprintf( _T("Jacobgen: unable to allocate temporary buffer\n") ); - return; - } - current_position = buffer; - HRESULT hr = LoadTypeLib( pszFileName, &pITypeLib ); - if ( S_OK != hr ) - { - append1( "ERROR: LoadTypeLib failed" ); - return; - } - - EnumTypeLib( pITypeLib ); - pITypeLib->Release(); - printf("Finished: Extract of library %ls\n", pszFileName); -} - -void EnumTypeLib( LPTYPELIB pITypeLib ) -{ - UINT tiCount = pITypeLib->GetTypeInfoCount(); - //printf("Starting: enumerating %d\n",tiCount); - //Extract Type lib name - BSTR pLibName; - pITypeLib->GetDocumentation(-1, &pLibName, NULL, 0, NULL ); - append2b("TYPELIB %ls\n", pLibName ); - - //hr = ptlib->GetDocumentation(-1, &pTypeLibrary->m_bstrName, &pTypeLibrary->m_bstrDocumentation, - // &pTypeLibrary->m_ulHelpContext, &pTypeLibrary->m_bstrHelpFile); - - for ( UINT i = 0; i < tiCount; i++ ) - { - LPTYPEINFO pITypeInfo; - HRESULT hr = pITypeLib->GetTypeInfo( i, &pITypeInfo ); - if ( S_OK == hr ) - { - ExtractTypeInfo( pITypeInfo ); - pITypeInfo->Release(); - } - } - //printf("Finished: enumerating %d\n",tiCount); -} - -void ExtractTypeInfo( LPTYPEINFO pITypeInfo ) -{ - //printf("Starting: ExtractTypeInfo\n"); - HRESULT hr; - - BSTR theGuid = SysAllocString(L"{00000000-0000-0000-0000-000000000000}"); - - BSTR pszTypeInfoName; - hr = pITypeInfo->GetDocumentation(MEMBERID_NIL, &pszTypeInfoName, 0, 0, 0); - if ( S_OK != hr ) - return; - printf("retrieved documentation %ls\n",pszTypeInfoName); - TYPEATTR * pTypeAttr; - hr = pITypeInfo->GetTypeAttr( &pTypeAttr ); - if ( S_OK != hr ) - { - printf("failed to get attribute!!!!!!!\n"); - SysFreeString( pszTypeInfoName ); - SysFreeString( theGuid ); - - return; - } - - //append3("CLASS %ls;%ls\n", pszTypeInfoName, - append3("CLASS %ls;%s\n", pszTypeInfoName, - GetTypeKindName(pTypeAttr->typekind) ); - - StringFromGUID2(pTypeAttr->guid, theGuid, 39); - append2b("GUID;%ls",theGuid ); - append1("\n"); - - if( pTypeAttr->typekind == TKIND_ALIAS ) { - TYPEDESC tdesc; - tdesc = pTypeAttr->tdescAlias; - - if( tdesc.vt == VT_PTR ) { - tdesc = *tdesc.lptdesc; - } - - if( tdesc.vt == VT_USERDEFINED ) { - BSTR pszRefFuncName = GetUserDefinedType( pITypeInfo, tdesc ); - if( pszRefFuncName ) { - append2b("EXTENDS;%ls\n",pszRefFuncName ); - SysFreeString( pszRefFuncName ); - } - } else { - append2("%EXTENDS;%ls\n",GetVarTypeName( tdesc.vt ) ); - } - } else { - EnumTypeInfoMembers( pITypeInfo, pTypeAttr ); - } - - SysFreeString( pszTypeInfoName ); - SysFreeString( theGuid ); - - pITypeInfo->ReleaseTypeAttr( pTypeAttr ); - //printf("Finished: ExtractTypeInfo\n"); -} - -void EnumTypeInfoMembers( LPTYPEINFO pITypeInfo, LPTYPEATTR pTypeAttr ) -{ - FUNCDESC * pFuncDesc; - BSTR pszFuncName; - ELEMDESC elemdesc; - TYPEDESC tdesc; - - //printf("Started: EnumTypeInfoMembers\n"); - if ( pTypeAttr->cImplTypes ) { - //printf(" : cImplTypes\n"); - for ( unsigned i = 0; i < pTypeAttr->cImplTypes; i++ ) { - - LPTYPEINFO pImplInfo; - HREFTYPE hRefType; - - pITypeInfo->GetRefTypeOfImplType( i, &hRefType ); - pITypeInfo->GetRefTypeInfo( hRefType, &pImplInfo ); - - if( pImplInfo != NULL ) { - pImplInfo->GetDocumentation(MEMBERID_NIL, &pszFuncName,0,0,0); - append2b("EXTENDS;%ls",pszFuncName ); - } - append1("\n"); - SysFreeString( pszFuncName ); - } - } - - if ( pTypeAttr->cFuncs ) { - //printf(" : cFuncs\n"); - for ( unsigned i = 0; i < pTypeAttr->cFuncs; i++ ) { - - pITypeInfo->GetFuncDesc( i, &pFuncDesc ); - pITypeInfo->GetDocumentation(pFuncDesc->memid, &pszFuncName,0,0,0); - - append2("%ls;", GetInvokeKindName(pFuncDesc->invkind) ); - - elemdesc = pFuncDesc->elemdescFunc; - //PARAMDESC pdesc; //PENDING - //pdesc = elemdesc.paramdesc; - tdesc = elemdesc.tdesc; - - //If type type is pointer, dereference - if( tdesc.vt == VT_PTR ) { - tdesc = *tdesc.lptdesc; - } - - //Check for user defined types - //append2("%ls",GetVarTypeName( tdesc.vt ) ); - if( tdesc.vt == VT_USERDEFINED ) { - //append1( "^" ); - BSTR pszRefFuncName = GetUserDefinedType( pITypeInfo, tdesc ); - if( pszRefFuncName ) { - append2b("%ls",pszRefFuncName ); - SysFreeString( pszRefFuncName ); - } - } else{ - append2("%ls",GetVarTypeName( tdesc.vt ) ); - } - - append2b(" ;%ls;",pszFuncName ); - - //Extract function parameters - EnumParameters( pITypeInfo, pFuncDesc ); - - pITypeInfo->ReleaseFuncDesc( pFuncDesc ); - SysFreeString( pszFuncName ); - } - } - - if ( pTypeAttr->cVars ) - //printf(" : cVars\n"); - { - - for ( unsigned i = 0; i < pTypeAttr->cVars; i++ ) - { - VARDESC * pVarDesc; - - pITypeInfo->GetVarDesc( i, &pVarDesc ); - - BSTR pszVarName; - pITypeInfo->GetDocumentation(pVarDesc->memid, &pszVarName,0,0,0); - VARIANT *pvarValue = pVarDesc->lpvarValue; - - //_tprintf( _T(" %ls\n"), pszVarName ); - append2("%ls;", GetVarKindName( pVarDesc->varkind ) ); - append2b("%ls;",pszVarName ); - - if( pVarDesc->varkind == VAR_CONST ) { - if(pvarValue!=NULL) - append2("%ls;", GetVarTypeName( pvarValue->vt ) ); - else - append1("UNKNOWN" ); - - LPTSTR s = GetVarDefaultValue( pvarValue ); - append1( s ); - free( (void *)s ); - } else { - if( pVarDesc->varkind == VAR_DISPATCH ) { - - elemdesc = pVarDesc->elemdescVar; - //PARAMDESC pdesc; //PENDING - //pdesc = elemdesc.paramdesc; - tdesc = elemdesc.tdesc; - - //If type type is pointer, dereference - if( tdesc.vt == VT_PTR ) { - tdesc = *tdesc.lptdesc; - } - - //Check for user defined types - //append2("%ls",GetVarTypeName( tdesc.vt ) ); - if( tdesc.vt == VT_USERDEFINED ) { - //append1( "^" ); - BSTR pszRefFuncName = GetUserDefinedType( pITypeInfo, tdesc ); - if( pszRefFuncName ) { - append2b("%ls",pszRefFuncName ); - SysFreeString( pszRefFuncName ); - } - } else { - append2("%ls",GetVarTypeName( tdesc.vt ) ); - } - } - } - - append1("\n"); - - pITypeInfo->ReleaseVarDesc( pVarDesc ); - SysFreeString( pszVarName ); - } - } - //printf("Finished: EnumTypeInfoMembers\n"); - -} - -/** - * For a USERDEFINED typedesc, extract the referred type - */ -BSTR GetUserDefinedType( LPTYPEINFO pITypeInfo, TYPEDESC tdesc ) { - HREFTYPE htype; - LPTYPEINFO ppTInfo = NULL; - HRESULT hr; - BSTR pszRefFuncName = NULL; - - if( tdesc.vt == VT_USERDEFINED ) { - htype = tdesc.hreftype; - - hr = pITypeInfo->GetRefTypeInfo( htype, &ppTInfo ); - if( ppTInfo ) - ppTInfo->GetDocumentation(MEMBERID_NIL, &pszRefFuncName, 0, 0, 0); - } - - return pszRefFuncName; -} - -void EnumParameters( ITypeInfo *pTypeInfo, FUNCDESC *pFuncDesc ) { - TYPEDESC tdesc; - - //printf("Started: EnumParameters \n"); - - unsigned int cMaxNames = pFuncDesc->cParams; - if (cMaxNames > 0) - cMaxNames++; - unsigned int pcNames; - - BSTR rgBstrNames[ 100 ]; - MEMBERID pMemId[ 100 ]; - - pTypeInfo->GetNames( pFuncDesc->memid, rgBstrNames, cMaxNames, &pcNames ); - pTypeInfo->GetIDsOfNames( rgBstrNames, pcNames, pMemId ); - - //printf(" EnumParameters %d, numParams: %d\n",cMaxNames,pcNames); - - append1( "[" ); - if (pcNames > 0) { - - // the 0th position is the name of the function itself - // for INVOKE_FUNC we want to igore this but - // for INVOKE_PROPERTYPUT we'd like to make that the name of the - // parameter that we want to pass in - for ( unsigned k = 0; k < pcNames; k++ ) - { - //if (k == 0){printf(" EnumParameters: Entrypoint defined as %S\n",rgBstrNames[0]);} - BSTR pszParName = NULL; - PARAMDESC pd; - if (k == 0 && pcNames == 1){ - // probably a property put method - pszParName = rgBstrNames[k]; - pd = pFuncDesc->lprgelemdescParam[k].paramdesc; - tdesc = pFuncDesc->lprgelemdescParam[k].tdesc; - } else { - // its probaly an invoke which means we do that offset thing - if (k == 0 && pcNames > 1){ - k++; // start in position one for the parm name - } - pszParName = rgBstrNames[k]; - pd = pFuncDesc->lprgelemdescParam[k-1].paramdesc; - tdesc = pFuncDesc->lprgelemdescParam[k-1].tdesc; - } - //printf(" EnumParameters: %d %S of type %d direction %d\n", - // k,pszParName,tdesc.vt,pd.wParamFlags); - - if( pd.wParamFlags != 0 ) { - append1( "{" ); - - if( pd.wParamFlags & PARAMFLAG_FIN ) - append1( "in-" ); - if( pd.wParamFlags & PARAMFLAG_FOUT ) - append1( "out-" ); - if( pd.wParamFlags & PARAMFLAG_FRETVAL ) - append1("retval-" ); - if( pd.wParamFlags & PARAMFLAG_FOPT ) - append1("optional-" ); - - append1( "}" ); - } - - //printf(" EnumParameters: working on %d b\n",k); - /* - VARTYPE vt = pFuncDesc->lprgelemdescParam[k].tdesc.vt; - if( vt == VT_PTR ) { - TYPEDESC *pPointedAt = pFuncDesc->lprgelemdescParam[k].tdesc.lptdesc; - vt = pPointedAt->vt; - append2( "%ls", GetVarTypeName( vt ) ); - } else if( vt == VT_SAFEARRAY ) { - TYPEDESC *pPointedAt = pFuncDesc->lprgelemdescParam[k].tdesc.lptdesc; - vt = pPointedAt->vt; - append2( "SAFEARRAY(%ls)", GetVarTypeName( vt ) ); - } else { - append2( "%ls", GetVarTypeName( vt ) ); - } - */ - - - - //printf(" EnumParameters: working on %d c\n",k); - bool isPointer = false; - VARTYPE vt = NULL; - //If type type is pointer, dereference - if( tdesc.vt == VT_PTR ) { - //printf(" EnumParameters: working on %d type: %d c1 \n",k,tdesc.vt); - isPointer = true; - // reset tdesc to be the thing that was pointed at - tdesc = *tdesc.lptdesc; - //printf(" EnumParameters: working on %d type: %d c2 \n",k,tdesc.vt); - - // SF1650138 added 11/2007 but crashes VM - // if tdesc is VT_USER_DEFINED - //TYPEDESC *pPointedAt = tdesc.lptdesc; - //if (pPointedAt) { - // printf(" EnumParameters: working on %d %d c3 \n",k, pPointedAt->vt); - // vt = pPointedAt->vt; - //} - } - //printf(" EnumParameters: working on %d d\n",k); - if (vt) { - // this was added for SF1650138 but doesn't do anything - // because the code that sets it is commented out - //printf(" EnumParameters: working on %d d1\n",k); - append2( "%ls", GetVarTypeName( vt ) ); - } else { - //printf(" EnumParameters: working on %d d2\n",k); - //Check for user defined types - if( tdesc.vt == VT_USERDEFINED ) { - //printf(" EnumParameters: working on %d d2x\n",k); - BSTR pszRefFuncName = GetUserDefinedType( pTypeInfo, tdesc ); - if( pszRefFuncName ) { - append2b("%ls",pszRefFuncName ); - SysFreeString( pszRefFuncName ); - } - } else { - // SF1650138 added 11/2007 but tries to use a class we don't have - // this apparently attempts to differentiate between methods - // that take a variant and a VT_Variant but jacob - // doesn't have the VariantVariant class implied by this code - //printf(" EnumParameters: working on %d d2y\n",k); - //if (isPointer && (tdesc.vt == VT_VARIANT)) { - // append1("VariantVariant"); - //} else { - append2("%ls",GetVarTypeName( tdesc.vt ) ); - //} - } - } - - //printf(" EnumParameters: working on %d e\n",k); - append2b( " %ls,", pszParName ); - } - } - append1("]\n" ); - //printf("Finished: EnumParameters\n"); -} - -/** - * Append a char array to destination buffer - */ -void append1( LPTSTR string ) { - LPTSTR s; - - s = string; - while( *s != '\0' ) { //TODO: add bound check - *current_position = *s; - s++; - current_position++; - } - - *current_position = '\0'; -} - -void append2b ( LPTSTR format, BSTR s1){ - append2c(format,s1); -} - -void append2c ( LPTSTR format, LPCWSTR s1){ - LPTSTR s; - //printf("append2c: '%s' %ls -- ",format, s1); - size_t dim = (wcslen( s1 )+ strlen(format)+1) * 2; - //printf("allocating %d -- ", dim); - //size_t dim = _tcslen( s1 ) * sizeof(_TCHAR) * 2; - - if( (dim > 0) ) { - s = (LPTSTR )malloc( dim ); - if( s != NULL ) { - *(s + dim - 1) = '\0'; - sprintf( s, format, s1 ); - //printf("generated %s\n", s); - append1( s ); - free( s ); - } - } -} - -/** - * Copy a generic text string to a char array and copies it - * to destination array - */ -void append2( LPTSTR format, LPCTSTR s1 ) { - //printf("append2 %s\n",s1); - USES_CONVERSION; - append2c(format,A2W(s1)); -} - -/** - * Copy two generic text strings to a char array and copies it - * to destination array - */ -void append3( LPTSTR format, BSTR s1, LPCTSTR s2 ) { - LPCWSTR wideS2; - LPTSTR s; - USES_CONVERSION; - wideS2 = A2W(s2); - int formatLength = strlen(format); - int width1 = wcslen(s1); - int width2 = wcslen(wideS2); - size_t dim = ( formatLength+ width1 + width2 +1 ) * 2; - //size_t dim = ( _tcslen( s1 ) + _tcslen( wideS2 ) ) * sizeof(_TCHAR) * 2; - - if( width1 > 0 && width2 > 0 ) { - s = (LPTSTR )malloc( dim ); - if( s != NULL ) { - *(s + dim - 1) = '\0'; - sprintf( s, format, s1, s2 ); - append1( s ); - free( s ); - } - } -} - - -#define CASE_STRING( x ) case x: s = _T(#x); break; - -LPCTSTR GetTypeKindName( TYPEKIND typekind ) -{ - LPTSTR s = _T(""); - - switch( typekind ) - { - CASE_STRING( TKIND_ENUM ) - CASE_STRING( TKIND_RECORD ) - CASE_STRING( TKIND_MODULE ) - CASE_STRING( TKIND_INTERFACE ) - CASE_STRING( TKIND_DISPATCH ) - CASE_STRING( TKIND_COCLASS ) - CASE_STRING( TKIND_ALIAS ) - CASE_STRING( TKIND_UNION ) - } - printf("found type %s\n",s); - - return s; -} - -LPCTSTR GetInvokeKindName( INVOKEKIND invkind ) -{ - LPTSTR s = _T(""); - - switch( invkind ) - { - CASE_STRING( INVOKE_FUNC ) - CASE_STRING( INVOKE_PROPERTYGET ) - CASE_STRING( INVOKE_PROPERTYPUT ) - CASE_STRING( INVOKE_PROPERTYPUTREF ) - } - //printf("found invoke %s\n",s); - return s; -} - -LPCTSTR GetVarTypeName( VARTYPE vt ) -{ - LPTSTR s = _T(""); - //LPTSTR s = _T(""); - - switch( vt ) - { - CASE_STRING( VT_EMPTY ) - CASE_STRING( VT_NULL ) - CASE_STRING( VT_I2 ) - CASE_STRING( VT_I4 ) - CASE_STRING( VT_R4 ) - CASE_STRING( VT_R8 ) - CASE_STRING( VT_CY ) - CASE_STRING( VT_DATE ) - CASE_STRING( VT_BSTR ) - CASE_STRING( VT_DISPATCH ) // IDispatch FAR* - CASE_STRING( VT_ERROR ) // Scodes - CASE_STRING( VT_BOOL ) - CASE_STRING( VT_VARIANT ) - CASE_STRING( VT_UNKNOWN ) // IUnknown FAR* - CASE_STRING( VT_I1 ) // Signed char. - CASE_STRING( VT_UI1 ) // Unsigned char. - CASE_STRING( VT_UI2 ) // Unsigned short. - CASE_STRING( VT_UI4 ) // Unsigned short. - CASE_STRING( VT_I8 ) // Signed 64-bit int. - CASE_STRING( VT_UI8 ) // Unsigned 64-bit int. - CASE_STRING( VT_INT ) // Signed machine int. - CASE_STRING( VT_UINT ) // Unsigned machine int. - CASE_STRING( VT_VOID ) // C-style void. - CASE_STRING( VT_HRESULT ) - CASE_STRING( VT_PTR ) // Pointer type. - CASE_STRING( VT_SAFEARRAY ) // Use VT_ARRAY in VARIANT. - CASE_STRING( VT_CARRAY ) // C-style array. - CASE_STRING( VT_USERDEFINED ) // User-defined type. - CASE_STRING( VT_LPSTR ) // Null-terminated string. - CASE_STRING( VT_LPWSTR ) // Wide null-terminated string. - CASE_STRING( VT_FILETIME ) // FILETIME. - CASE_STRING( VT_BLOB ) // Length-prefixed bytes. - CASE_STRING( VT_STREAM ) // Name of the stream follows. - CASE_STRING( VT_STORAGE ) // Name of the storage follows. - CASE_STRING( VT_STREAMED_OBJECT ) // Stream contains an object. - CASE_STRING( VT_STORED_OBJECT ) // Storage contains an object. - CASE_STRING( VT_BLOB_OBJECT ) // Blob contains an object. - CASE_STRING( VT_CF ) // Clipboard format. - CASE_STRING( VT_CLSID ) // A class ID. - CASE_STRING( VT_VECTOR ) // Simple counted array. - CASE_STRING( VT_ARRAY )// SAFEARRAY*. - CASE_STRING( VT_BYREF ) - CASE_STRING( VT_RESERVED ) - - //CASE_STRING( VT_USERDEFINED ) - //CASE_STRING( VT_RESERVED ) - //CASE_STRING( VT_BYREF ) // A pointer to data is passed - //CASE_STRING( VT_ARRAY ) // A safe array of the data is passed - } - - return s; -} - -LPCTSTR GetVarKindName( VARKIND vk ) -{ - LPTSTR s = _T(""); - - switch( vk ) - { - CASE_STRING( VAR_PERINSTANCE ) - CASE_STRING( VAR_STATIC ) - CASE_STRING( VAR_CONST ) - CASE_STRING( VAR_DISPATCH ) - } - - return s; -} - -LPTSTR GetVarDefaultValue( VARIANT *pv ) -{ - LPTSTR buf = (LPTSTR )malloc( 128 ); - - if( buf != NULL ) { - switch( pv->vt ) - { - case VT_I4: sprintf(buf, "%ld", pv->lVal ); break; - } - } - - return buf; -} - -} \ No newline at end of file diff --git a/jacobgen/jni/TypeLibInspector.h b/jacobgen/jni/TypeLibInspector.h deleted file mode 100644 index b408b8e..0000000 --- a/jacobgen/jni/TypeLibInspector.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Jacobgen.h - * Copyright (C) 2000 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -/* Header for class com_jacob_jacobgen_TypeLibInspector */ - -#ifndef _Included_com_jacob_jacobgen_TypeLibInspector -#define _Included_com_jacob_jacobgen_TypeLibInspector -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_jacobgen_TypeLibInspector - * Method: queryInterface - * Signature: (Ljava/lang/String;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_com_jacob_jacobgen_TypeLibInspector_queryInterface - (JNIEnv *, jobject, jstring); - -void ExtractTypeLib( LPWSTR pszFileName ); -void EnumTypeLib( LPTYPELIB pITypeLib ); -void ExtractTypeInfo( LPTYPEINFO pITypeInfo ); -void EnumTypeInfoMembers( LPTYPEINFO pITypeInfo, LPTYPEATTR pTypeAttr); -void EnumParameters( ITypeInfo *pTypeInfo, FUNCDESC *f ); - -BSTR GetUserDefinedType( LPTYPEINFO pITypeInfo, TYPEDESC tdesc ); - -LPCTSTR GetTypeKindName( TYPEKIND typekind ); -LPCTSTR GetInvokeKindName( INVOKEKIND invkind ); -LPCTSTR GetVarTypeName( VARTYPE vt ); -LPCTSTR GetVarKindName( VARKIND vk ); -LPTSTR GetVarDefaultValue( VARIANT *pv ); - -void append1( LPTSTR string ); -void append2( LPTSTR format, LPCTSTR s1 ); -void append2b( LPTSTR format, BSTR s1); -void append2c ( LPTSTR format, LPCWSTR s1); -void append3( LPTSTR format, BSTR bstr1, LPCTSTR s2 ); - -//Output buffer size -#define BUF_SIZE 5000000 - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/jacobgen/jni/makeh.bat b/jacobgen/jni/makeh.bat deleted file mode 100644 index d3a2e3c..0000000 --- a/jacobgen/jni/makeh.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off -cls -REM This file uses javah to create the jni headers for a class -REM It will use the verbose naming convention - -set JAVA_HOME=D:\j2sdk1.4.2_09 -set JAVAH=%JAVA_HOME%\bin\javah -set CLASSPATH=%JAVA_HOME%\lib\classes.zip;src;release - -%JAVAH% -d jni -jni com.jacob.jacobgen.TypeLibInspector -pause diff --git a/jacobgen/lib/junit3.8.1/junit.jar b/jacobgen/lib/junit3.8.1/junit.jar deleted file mode 100644 index 674d71e..0000000 Binary files a/jacobgen/lib/junit3.8.1/junit.jar and /dev/null differ diff --git a/jacobgen/lib/viztool.jar b/jacobgen/lib/viztool.jar deleted file mode 100644 index 553db19..0000000 Binary files a/jacobgen/lib/viztool.jar and /dev/null differ diff --git a/jacobgen/samples/README.txt b/jacobgen/samples/README.txt deleted file mode 100644 index 7502363..0000000 --- a/jacobgen/samples/README.txt +++ /dev/null @@ -1 +0,0 @@ -This file exists to make sure this directory hangs around until there are actual sample files to put in the samples directory \ No newline at end of file diff --git a/jacobgen/src/com/jacob/jacobgen/AbstractGenerator.java b/jacobgen/src/com/jacob/jacobgen/AbstractGenerator.java deleted file mode 100644 index d560e51..0000000 --- a/jacobgen/src/com/jacob/jacobgen/AbstractGenerator.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * AbstractGenerator.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.Vector; - -/** - * This class represents any of the Abstract classes generated by Jacobgen - * - * @version $Id$ - * - */ -public abstract class AbstractGenerator { - protected final String classHeader = "/**\n" - + " * JacobGen generated file --- do not edit\n" + " *\n" - + " * (http://www.sourceforge.net/projects/jacob-project" + " */\n"; - - protected String filename; - protected String typelibName; - protected String className; - protected String baseClass; - protected Vector classFields; - protected Vector classMethods; - protected String destinationPackage; - protected Writer w; - protected String guid; - - protected boolean simpleEnums = true; - - protected AbstractGenerator(String filename, String typelibName, - String destinationPackage, String className, String baseClass, - Vector classFields, Vector classMethods, - String guid) { - - this.filename = filename; - this.typelibName = typelibName; - this.className = className; - this.baseClass = baseClass; - this.classFields = classFields; - this.classMethods = classMethods; - this.destinationPackage = destinationPackage; - this.guid = guid; - } - - public void generate() throws IOException { - // System.out.println("Writing class: " + filename); - w = new FileWriter(filename); - w.write(classHeader); - - writePackageDeclaration(); - writeImports(); - writeClassDeclaration(); - writeFields(); - writeConstructors(); - writeMethods(); - writeEndings(); - writeClassClosing(); - - w.close(); - } - - protected void writeImports() throws IOException { - w.write("import com.jacob.com.*;\n\n"); - } - - protected void writePackageDeclaration() throws IOException { - if (destinationPackage != null - && destinationPackage.trim().length() > 0) { - w.write("package " + destinationPackage + ";\n\n"); - } - } - - protected abstract void writeClassDeclaration() throws IOException; - - protected abstract void writeFields() throws IOException; - - protected abstract void writeConstructors() throws IOException; - - protected abstract void writeMethods() throws IOException; - - protected void writeEndings() throws IOException { - } - - protected void writeClassClosing() throws IOException { - w.write("}\n"); - } -} diff --git a/jacobgen/src/com/jacob/jacobgen/AliasGenerator.java b/jacobgen/src/com/jacob/jacobgen/AliasGenerator.java deleted file mode 100644 index 91adac0..0000000 --- a/jacobgen/src/com/jacob/jacobgen/AliasGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * AliasGenerator.java - * Copyright (C) 2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.io.IOException; - -/** - * This class creates any of the wrapper classes that map to a DLL object of - * type TKIND_ALIAS - * - * @version $Id$ - */ -class AliasGenerator extends AbstractGenerator { - - protected AliasGenerator(String filename, String typelibName, - String destinationPackage, String className, String baseClass) { - super(filename, typelibName, destinationPackage, className, baseClass, - null, null, null); - } - - protected void writeClassDeclaration() throws IOException { - w.write("public interface " + className + " extends " + baseClass - + " {\n\n"); - } - - protected void writeFields() throws IOException { - } - - protected void writeConstructors() throws IOException { - } - - protected void writeMethods() throws IOException { - } - -} diff --git a/jacobgen/src/com/jacob/jacobgen/ClassGenerator.java b/jacobgen/src/com/jacob/jacobgen/ClassGenerator.java deleted file mode 100644 index a918326..0000000 --- a/jacobgen/src/com/jacob/jacobgen/ClassGenerator.java +++ /dev/null @@ -1,597 +0,0 @@ -/* - * ClassGenerator.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.Vector; - -/** - * The standard class generator for DLL entities of type TKIND_COCLASS and - * TKIND_DISPATCH - * - * @version $Id$ - * - */ -class ClassGenerator extends AbstractGenerator { - - public static String[] javaKeywords = { "goto", "default", "volatile", - "import", "new", "abstract" }; - - protected boolean containsDate = false; - - protected ClassGenerator(String filename, String typelibName, - String destinationPackage, String className, String baseClass, - Vector classFields, Vector classMethods, - String guid) { - super(filename, typelibName, destinationPackage, className, baseClass, - classFields, classMethods, guid); - } - - protected void writeClassDeclaration() throws IOException { - w.write("public class " + className + " extends " + baseClass - + " {\n\n"); - } - - protected void writeFields() throws IOException { - - if (guid == null || "".equals(guid)) { - w.write("\tpublic static final String componentName = \"" - + typelibName + "." + className + "\";\n\n"); - } else { - w.write("\tpublic static final String componentName = \"clsid:" - + guid + "\";\n\n"); - } - } - - protected void writeConstructors() throws IOException { - if (baseClass.equals("Dispatch")) { - writeConstructor1(); - writeConstructor2(); - writeConstructor4(); - } else { - writeConstructor3(); - } - } - - protected void writeConstructor1() throws IOException { - w.write("\tpublic " + className - + "() {\n\t\tsuper(componentName);\n\t}\n\n"); - } - - protected void writeConstructor2() throws IOException { - w.write("\t/**\n"); - w - .write("\t* This constructor is used instead of a case operation to\n"); - w - .write("\t* turn a Dispatch object into a wider object - it must exist\n"); - w - .write("\t* in every wrapper class whose instances may be returned from\n"); - w.write("\t* method calls wrapped in VT_DISPATCH Variants.\n"); - w.write("\t*/\n"); - w.write("\tpublic " + className + "(Dispatch d) {\n"); - w.write("\t\t// take over the IDispatch pointer\n"); - w.write("\t\tm_pDispatch = d.m_pDispatch;\n"); - w.write("\t\t// null out the input's pointer\n"); - w.write("\t\td.m_pDispatch = 0;\n"); - w.write("\t}\n\n"); - } - - protected void writeConstructor4() throws IOException { - w.write("\tpublic " + className - + "(String compName) {\n\t\tsuper(compName);\n\t}\n\n"); - } - - protected void writeConstructor3() throws IOException { - w.write("\tpublic " + className - + "() {\n\t\tsuper(componentName);\n\t}\n\n"); - w.write("\tpublic " + className + "(Dispatch d) {\n" - + "\t\tsuper(d);\n\t}\n"); - } - - protected void writeMethods() throws IOException { - Enumeration e = classMethods.elements(); - while (e.hasMoreElements()) { - MethodItem mi = e.nextElement(); - - if (mi.getMethodType() == MethodItem.METHODTYPE_FUNCTION - || mi.getMethodType() == MethodItem.METHODTYPE_PROPERTYGET - || mi.getMethodType() == MethodItem.METHODTYPE_PROPERTYPUT - || mi.getMethodType() == MethodItem.METHODTYPE_PROPERTYPUTREF) { - - writeMethod(mi); - if (mi.isAdditionalMethodRequired()) { - writeByRefMethod(mi); - } - } - } - } - - protected void writeByRefMethod(MethodItem mi) throws IOException { - ParameterItem[] parameters = mi.getParameters(); - - writeMethodDeclaration(mi, parameters.length, false); - writeMethodBody(mi, parameters.length, false); - } - - protected void writeMethod(MethodItem mi) throws IOException { - // System.out.println("Writing method: " + mi.getName() + " type:" - // + mi.getMethodType()); - ParameterItem[] parameters = mi.getParameters(); - - writeMethodDeclaration(mi, parameters.length, true); - writeMethodBody(mi, parameters.length, true); - - // Try to guess which overloaded methods to write - for (int i = parameters.length - 1; i >= 0; i--) { - ParameterItem p = parameters[i]; - - if (p.isOptional()) { - writeMethodDeclaration(mi, i, true); - writeMethodBody(mi, i, true); - } - } - } - - /** - * This Method writes a short javadoc-comment in front of the method. Maybe - * in a future version the helpstring could be extracted an used instead the - * current weak description. - * - * @param mi - * the MethodItem which should be documented - * @param paramNum - * the count of parameters - * @param baseTypes - * is this a comment for method with only base types or is this a - * comment for method with output-parameters - * @throws IOException - * the used Writer could throw an IOException - */ - protected void writeMethodComment(MethodItem mi, int paramNum, - boolean baseTypes) throws IOException { - // Short description of the method - w.write("\t/**\n"); - if (baseTypes) { - w - .write("\t * Wrapper for calling the ActiveX-Method with input-parameter(s).\n"); - } else { - w - .write("\t * Wrapper for calling the ActiveX-Method and receiving the output-parameter(s).\n"); - } - - // descriptions of the parameters - ParameterItem[] parameters = mi.getParameters(); - for (int i = 0; i < paramNum; i++) { - ParameterItem p = parameters[i]; - if (baseTypes || p.getDirection() == ParameterItem.DIRECTION_IN - || p.getDirection() == ParameterItem.DIRECTION_UNKNOWN) { - w.write("\t * @param " + p.getJavaName() - + " an input-parameter of type " + p.getType() + "\n"); - } else { - // this is only necessary if we want to comment non-basetypes - // and if it is an output-parameter - char[] achParamSpace = new char[p.getJavaName().length()]; - Arrays.fill(achParamSpace, ' '); - // don't want to put a char array in a write() statement - String achParamSpaceString = new String(achParamSpace); - w - .write("\t * @param " - + p.getJavaName() - + " is an one-element array which sends the input-parameter\n" - + "\t * " - + achParamSpaceString - + " to the ActiveX-Component and receives the output-parameter\n"); - } - } - - // and the return-value - if (!mi.getReturnType().equals("void")) { - w.write("\t * @return the result is of type " + mi.getReturnType() - + "\n"); - } - - w.write("\t */\n"); - } - - protected void writeMethodDeclaration(MethodItem mi, int paramNum, - boolean baseTypes) throws IOException { - String[] objectMethods = { "clone", "equals", "finalize", "getClass", - "hashCode", "notify", "notifyAll", "toString", "wait" }; - - writeMethodComment(mi, paramNum, baseTypes); - - w.write("\tpublic "); - if (mi.getMethodType() == MethodItem.METHODTYPE_PROPERTYGET - && mi.getReturnType().trim().length() == 0) { - w.write("Variant"); - } else if (mi.getReturnType().trim().length() == 0) { - w.write("void"); - } else { - w.write(mi.getReturnType()); - } - - w.write(" "); - - StringBuffer methodName = new StringBuffer(); - - // Change Method name if it is a property get or set - switch (mi.getMethodType()) { - case MethodItem.METHODTYPE_FUNCTION: - if (checkForJavaKeywords(mi.getName())) { - methodName.append("m_"); - } - methodName.append(mi.getName().substring(0, 1).toLowerCase()); - methodName.append(mi.getName().substring(1)); - break; - - case MethodItem.METHODTYPE_PROPERTYGET: - methodName.append("get"); - methodName.append(mi.getName()); - break; - - case MethodItem.METHODTYPE_PROPERTYPUT: - case MethodItem.METHODTYPE_PROPERTYPUTREF: - methodName.append("set"); - methodName.append(mi.getName()); - break; - } - - // this should remove any duplicate method names - for (int i = 0; i < objectMethods.length; i++) { - if (objectMethods[i].equals(methodName.toString())) { - methodName.append("1"); - break; - } - } - - // System.out.println("-------> writing " + methodName.toString() - // + " of type " + mi.getMethodType() + " with " - // + mi.getParameters().length + " parameters"); - w.write(methodName.toString()); - w.write("("); - - ParameterItem[] parameters = mi.getParameters(); - for (int i = 0; i < paramNum; i++) { - ParameterItem p = parameters[i]; - - // w.write( p.getType() + "_" + p.getNativeType() ); - w.write(p.getType(baseTypes) + " " + p.getJavaName()); - - if (i < paramNum - 1) { - w.write(", "); - } - } - - w.write(") {\n"); - } - - protected void writeMethodBody(MethodItem mi, int paramNum, - boolean baseTypes) throws IOException { - - switch (mi.getMethodType()) { - case MethodItem.METHODTYPE_FUNCTION: - if (baseTypes) { - writeFunctionMethodBody(mi, paramNum); - } else { - writeOutFunctionMethodBody(mi, paramNum); - } - break; - - case MethodItem.METHODTYPE_PROPERTYGET: - // For zero parameters get property methods I can call - // Dispatch.get, otherwise switch to Dispatch.call - if (paramNum == 0) { - w.write("\t\treturn "); - - if (mi.isCustomReturnType()) { - w.write("new " + mi.getReturnType() + "("); - } - - w.write("Dispatch.get(this, \"" + mi.getName() + "\")" - + mi.getReturnConversionMethodCode()); - - if (mi.isCustomReturnType()) { - w.write(".toDispatch())"); - } - - w.write(";\n"); - } else { - if (baseTypes) { - writeFunctionMethodBody(mi, paramNum); - } else { - writeOutFunctionMethodBody(mi, paramNum); - } - } - break; - - case MethodItem.METHODTYPE_PROPERTYPUT: - case MethodItem.METHODTYPE_PROPERTYPUTREF: - // w.write( "\t\tDispatch.put(this, \"" + mi.getName() + "\", " + - // computeParamType( params[0] ) + ");\n" ); - - // ---- special processing should be done in the functions - // write*MethodBody - if (paramNum == 1) { - - ParameterItem[] parameters = mi.getParameters(); - ParameterItem p = parameters[0]; - w.write("\t\tDispatch.put(this, \"" + mi.getName() + "\", " - + p.getParameterCallingCode() + ");\n"); - } else { - if (baseTypes) { - writeFunctionMethodBody(mi, paramNum); - } else { - writeOutFunctionMethodBody(mi, paramNum); - } - } - break; - } - - w.write("\t}\n\n"); - } - - /** - * This Method writes the method body for a method with output-parameters. - * - * @param mi - * the MethodItem which should be documented - * @param paramNum - * the count of parameters - * @throws IOException - * the used Writer could throw an IOException - */ - protected void writeOutFunctionMethodBody(MethodItem mi, int paramNum) - throws IOException { - ParameterItem[] parameters = mi.getParameters(); - - // If we are using paramters with return values we have to initialize - // the Varaints with put*Ref(). This has to be done before the call. - // It should look like the following: Variant param1 = new Variant(); - // param1.putIntRef(lastParam[0]); - for (int i = 0; i < paramNum; i++) { - ParameterItem p = parameters[i]; - // this is only necessary if it is an output-parameter - // if ( p.getDirection() == ParameterItem.DIRECTION_OUT && - // !p.getType().equals("SafeArray") ) { - if (p.getDirection() == ParameterItem.DIRECTION_OUT) { - w.write("\t\tVariant " + p.getVariantName() - + " = new Variant();\n"); - w.write("\t\tif( " + p.getJavaName() + " == null || " - + p.getJavaName() + ".length == 0 )\n"); - w.write("\t\t\t" + p.getVariantName() + ".putNoParam();\n"); - w.write("\t\telse\n"); - // 12/2005 hack to get get this to generate compileable code. - // Hopefully someone will look at this later and make sure it is - // correct - if (p.getVariantPutMethod().equals("putVariantRef")) { - w.write("\t\t\t" + p.getVariantName() + " = " - + p.getJavaName() + "[0];\n\n"); - } else if (p.getVariantPutMethod().equals("java.util.Date")) { - w.write("\t\t\t" + p.getVariantName() + ".putDate(" - + p.getJavaName() + "[0]);\n\n"); - } else { - w.write("\t\t\t" + p.getVariantName() + "." - + p.getVariantPutMethod() + "(" + p.getJavaName() - + "[0]);\n\n"); - } - } - } - - w.write("\t\t"); - if (!mi.getReturnType().equals("void")) { - w.write(mi.getReturnType() + " result_of_" + mi.getName() + " = "); - - if (mi.isCustomReturnType()) { - w.write("new " + mi.getReturnType() + "("); - } - - if (mi.getReturnType().equals("java.util.Date")) { - w.write("javaDateToComDate("); - containsDate = true; - } - } - - w.write("Dispatch.call"); - if (paramNum > 8) { - w.write("N"); - } - w.write("(this, \"" + mi.getName() + "\""); - if (paramNum > 0) { - w.write(", "); - } - - if (paramNum > 8) { - w.write("new Object[] { "); - } - - for (int i = 0; i < paramNum; i++) { - if (i != 0) { - w.write(", "); - } - - ParameterItem p = parameters[i]; - if (p.getDirection() == ParameterItem.DIRECTION_IN - || p.getDirection() == ParameterItem.DIRECTION_UNKNOWN) { - // if it is an input-parameter we use the normal behaviour - w.write(p.getParameterCallingCode()); - } else { - // if it is an output-parameter we use the variant-variable - w.write(p.getVariantName()); - } - } - - if (paramNum > 8) { - w.write("}"); - } - - w.write(")"); - if (!mi.getReturnType().equals("void")) { - w.write(mi.getReturnConversionMethodCode()); - } - - if (mi.isCustomReturnType()) { - w.write(".toDispatch())"); - } - - if (mi.getReturnType().equals("java.util.Date")) { - w.write(")"); - } - - w.write(";\n\n"); - - // If we are using paramters with return values we have to retrieve this - // values from the Varaints with to*(). This has to be done after the - // call. - // It should look like the following: lastParam[0] = param1.toInt(); - for (int i = 0; i < paramNum; i++) { - ParameterItem p = parameters[i]; - // this is only necessary if it is an output-parameter - if (p.getDirection() == ParameterItem.DIRECTION_OUT) { - w.write("\t\tif( " + p.getJavaName() + " != null && " - + p.getJavaName() + ".length > 0 )\n"); - if (p.getVariantGetMethod().equals("toVariant")) { - // 12/2005 hack to get get this to generate compileable - // code. - // Hopefully someone will look at this later and make sure - // it is correct - w.write("\t\t\t" + p.getJavaName() + "[0] = " - + p.getVariantName() + ";\n"); - } else { - w.write("\t\t\t" + p.getJavaName() + "[0] = " - + p.getVariantName() + "." - + p.getVariantGetMethod() + "();\n"); - } - } - } - - // Now it is time to return the result - if (!mi.getReturnType().equals("void")) { - w.write("\n\t\treturn result_of_" + mi.getName() + ";\n"); - } - } - - protected void writeFunctionMethodBody(MethodItem mi, int paramNum) - throws IOException { - w.write("\t\t"); - - if (!mi.getReturnType().equals("void")) { - w.write("return "); - - if (mi.isCustomReturnType()) { - w.write("new " + mi.getReturnType() + "("); - } - } - - w.write("Dispatch.call"); - if (paramNum > 8) { - w.write("N"); - } - w.write("(this, \"" + mi.getName() + "\""); - if (paramNum > 0) { - w.write(", "); - } - - ParameterItem[] parameters = mi.getParameters(); - if (paramNum > 8) { - w.write("new Object[] { "); - } - - for (int i = 0; i < paramNum; i++) { - if (i != 0) { - w.write(", "); - } - - ParameterItem p = parameters[i]; - w.write(p.getParameterCallingCode()); - } - - if (paramNum > 8) { - w.write("}"); - } - - w.write(")"); - if (!mi.getReturnType().equals("void")) { - w.write(mi.getReturnConversionMethodCode()); - } - - if (mi.isCustomReturnType()) { - w.write(".toDispatch())"); - } - - w.write(";\n"); - } - - protected void writeDateConversionCode() throws IOException { - w.write("\tstatic long zoneOffset"); - w - .write("\t= java.util.Calendar.getInstance().get(java.util.Calendar.ZONE_OFFSET);\n\n"); - /* - * w.write( "\tstatic java.util.Date comDateToJavaDate(double comDate) - * {\n"); w.write( "\t\tcomDate = comDate - 25569D;\n"); w.write( - * "\t\tlong millis = Math.round(86400000L * comDate) - - * zoneOffset;\n\n"); w.write( "\t\tjava.util.Calendar cal = - * java.util.Calendar.getInstance();\n"); w.write( "\t\tcal.setTime(new - * java.util.Date(millis));\n"); w.write( "\t\tmillis -= - * cal.get(java.util.Calendar.DST_OFFSET);\n\n"); w.write( "\t\treturn - * new java.util.Date(millis);\n"); w.write( "\t}\n\n"); - */ - w - .write("\tstatic double javaDateToComDate(java.util.Date javaDate) {\n\n"); - w - .write("\t\tjava.util.Calendar cal = java.util.Calendar.getInstance();\n"); - w.write("\t\tcal.setTime(javaDate);\n"); - w - .write("\t\tlong gmtOffset = (cal.get(java.util.Calendar.ZONE_OFFSET) + cal.get(java.util.Calendar.DST_OFFSET));\n\n"); - w.write("\t\tlong millis = javaDate.getTime() + gmtOffset;\n"); - w.write("\t\treturn 25569D+millis/86400000D;\n"); - w.write("\t}\n\n"); - } - - protected void writeEndings() throws IOException { - if (containsDate) { - writeDateConversionCode(); - } - } - - /* - * protected String computeParamType( ParameterItem pi ) { String result = - * "new Variant(" + pi.getName() + ")"; if( pi.getType().equals("String" ) || - * pi.isObject() || pi.isCustomType() ) result = pi.getName(); - * - * return result; } - */ - - /** - * Change contents of StringBuffer if contains a Java Keyword. It should - * prevent compile errors. - */ - public static boolean checkForJavaKeywords(String s) { - boolean result = false; - for (int i = 0; i < javaKeywords.length; i++) { - if (s.equalsIgnoreCase(javaKeywords[i])) { - result = true; - break; - } - } - - return result; - } -} diff --git a/jacobgen/src/com/jacob/jacobgen/EnumGenerator.java b/jacobgen/src/com/jacob/jacobgen/EnumGenerator.java deleted file mode 100644 index 650c37f..0000000 --- a/jacobgen/src/com/jacob/jacobgen/EnumGenerator.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * EnumGenerator.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.Vector; - -/** - * the class that generates java classes representing DLL entities of type - * TKIND_ENUM - * - * @version $Id$ - * - */ -class EnumGenerator extends AbstractGenerator { - - protected EnumGenerator(String filename, String typelibName, - String destinationPackage, String className, String baseClass, - Vector classFields, Vector classMethods) { - super(filename, typelibName, destinationPackage, className, baseClass, - classFields, classMethods, null); - } - - protected void writeClassDeclaration() throws IOException { - w.write("public interface " + className + " {\n\n"); - } - - protected void writeFields() throws IOException { - Enumeration e = classFields.elements(); - - while (e.hasMoreElements()) { - FieldItem fi = e.nextElement(); - w.write("\tpublic static final " + fi.getType() + " " - + fi.getName() + " = " + fi.getDefaultValue() + ";\n"); - } - } - - protected void writeConstructors() throws IOException { - } - - protected void writeMethods() throws IOException { - } - -} diff --git a/jacobgen/src/com/jacob/jacobgen/FieldItem.java b/jacobgen/src/com/jacob/jacobgen/FieldItem.java deleted file mode 100644 index 785693e..0000000 --- a/jacobgen/src/com/jacob/jacobgen/FieldItem.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * FieldItem.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.util.NoSuchElementException; -import java.util.StringTokenizer; - -/** - * Represents a class method - * - * @version $Id$ - * @author Massimiliano Bigatti - */ -public class FieldItem { - - private String name; - private String type; - private String nativeType; - /** - * note that this field is set but never read. It looks like an incomplete - * implementation - */ - private int fieldType; - private String defaultValue; - - public static final int FIELDTYPE_UNKNOWN = -1; - public static final int FIELDTYPE_CONST = 0; - - protected FieldItem(String line) throws IllegalFormatException { - extractData(line); - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDefaultValue() { - return defaultValue; - } - - /** - * this was added to remove a compiler warning but it looks like the field - * type was never fully implemented - * - * @return the field type that was set - */ - public int getFieldType() { - return fieldType; - } - - /** - * Extract information from a well formatted line - */ - protected void extractData(String line) throws IllegalFormatException { - StringTokenizer st = new StringTokenizer(line, ";"); - - try { - // Extract field type - computeFieldType(st.nextToken()); - - // Extract variable name - name = st.nextToken(); - - // Compute variable type - nativeType = st.nextToken(); - computeFieldVartype(nativeType); - - // Extract default value - defaultValue = st.nextToken(); - - } catch (NoSuchElementException ns) { - System.err.println("Seems that line " + line + " is not well " - + "formed, report to support."); - ns.printStackTrace(); - } - - } - - protected void computeFieldType(String type) { - fieldType = FIELDTYPE_UNKNOWN; - if (type.equals("VAR_CONST")) { - fieldType = FIELDTYPE_CONST; - } - } - - protected void computeFieldVartype(String fieldVartype) { - type = ""; - if (nativeType.equals("VT_I4")) { - type = "int"; - } - } -} diff --git a/jacobgen/src/com/jacob/jacobgen/IllegalFormatException.java b/jacobgen/src/com/jacob/jacobgen/IllegalFormatException.java deleted file mode 100644 index bedf205..0000000 --- a/jacobgen/src/com/jacob/jacobgen/IllegalFormatException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * IllegalFormatException.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -/** - * used by Method and Field item when they find a spec of an unknown format - * - * @version $Id$ - * - */ -public class IllegalFormatException extends Exception { - - /** - * unique id generated by Eclipse - */ - private static final long serialVersionUID = -8213908427515923275L; - - protected IllegalFormatException() { - super(); - } - - protected IllegalFormatException(String msg) { - super(msg); - } - -} diff --git a/jacobgen/src/com/jacob/jacobgen/Jacobgen.java b/jacobgen/src/com/jacob/jacobgen/Jacobgen.java deleted file mode 100644 index 928154a..0000000 --- a/jacobgen/src/com/jacob/jacobgen/Jacobgen.java +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Jacoben.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.LineNumberReader; -import java.io.StringReader; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.StringTokenizer; -import java.util.Vector; - -import com.samskivert.viztool.clenum.ClassEnumerator; - -/** - * This is the root class for Jacobgen. It generates Jacob wrapper class for - * windows DLLs. Run this class with no command line parameters to get a list of - * the valid command line options - * - * - * %JRE% -Xint com.jacob.jacobgen.Jacobgen %1 %2 %3 %4 %5 - * - * - * @version $Id$ - * @author Massimiliano Bigatti - */ -public class Jacobgen { - - public static final String version = "0.8"; - public static Jacobgen instance; - protected Vector methodsToAvoid; - - /** - * Package where to put generated classes - */ - protected String destinationPackage = ""; - - // This option allow to re-run from a modified list file, instead of re - // parsing the typelib - protected String inputFileName = null; - - protected String destinationPath = ""; - - protected String typelibFilename = null; - - protected String tempFileName = null; - - protected Vector internalEnums = new Vector(); - - protected Hashtable externalClasses; - - private Jacobgen() { - methodsToAvoid = new Vector(); - methodsToAvoid.addElement("QueryInterface"); - methodsToAvoid.addElement("AddRef"); - methodsToAvoid.addElement("Release"); - methodsToAvoid.addElement("GetTypeInfoCount"); - methodsToAvoid.addElement("GetTypeInfo"); - methodsToAvoid.addElement("GetIDsOfNames"); - methodsToAvoid.addElement("Invoke"); - } - - protected void loadExternalClasses() { - String classpath = System.getProperty("java.class.path"); - ClassEnumerator aClassEnumerator = new ClassEnumerator(classpath); - - // print out the warnings - ClassEnumerator.Warning[] warnings = aClassEnumerator.getWarnings(); - for (int i = 0; i < warnings.length; i++) { - System.out.println("External Class Loader Warning: " - + warnings[i].reason); - } - - externalClasses = new Hashtable(); - while (aClassEnumerator.hasNext()) { - String s = (String) aClassEnumerator.next(); - int p = s.lastIndexOf('.'); - externalClasses.put(s.substring(p + 1), s); - } - } - - protected String getExternalClass(String className) { - return externalClasses.get(className); - } - - public boolean isEnum(String className) { - String fullClassName = null; - boolean result = internalEnums.contains(className.toLowerCase()); - - // Check for pointed JARs. We assume that all enums are implemented - // as interfaces. - if (!result) { - fullClassName = getExternalClass(className); - if (fullClassName != null) { - try { - Class clazz = Class.forName(fullClassName); - result = clazz.isInterface(); // Little hack - // if( result ) - // System.out.println("isEnum : " + fullClassName ); - - } catch (ClassNotFoundException ex1) { - } catch (NoClassDefFoundError ex2) { - } - } - } - - return result; - } - - public void generate() throws IOException { - - System.out.println("JACOBGEN " + version - + ". See the distribution for licensing details."); - System.out.println("starting ..."); - - // Create a list of external classes - loadExternalClasses(); - - byte[] typelibinfo = null; - - if (inputFileName == null) { - - System.out.println("creating TypeLibInspector"); - // Query TypeLib informations - TypeLibInspector inspector = new TypeLibInspector(); - System.out.println("calling TypeLibInspector.queryInterface with " - + typelibFilename); - typelibinfo = inspector.queryInterface(typelibFilename); - } else { - File inputFile = new File(inputFileName); - int len = new Long(inputFile.length()).intValue(); - typelibinfo = new byte[len]; - FileInputStream fis = new FileInputStream(inputFile); - fis.read(typelibinfo); - } - - System.out.println("TypeLibInspector.queryInterface finished."); - // Convert byte array to a vector of lines - LineNumberReader reader = new LineNumberReader(new StringReader( - new String(typelibinfo))); - - Vector lines = new Vector(); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } - - lines.addElement(line); - } - - if (tempFileName != null) { - try { - File out = new File(tempFileName); - FileWriter fw = new FileWriter(out); - - Enumeration e = lines.elements(); - while (e.hasMoreElements()) { - fw.write(e.nextElement()); - fw.write('\n'); - } - - fw.close(); - - } catch (IOException io) { - System.err - .println("Unable to generate temporary output file\n"); - } - } - - generateClasses(lines); - } - - protected void generateClasses(Vector lines) throws IOException { - int count = 0; - boolean startClass = false; - Vector classMethods = null; - Vector classFields = null; - String className = ""; - String classType = ""; - String typelibName = ""; - String baseClass = ""; - String guid = ""; - - int enums = 0; - System.out.print("finding ENUMS (" + lines.size() + ")... "); - for (int i = 0; i < lines.size(); i++) { - String line = lines.elementAt(i); - - System.out.println("Line=" + line); - - if (line.startsWith("CLASS")) { - int p = line.indexOf(' '); - int f = line.indexOf(';'); - classType = line.substring(f + 1).trim(); - className = line.substring(p, f).trim().toLowerCase(); - - if (classType.equals("TKIND_ENUM")) { - internalEnums.addElement(className); - enums++; - } - - if (classType.equals("TKIND_ALIAS")) { - - // Pick up the next row and determine the superclass - i++; - String derivedAlias = lines.elementAt(i); - derivedAlias = derivedAlias.substring( - derivedAlias.indexOf(';') + 1).trim(); - - // Search for pointed to alias - for (int k = 0; k < lines.size(); k++) { - line = lines.elementAt(k); - if (line.startsWith("CLASS")) { - int p1 = line.indexOf(' '); - int f1 = line.indexOf(';'); - String className1 = line.substring(p1, f1).trim(); - - if (className1.trim().equals(derivedAlias)) { - internalEnums.addElement(className); - enums++; - break; - } - } - } - } - } - } - System.out.println("done (" + enums + ")"); - - for (int i = 0; i < internalEnums.size(); i++) { - System.out.println(internalEnums.elementAt(i)); - } - className = ""; - classType = ""; - - System.out.println("generating classes ... "); - for (int i = 0; i < lines.size(); i++) { - String line = lines.elementAt(i); - - if (line.startsWith("TYPELIB")) { - typelibName = line.substring(8); - } - - if (line.startsWith("GUID")) { - if (line.substring(5) != null - && !"{00000000-0000-0000-0000-000000000000}" - .equals(line.substring(5))) { - guid = line.substring(5); - } - } else - - if (line.startsWith("CLASS")) { - if (startClass) { - // Previous class definition ends, commit data to file - createSourceFile(typelibName, className, classType, - baseClass, classFields, classMethods, guid); - } - baseClass = ""; - classMethods = new Vector(); - classFields = new Vector(); - - int p = line.indexOf(' '); - int f = line.indexOf(';'); - - className = line.substring(p, f).trim(); - classType = line.substring(f + 1).trim(); - startClass = true; - count++; - } else { - if (startClass) { - - if (line.startsWith("EXTENDS")) { - - int f = line.indexOf(';'); - if (!line.substring(f + 1).trim().endsWith("Events")) { - baseClass = line.substring(f + 1).trim(); - if (baseClass.equals("IDispatch")) { - baseClass = "Dispatch"; - } - } - - } else { - try { - if (classType.equals("TKIND_ENUM")) { - FieldItem fi = new FieldItem(line); - classFields.addElement(fi); - } else if (classType.equals("TKIND_DISPATCH")) { - - StringTokenizer st = new StringTokenizer(line, - ";"); - String kind = ""; - String name = ""; - String native_type = ""; - try { - kind = st.nextToken(); - name = st.nextToken(); - native_type = st.nextToken(); - } catch (Exception e) { - } - if (kind.equals("VAR_DISPATCH")) { - - // System.out.println("FOUND!!! -"+line); - // System.out.println("Kind="+kind+", - // name="+name+", type="+native_type); - // String getPropLine = - // "INVOKE_PROPERTYGET;"+native_type+";"+name+";["+native_type+" - // parmValue]"; - // String putPropLine = - // "INVOKE_PROPERTYPUT;VT_VOID - // ;"+name+";["+native_type+" - // key,"+native_type+" parmValue]"; - String getPropLine = "INVOKE_PROPERTYGET;" - + native_type + ";" + name + ";[]"; - String putPropLine = "INVOKE_PROPERTYPUT;VT_VOID ;" - + name - + ";[" - + native_type - + " parmValue]"; - - MethodItem mi = new MethodItem(getPropLine); - if (!methodsToAvoid.contains(mi.getName())) { - classMethods.addElement(mi); - } - - MethodItem mi2 = new MethodItem(putPropLine); - if (!methodsToAvoid.contains(mi2.getName())) { - classMethods.addElement(mi2); - } - - /* - * - * VAR_DISPATCH;topicname;VT_BSTR - * VAR_DISPATCH;selector;VT_I2 - * - * INVOKE_PROPERTYGET;VT_BSTR - * ;PlanProp;[VT_BSTR LastParam] - * INVOKE_PROPERTYPUT;VT_VOID - * ;PlanProp;[VT_BSTR bstrKey,VT_BSTR - * LastParam] - */ - } else { - - MethodItem mi = new MethodItem(line); - if (!methodsToAvoid.contains(mi.getName())) { - classMethods.addElement(mi); - } - } - } - } catch (IllegalFormatException ife) { - System.err.println("Class " + className - + ", method:" + line - + " not parsed due to a format error"); - ife.printStackTrace(); - } - } - } - } - } - - // Parse last CLASS definition - if (startClass) { - // Previous class definition ends, commit data to file - createSourceFile(typelibName, className, classType, baseClass, - classFields, classMethods, guid); - } - System.out.println("done (" + count + " classes)"); - - } - - protected void createSourceFile(String typelibName, String className, - String classType, String baseClass, Vector classFields, - Vector classMethods, String guid) throws IOException { - - AbstractGenerator g; - String filename; - String directory = ""; - - if (destinationPath.length() > 0) { - if (!destinationPath.endsWith(File.separator)) { - destinationPath += File.separator; - } - } - - if (destinationPackage.length() > 0) { - directory = convertPackageToDir(destinationPackage) - + File.separator; - } - - filename = destinationPath + directory + className + ".java"; - - System.out.println("Creating " + filename + " ..."); - - File file = new File(destinationPath + directory); - if (!file.exists()) { - if (!file.mkdirs()) { - System.err.println("Unable to create directories (" - + destinationPath + directory + ") !"); - } - } - - g = null; - if (classType.equals("TKIND_ENUM")) { - g = new EnumGenerator(filename, typelibName, destinationPackage, - className, baseClass, classFields, null); - } else if (classType.equals("TKIND_COCLASS")) { - g = new ClassGenerator(filename, typelibName, destinationPackage, - className, baseClass, null, classMethods, guid); - } else if (classType.equals("TKIND_DISPATCH")) { - g = new ClassGenerator(filename, typelibName, destinationPackage, - className, baseClass, null, classMethods, null); - } else if (classType.equals("TKIND_INTERFACE")) { - g = new ClassGenerator(filename, typelibName, destinationPackage, - className, baseClass, null, classMethods, null); - } else if (classType.equals("TKIND_ALIAS")) { - g = new AliasGenerator(filename, typelibName, destinationPackage, - className, baseClass); - } else { - System.err.println("Unrecognized class type " + classType); - } - - if (g != null) { - g.generate(); - } - - } - - protected String convertPackageToDir(String packageName) { - StringTokenizer st = new StringTokenizer(packageName, "."); - StringBuffer buffer = new StringBuffer(); - - while (st.hasMoreTokens()) { - buffer.append(st.nextToken()); - if (st.hasMoreTokens()) { - buffer.append(File.separator); - } - } - - return buffer.toString(); - } - - protected Vector readFile(String filename) - throws FileNotFoundException, IOException { - Vector result = new Vector(); - - FileReader fr = new FileReader(filename); - LineNumberReader reader = new LineNumberReader(fr); - - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } - - result.addElement(line); - } - - return result; - } - - public static Jacobgen getInstance() { - if (instance == null) { - instance = new Jacobgen(); - } - - return instance; - } - - public void parseOptions(String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].startsWith("-package")) { - destinationPackage = args[i].substring(9); - } else if (args[i].startsWith("-destdir")) { - destinationPath = args[i].substring(9); - } else if (args[i].startsWith("-listfile")) { - tempFileName = args[i].substring(10); - } else if (args[i].startsWith("-inputfile")) { - inputFileName = args[i].substring(11); - } else { - typelibFilename = resolveFileName(args[i]); - } - } - System.out.println("destinationPackage: " + destinationPackage); - System.out.println("destinationPath: " + destinationPath); - System.out.println("tempFileName: " + tempFileName); - System.out.println("inputFileName: " + inputFileName); - System.out.println("typelibFilename: " + typelibFilename); - } - - /** - * This was added sourceforge 1651565 to support the searching for the files - * by name on the path in addition to supporting absolute paths for file - * names - */ - private String resolveFileName(String fileName) { - File file = new File(fileName); - if (file != null) { - return file.getAbsolutePath(); - } else { - // this essentially fails over to the old (absolute path only) - // behavior - return fileName; - } - } - - public static void main(String[] args) { - if (args.length == 0) { - System.out.println("JacobGen [options] typelibfile\n"); - System.out.println("Options:"); - System.out.println("\t-package:"); - System.out.println("\t-destdir:"); - System.out.println("\t-listfile:"); - System.out.println(); - System.exit(0); - } else { - Jacobgen g = getInstance(); - try { - g.parseOptions(args); - if (g.typelibFilename == null && g.inputFileName == null) { - System.out - .println("Jacobgen you need to specify a typelib file or an input file"); - } else { - g.generate(); - // g.generate( argv[0], argv[1] ); - } - } catch (IOException ex2) { - System.err.println("Jacobgen: I/O error (file " - + g.typelibFilename + ")"); - } - } - } -} diff --git a/jacobgen/src/com/jacob/jacobgen/MethodItem.java b/jacobgen/src/com/jacob/jacobgen/MethodItem.java deleted file mode 100644 index 1c20854..0000000 --- a/jacobgen/src/com/jacob/jacobgen/MethodItem.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * MethodItem.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -import java.util.NoSuchElementException; -import java.util.StringTokenizer; -import java.util.Vector; - -/** - * Represents a class method. - * - * @version $Id$ - * @author Massimiliano Bigatti - */ -public class MethodItem { - - private String name; - private String returnType; - private String nativeReturnType; - private int methodType; - private Vector parametersList; - private boolean customReturnType; - private boolean additionalMethodRequired; - - public static final int METHODTYPE_UNKNOWN = -1; - public static final int METHODTYPE_FUNCTION = 1; - public static final int METHODTYPE_PROPERTYGET = 2; - public static final int METHODTYPE_PROPERTYPUT = 3; - public static final int METHODTYPE_PROPERTYPUTREF = 4; - - protected MethodItem(String line) throws IllegalFormatException { - parametersList = new Vector(); - extractData(line); - } - - /** - * Extract information from a well formatted line - */ - protected void extractData(String line) throws IllegalFormatException { - StringTokenizer st = new StringTokenizer(line, ";"); - - try { - - String mt = st.nextToken(); - - // Extract method type - methodType = computeMethodType(mt); - - // Extract return type - nativeReturnType = st.nextToken().trim(); - if (nativeReturnType.length() > 0) { - returnType = computeVarType(nativeReturnType); - } else { - returnType = ""; - } - - // Extract name - name = st.nextToken(); - - // Extract parameters - extractParameters(st.nextToken()); - // System.out.println(" extracted PUT parameters from line: " - // + line + " resulting in: " + this.parametersList); - - // Computes if the return type is a standard type - computeCustomReturnType(); - - } catch (NoSuchElementException ns) { - System.err.println("Seems that line " + line + " is not well " - + "formed, report to support."); - ns.printStackTrace(); - } - } - - /** - * This extracts the parameters from a line that comes from typelib. - * - * Sample lines looks like: - * - *
-	 * INVOKE_FUNC;VT_VOID ;SetRange;[{in-}VT_I4 Start,{in-}VT_I4 End]
-	 * INVOKE_FUNC;VT_VOID ;Collapse;[{in-optional-}VT_VARIANT Direction]
-	 * INVOKE_FUNC;VT_VOID ;Sync;[MsoSyncEventType SyncEventType]
-	 * 
- * - * The parameters section for the first one would be - * [{in-}VT_I4 Start,{in-}VT_I4 End] where the first - * parameter is {in-}VT_I4 Start and the second parameter is - * {in-}VT_I4 End - * - * @param parameters - * @throws IllegalFormatException - */ - protected void extractParameters(String parameters) - throws IllegalFormatException { - additionalMethodRequired = false; - - // Strip trailing and ending [] on the parameter list - if (!parameters.startsWith("[") || !parameters.endsWith("]")) { - throw new IllegalFormatException("Parameters format error : " - + parameters); - } else { - parameters = parameters.substring(1, parameters.length() - 1); - } - - // the parameters are in a comma separated list - StringTokenizer st = new StringTokenizer(parameters, ","); - while (st.hasMoreTokens()) { - String param = st.nextToken(); - - // Extract parameters data - StringTokenizer st1 = new StringTokenizer(param); - String options = st1.nextToken("{}"); - String parameterType = null; - String parameterName = null; - if (options.endsWith("-")) { - parameterType = st1.nextToken(" ").substring(1).trim(); - parameterName = st1.nextToken(); - } else { - // SF1650138 added this to handle enumerated types. - // they look like [type value] - StringTokenizer st3 = new StringTokenizer(param); - parameterType = st3.nextToken(" "); - parameterName = st3.nextToken(); - } - - // Extract options - int direction = ParameterItem.DIRECTION_UNKNOWN; - boolean optional = false; - // this is a while loop because it could be a compound - // option description like {in-optional-} - StringTokenizer st2 = new StringTokenizer(options, "-"); - while (st2.hasMoreTokens()) { - String option = st2.nextToken(); - if (option.equals("in")) { - direction = ParameterItem.DIRECTION_IN; - } else if (option.equals("out")) { - direction = ParameterItem.DIRECTION_OUT; - } else if (option.equals("retval")) { - direction = ParameterItem.DIRECTION_RETVAL; - } else if (option.equals("optional")) { - optional = true; - } - } - - ParameterItem pi = new ParameterItem(parameterName, parameterType, - computeVarType(parameterType), direction, optional); - - // This parameter is a Java base class - // if( pi.getObjectType() != pi.getType() ) - if (optional || direction == ParameterItem.DIRECTION_OUT) { - additionalMethodRequired = true; - } - - // System.out.println("Parameter: " + pi); - parametersList.addElement(pi); - } - - } - - public String getName() { - return name; - } - - public String getReturnType() { - return returnType; - } - - public int getMethodType() { - return methodType; - } - - public boolean isAdditionalMethodRequired() { - return additionalMethodRequired; - } - - protected void computeCustomReturnType() { - if (nativeReturnType.equals("VT_SAFEARRAY")) { - customReturnType = false; - return; - } - - String[] types = { "void", "Object", "short", "int", "float", "double", - "long", "java.util.Date", "String", "Dispatch", "boolean", - "Variant", "byte" }; - - customReturnType = true; - if (returnType.trim().length() == 0) { - customReturnType = false; - } else { - for (int i = 0; i < types.length; i++) { - if (types[i].equals(returnType.trim())) { - customReturnType = false; - break; - } - } - } - } - - public boolean isCustomReturnType() { - return customReturnType; - } - - public ParameterItem[] getParameters() { - ParameterItem[] parameters = new ParameterItem[parametersList.size()]; - parametersList.copyInto(parameters); - return parameters; - } - - public static int computeMethodType(String type) - throws IllegalFormatException { - int result = METHODTYPE_UNKNOWN; - - if (type.equals("INVOKE_FUNC")) { - result = METHODTYPE_FUNCTION; - } else if (type.equals("INVOKE_PROPERTYGET")) { - result = METHODTYPE_PROPERTYGET; - } else if (type.equals("INVOKE_PROPERTYPUT")) { - result = METHODTYPE_PROPERTYPUT; - } else if (type.equals("INVOKE_PROPERTYPUTREF")) { - result = METHODTYPE_PROPERTYPUTREF; - } else { - throw new IllegalFormatException("Unknown method type: " + type); - } - - return result; - } - - public static String computeVarType(String type) - throws IllegalFormatException { - String result = ""; - - if (type.equals("VT_EMPTY")) { - result = "void"; - } else if (type.equals("VT_NULL")) { - result = "Object"; - } else if (type.equals("VT_I2")) { - result = "short"; - } else if (type.equals("VT_I4") || type.equals("VT_INT")) { - result = "int"; - } else if (type.equals("VT_R4")) { - result = "float"; - } else if (type.equals("VT_R8")) { - result = "double"; - } else if (type.equals("VT_CY")) { - result = "long"; - } else if (type.equals("VT_DATE")) { - result = "java.util.Date"; - } else if (type.equals("VT_BSTR")) { - result = "String"; - } else if (type.equals("VT_DISPATCH")) { - // result = "Dispatch"; - result = "Object"; - } else if (type.equals("VT_ERROR")) { - result = "int"; - } else if (type.equals("VT_BOOL")) { - result = "boolean"; - } else if (type.equals("VT_VARIANT")) { - result = "Variant"; - } else if (type.equals("VT_UNKNOWN")) { - result = "Variant"; - } else if (type.equals("VT_I1")) { - result = "byte"; - } else if (type.equals("VT_UI1")) { - result = "byte"; - } else if (type.equals("VT_UI2")) { - result = "short"; - } else if (type.equals("VT_UI4")) { - result = "int"; - } else if (type.equals("VT_I8")) { - result = "long"; - } else if (type.equals("VT_UI8")) { - result = "long"; - } else if (type.equals("VT_INT")) { - result = "int"; - } else if (type.equals("VT_UINT")) { - result = "int"; - } else if (type.equals("VT_VOID")) { - result = "void"; - } else if (type.equals("VT_HRESULT")) { - result = "int"; - } else if (type.equals("VT_SAFEARRAY")) { - result = "SafeArray"; - } else if (type.equals("MsoRGBType")) { - result = "int"; - } else { - // Custom type - result = Jacobgen.getInstance().getExternalClass(type) == null ? type - : Jacobgen.getInstance().getExternalClass(type); - } - - // Simple enumeration - if (Jacobgen.getInstance().isEnum(type)) { - result = "int"; - } - - return result; - } - - /** - * Return the code required to perform the correct conversion between - * Variant and return type - */ - protected String getReturnConversionMethodCode() { - String result = ""; - - if (nativeReturnType.equals("VT_EMPTY")) { - result = ""; - } else if (nativeReturnType.equals("VT_NULL")) { - // method? this calls - // toDispatch() which - // results in what ? - result = ".toDispatch()"; - } else if (nativeReturnType.equals("VT_I2")) { - result = ".changeType(Variant.VariantShort).getShort()"; - } else if (nativeReturnType.equals("VT_I4") - || nativeReturnType.equals("VT_INT")) { - result = ".changeType(Variant.VariantInt).getInt()"; - } else if (nativeReturnType.equals("VT_R4")) { - result = ".changeType(Variant.VariantFloat).getFloat()"; - } else if (nativeReturnType.equals("VT_R8")) { - result = ".changeType(Variant.VariantDouble).getDouble()"; - } else if (nativeReturnType.equals("VT_CY")) { - result = ".changeType(Variant.VariantCurrency).getCurrency()"; - } else if (nativeReturnType.equals("VT_DATE")) { - // new toJavaDate() so - // we could remove the - // conversion code - result = ".getJavaDate()"; - } else if (nativeReturnType.equals("VT_BSTR")) { - result = ".toString()"; - } else if (nativeReturnType.equals("VT_DISPATCH")) { - // needed because he - // does - // .toDispatch() no - // matter what - // result = ".toDispatch()"; - result = ""; - } else if (nativeReturnType.equals("VT_ERROR")) { - result = ".changeType(Variant.VariantError).getError()"; - } else if (nativeReturnType.equals("VT_BOOL")) { - result = ".changeType(Variant.VariantBoolean).getBoolean()"; - } else if (nativeReturnType.equals("VT_VARIANT")) { - result = ""; - } else if (nativeReturnType.equals("VT_UNKNOWN")) { - result = ""; - } else if (nativeReturnType.equals("VT_UI1")) { - result = ".changeType(Variant.VariantByte).getByte()"; - } else if (nativeReturnType.equals("VT_HRESULT")) { - result = ".changeType(Variant.VariantInt).getInt()"; - } else if (nativeReturnType.equals("VT_SAFEARRAY")) { - result = ".toSafeArray()"; - } - - // Simple enumeration - if (Jacobgen.getInstance().isEnum(nativeReturnType)) { - result = ".changeType(Variant.VariantInt).getInt()"; - } - - // RGB VB Internal type - if (nativeReturnType.equals("MsoRGBType")) { - result = ".changeType(Variant.VariantInt).getInt()"; - } - - return result; - } - -} diff --git a/jacobgen/src/com/jacob/jacobgen/ParameterItem.java b/jacobgen/src/com/jacob/jacobgen/ParameterItem.java deleted file mode 100644 index 59f6b87..0000000 --- a/jacobgen/src/com/jacob/jacobgen/ParameterItem.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * ParameterItem.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -/** - * Represent a method parameter - * - * @version $Id$ - * @author Massimiliano Bigatti - */ -public class ParameterItem { - - private String name; - private String nativeType; - private String type; - private String objectType; - // private String arrayType; - private int direction; - private boolean optional; - private boolean object; - private boolean customType; - - public static final int DIRECTION_UNKNOWN = 0; - public static final int DIRECTION_IN = 1; - public static final int DIRECTION_OUT = 2; - public static final int DIRECTION_RETVAL = 3; - - private String[] types = { "void", "Object", "short", "int", "float", - "double", "long", "Date", "String", "Dispatch", "Error", "boolean", - "Variant", "byte" }; - - private String[] otypes = { "void", "Object", "Short", "Int", "Float", - "Double", "Long", "Date", "String", "Dispatch", "Error", "Boolean", - "Variant", "Byte" }; - - protected ParameterItem(String name, String nativeType, String type, - int direction, boolean optional) { - this.name = name.substring(0, 1).toLowerCase() + name.substring(1); - this.nativeType = nativeType; - this.type = type; - this.direction = direction; - this.optional = optional; - object = false; - - computeCustomType(); - computeObjectType(); - } - - public String getName() { - return name; - } - - /** - * Returns the name for the parameter used by the java component. If it is - * the same as a Java-Keyword it will be preceeded by a p_. - * - * @return a String which is the name of the parameter without any conflicts - * with Java-Keywords - */ - public String getJavaName() { - if (ClassGenerator.checkForJavaKeywords(this.name)) { - return "p_" + this.name; - } else { - return this.name; - } - } - - /** - * Returns the name for the parameter as it is used by the Variant-variable - * which is necessary for calls with out-parameters. - * - * @return a String which is the name of the Variant-variable of this - * parameter - */ - public String getVariantName() { - return "vnt_" + this.name; - } - - /** - * Returns the name for the put*Ref-method for this parameter as it is used - * by the Variant-variable which is necessary for calls with out-parameters. - * - * @return a String which is the name of the put*Ref-method of this - * parameter - */ - public String getVariantPutMethod() { - if (getObjectType().equals("java.util.Date")) { - return "putDateRef"; - } else { - return "put" + getObjectType() + "Ref"; - } - } - - /** - * Returns the name for the to*-method for this parameter as it is used by - * the Variant-variable which is necessary for calls with out-parameters. - * - * @return a String which is the name of the to*-method of this parameter - */ - public String getVariantGetMethod() { - if (getObjectType().equals("java.util.Date")) { - return "toJavaDate"; - } else { - return "to" + getObjectType(); - } - } - - /** - * Returns the type for the parameter as an array. - * - * @return a String which is the type of this parameter as an array - */ - public String getArrayType() { - return this.type + "[]"; - } - - /** - * Returns the type for this parameter. Also if non-basetypes are requested - * it returns ab basetye if it is a pure input parameter. - * - * @return a String which is the type of this parameter - */ - public String getType(boolean baseType) { - if (baseType || (direction == DIRECTION_IN) - || (direction == DIRECTION_UNKNOWN)) { - return getType(); - } else { - return getArrayType(); - } - } - - public String getType() { - return type; - } - - private String getObjectType() { - return objectType; - } - - public String getNativeType() { - return nativeType; - } - - public int getDirection() { - return direction; - } - - public boolean isOptional() { - return optional; - } - - public boolean isObject() { - return object; - } - - public boolean isCustomType() { - return customType; - } - - /** - * Return the method required to pass this parameter to the Dispatch call - * method. - */ - protected String getParameterCallingCode() { - String result = name; - String paramName = name; - - if (ClassGenerator.checkForJavaKeywords(name)) { - paramName = "p_" + name; - } - - result = Jacobgen.getInstance().getExternalClass(paramName) == null ? paramName - : Jacobgen.getInstance().getExternalClass(paramName); - - if (nativeType.equals("VT_EMPTY")) { - result = ""; - } else if (nativeType.equals("VT_NULL")) { - result = ""; - } else if (nativeType.equals("VT_I2")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_I4") || nativeType.equals("VT_INT")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_R4")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_R8")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_CY")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_DATE")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_BSTR")) { - result = paramName; - } else if (nativeType.equals("VT_DISPATCH")) { - result = paramName; - } else if (nativeType.equals("VT_ERROR")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_BOOL")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_HRESULT")) { - result = "new Variant(" + paramName + ")"; - } else if (nativeType.equals("VT_UNKNOWN")) { - result = paramName; - } else if (nativeType.equals("VT_UI1")) { - result = "new Variant(" + paramName + ")"; - } - - // Simple Enums - if (Jacobgen.getInstance().isEnum(nativeType)) { - result = "new Variant(" + paramName + ")"; - } - - // RGB VB Internal type - if (nativeType.equals("MsoRGBType")) { - result = "new Variant(" + paramName + ")"; - } - - return result; - } - - protected void computeCustomType() { - customType = true; - if (type.trim().length() == 0) { - customType = false; - } else { - for (int i = 0; i < types.length; i++) { - if (types[i].equals(type.trim())) { - customType = false; - break; - } - } - } - } - - protected void computeObjectType() { - for (int i = 0; i < types.length; i++) { - if (types[i].equals(type)) { - objectType = otypes[i]; - break; - } - } - - if (objectType == null) { - objectType = type; - } - } - - /** for debugging */ - public String toString() { - return name + "," + nativeType + "," + objectType + "," + otypes + "," - + type + "," + types; - - } -} diff --git a/jacobgen/src/com/jacob/jacobgen/TypeLibInspector.java b/jacobgen/src/com/jacob/jacobgen/TypeLibInspector.java deleted file mode 100644 index bc9b45b..0000000 --- a/jacobgen/src/com/jacob/jacobgen/TypeLibInspector.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * TypeLibInspector.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -/** - * The wrapper for the jni code that generates the tokenized representatation of - * the DLL that is used by the java classes to generate the stubs - * - * @version $Id$ - * - */ -public class TypeLibInspector { - - /** - * the front for the actual jni code that is the working guts of this thing - * - * @param filename - * @return - */ - public native byte[] queryInterface(String filename); - - static { - System.loadLibrary("Jacobgen"); - } - - protected static void main(String[] argv) { - byte buf[]; - - TypeLibInspector dll = new TypeLibInspector(); - - if (argv.length > 0) { - buf = dll.queryInterface(argv[0]); - - for (int i = 0; i < buf.length; i++) { - System.out.print((char) buf[i]); - } - } else { - System.out.println("TypeLibInspector "); - } - } - -} diff --git a/jacobgen/unittest/README.txt b/jacobgen/unittest/README.txt deleted file mode 100644 index f8ff79d..0000000 --- a/jacobgen/unittest/README.txt +++ /dev/null @@ -1 +0,0 @@ -This file exists to make sure this directory hangs around until there are actual sample files to put in the unittest directory \ No newline at end of file diff --git a/jacobgenPluggin/.project b/jacobgenPluggin/.project deleted file mode 100644 index ef13ee5..0000000 --- a/jacobgenPluggin/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - jacobgenPluggin - - - - - - - - diff --git a/jacobgenPluggin/JacobGeneratorEngine/.classpath b/jacobgenPluggin/JacobGeneratorEngine/.classpath deleted file mode 100644 index e76a03d..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/jacobgenPluggin/JacobGeneratorEngine/.jetproperties b/jacobgenPluggin/JacobGeneratorEngine/.jetproperties deleted file mode 100644 index 2907c83..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/.jetproperties +++ /dev/null @@ -1,4 +0,0 @@ - - - templates src - diff --git a/jacobgenPluggin/JacobGeneratorEngine/.project b/jacobgenPluggin/JacobGeneratorEngine/.project deleted file mode 100644 index c15501d..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - JacobGeneratorEngine - - - - - - org.eclipse.emf.codegen.JETBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.emf.codegen.jet.IJETNature - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/jacobgenPluggin/JacobGeneratorEngine/build.properties b/jacobgenPluggin/JacobGeneratorEngine/build.properties deleted file mode 100644 index efcc048..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = plugin.xml,\ - META-INF/,\ - .,\ - bin/,\ - lib/jacob.jar,\ - lib/junit-4.4.jar,\ - lib/log4j-1.2.15.jar diff --git a/jacobgenPluggin/JacobGeneratorEngine/jacob.dll b/jacobgenPluggin/JacobGeneratorEngine/jacob.dll deleted file mode 100755 index e4e6350..0000000 Binary files a/jacobgenPluggin/JacobGeneratorEngine/jacob.dll and /dev/null differ diff --git a/jacobgenPluggin/JacobGeneratorEngine/jacobgen.dll b/jacobgenPluggin/JacobGeneratorEngine/jacobgen.dll deleted file mode 100755 index 32a766e..0000000 Binary files a/jacobgenPluggin/JacobGeneratorEngine/jacobgen.dll and /dev/null differ diff --git a/jacobgenPluggin/JacobGeneratorEngine/lib/jacob.jar b/jacobgenPluggin/JacobGeneratorEngine/lib/jacob.jar deleted file mode 100755 index adbba83..0000000 Binary files a/jacobgenPluggin/JacobGeneratorEngine/lib/jacob.jar and /dev/null differ diff --git a/jacobgenPluggin/JacobGeneratorEngine/lib/junit-4.4.jar b/jacobgenPluggin/JacobGeneratorEngine/lib/junit-4.4.jar deleted file mode 100755 index 649b0b3..0000000 Binary files a/jacobgenPluggin/JacobGeneratorEngine/lib/junit-4.4.jar and /dev/null differ diff --git a/jacobgenPluggin/JacobGeneratorEngine/lib/log4j-1.2.15.jar b/jacobgenPluggin/JacobGeneratorEngine/lib/log4j-1.2.15.jar deleted file mode 100755 index c930a6a..0000000 Binary files a/jacobgenPluggin/JacobGeneratorEngine/lib/log4j-1.2.15.jar and /dev/null differ diff --git a/jacobgenPluggin/JacobGeneratorEngine/plugin.properties b/jacobgenPluggin/JacobGeneratorEngine/plugin.properties deleted file mode 100644 index c65c155..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/plugin.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# -# -# $Id$ - -# ==================================================================== -# To code developer: -# Do NOT change the properties between this line and the -# "%%% END OF TRANSLATED PROPERTIES %%%" line. -# Make a new property name, append to the end of the file and change -# the code to use the new property. -# ==================================================================== - -# ==================================================================== -# %%% END OF TRANSLATED PROPERTIES %%% -# ==================================================================== - -pluginName = Company Model -providerName = www.example.org diff --git a/jacobgenPluggin/JacobGeneratorEngine/plugin.xml b/jacobgenPluggin/JacobGeneratorEngine/plugin.xml deleted file mode 100644 index 4640f90..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/plugin.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java b/jacobgenPluggin/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java deleted file mode 100755 index d6ba0c8..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/com/jacob/jacobgen/TypeLibInspector.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * TypeLibInspector.java - * Copyright (C) 2000-2002 Massimiliano Bigatti - * 2007 modified by Robert Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.jacob.jacobgen; - -/** - * The wrapper for the jni code that generates the tokenized representatation of - * the DLL that is used by the java classes to generate the stubs - * - * @version $Id$ - * - */ -public class TypeLibInspector { - - static { - System.loadLibrary("Jacobgen"); - } - - public static void main(final String[] argv) { - byte buf[]; - - final TypeLibInspector dll = new TypeLibInspector(); - - if (argv.length > 0) { - buf = dll.queryInterface(argv[0]); - - for (int i = 0; i < buf.length; i++) { - System.out.print((char) buf[i]); - } - } else { - System.out.println("TypeLibInspector "); - } - } - - /** - * the front for the actual jni code that is the working guts of this thing - * - * @param filename - * @return - */ - public native byte[] queryInterface(String filename); - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java deleted file mode 100755 index a664aa3..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TLBtoECOREtoCODE.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.LineNumberReader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterEnumerator; -import net.sourceforge.jacob.generator.adapters.AdapterEnumeratorValues; -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; -import net.sourceforge.jacob.generator.adapters.BaseAdapter; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClass; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassExtends; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassGUID; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassMethod; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassPropertyGet; -import net.sourceforge.jacob.generator.adapters.classInfo.AdapterClassPropertyPut; - -import org.apache.log4j.Logger; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; - -import com.jacob.jacobgen.TypeLibInspector; - -public class TLBtoECOREtoCODE { - private final String fileLocation ; - - private final static Logger log = Logger.getLogger(TLBtoECOREtoCODE.class); - - private AdapterClass classAdapter; - - private AdapterEnumerator classEnumeration; - private EPackage companyPackage = null; - private final java.util.List firstPassCommands = new ArrayList(); - private final EPackage superPackage = EcoreFactory.eINSTANCE.createEPackage(); - private final String typelibFilename; - - public TLBtoECOREtoCODE(final String destinationPackage, final String typelibFilename, final String fileLocation) { - this.typelibFilename = typelibFilename; - this.fileLocation = fileLocation; - - // create a package that represents company - final StringTokenizer packageTokenizer = new StringTokenizer(destinationPackage.trim(), "."); - final String superPackageName = packageTokenizer.nextToken(); - - superPackage.setName(superPackageName); - superPackage.setNsPrefix(superPackageName + "NS"); - superPackage.setNsURI("http://generator.jacob.sourceforge.net/" + superPackageName); - - if (packageTokenizer.countTokens() > 1) { - EPackage sup = superPackage; - EPackage sub = superPackage; - while (packageTokenizer.hasMoreTokens()) { - sup = sub; - final String subPackageName = packageTokenizer.nextToken(); - sub = AdapterUtilities.createSubPackage(sup, subPackageName); - } - companyPackage = sub; - } else { - companyPackage = superPackage; - } - } - - private void addAttributesParameters(final LineNumberReader lnr) throws IOException { - String firstLine = lnr.readLine();// skip TYPELIB - firstLine = lnr.readLine(); - EClass classModel = null; - EEnum enumModel = null; - while (firstLine != null) { - firstLine = firstLine.trim(); - log.debug(firstLine); - boolean accepted = false; - if (classAdapter.isAccepted(firstLine)) { - classModel = null; - enumModel = null; - accepted = true; - classModel = classAdapter.getCreateClass(); - } else if (classEnumeration.isAccepted(firstLine)) { - classModel = null; - enumModel = null; - accepted = true; - enumModel = classEnumeration.getCreateEEnum(); - } else { - for (final BaseAdapter typesAdapter : firstPassCommands) { - accepted = typesAdapter.isAccepted(firstLine); - if (accepted) { - classModel = null; - enumModel = null; - break; - } - } - if ((null != enumModel) && (false == accepted)) { - // FIXME does an Enum have a GUID??? - accepted = firstLine.startsWith("GUID;{"); - - } - if ((null != classModel) && (false == accepted)) { // method or - // attribute - final List secondPassCommands = new ArrayList(); - secondPassCommands.clear(); - secondPassCommands.add(new AdapterClassMethod(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassPropertyGet(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassPropertyPut(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassExtends(companyPackage, classModel)); - secondPassCommands.add(new AdapterClassGUID(companyPackage, classModel)); - for (final BaseAdapter command : secondPassCommands) { - accepted = command.isAccepted(firstLine); - if (accepted) { - command.process(firstLine); - break; - } - } - } - - } - if (false == accepted) { - log.fatal("Problem with \t'" + firstLine + "'"); - System.exit(-1); - } - firstLine = lnr.readLine(); - } - } - - /** - * @see http://www.devx.com/Java/Article/29093/1954?pf=true - * @throws FileNotFoundException - * @throws IOException - */ - public void generate() throws FileNotFoundException, IOException { - // readFile(typelibFilename); - final TypeLibInspector lib = new TypeLibInspector(); - assert null != typelibFilename; - final byte[] queryInterface = lib.queryInterface(typelibFilename); - System.out.flush(); - System.err.flush(); - final String st = new String(queryInterface); - final String typeLib = new LineNumberReader(new StringReader(st)).readLine().substring("TYPELIB ".length()).trim(); - - { - final String subPackageName = typeLib; - companyPackage = AdapterUtilities.createSubPackage(companyPackage, subPackageName); - } - - packageAdapatersFactory(); - structureOnly(new LineNumberReader(new StringReader(st))); - - addAttributesParameters(new LineNumberReader(new StringReader(st))); - save(superPackage); - - final File xmiFile = new File(fileLocation + ".xmi"); - final File ecoreFile = new File(fileLocation + ".ecore"); - if (ecoreFile.exists()) - ecoreFile.delete(); - xmiFile.renameTo(ecoreFile); - } - - private void packageAdapatersFactory() { - firstPassCommands.clear(); - classAdapter = new AdapterClass(companyPackage); - firstPassCommands.add(classAdapter); - classEnumeration = new AdapterEnumerator(companyPackage); - firstPassCommands.add(classEnumeration); - firstPassCommands.add(new AdapterEnumeratorValues(companyPackage, classEnumeration)); - } - - private void save(final EObject company) throws IOException { - // create resource set and resource - final ResourceSet resourceSet = new ResourceSetImpl(); - - // Register XML resource factory - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); - - final Resource resource = resourceSet.createResource(URI.createFileURI(fileLocation + ".xmi")); - // add the root object to the resource - resource.getContents().add(company); - // serialize resource – you can specify also serialization - // options which defined on org.eclipse.emf.ecore.xmi.XMIResource - resource.save(null); - } - - private void structureOnly(final LineNumberReader lnr) throws IOException { - String firstLine; - do { - firstLine = lnr.readLine(); - boolean accepted = false; - for (final BaseAdapter command : firstPassCommands) { - accepted = command.isAccepted(firstLine); - if (accepted) { - command.process(firstLine); - break; - } - } - } while (firstLine != null); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java deleted file mode 100755 index 317dbdf..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/TestGenerator.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.apache.log4j.Logger; - -/** - * This is the root class for Jacobgen. It generates Jacob wrapper class for - * windows DLLs. Run this class with no command line parameters to get a list of - * the valid command line options - * - * - * %JRE% -Xint com.jacob.jacobgen.Jacobgen %1 %2 %3 %4 %5 - * - * - * @version $Id$ - * @author Robert Searle - */ -public class TestGenerator { - final static private Logger log = Logger.getLogger(TestGenerator.class); - - public static void main(final String[] args) { - org.apache.log4j.BasicConfigurator.configure(); - - if (args.length == 0) { - System.out.println("JacobGen [options] typelibfile\n"); - System.out.println("Options:"); - System.out.println("\t-package:"); - System.out.println(); - System.exit(0); - } else { - final TestGenerator g = new TestGenerator(args); - g.parseOptions(args); - if (g.typelibFilename == null) { - System.out.println("Jacobgen you need to specify an input file"); - } else { - final TLBtoECOREtoCODE gener = new TLBtoECOREtoCODE(g.destinationPackage, g.typelibFilename, "model/company"); - try { - gener.generate(); - } catch (final FileNotFoundException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final IOException e) { - System.out.flush(); - e.printStackTrace(); - } - System.out.println("Done"); - } - System.exit(0); - } - } - - String destinationPackage; - - String typelibFilename; - - public TestGenerator(final String[] args) { - parseOptions(args); - } - - private void parseOptions(final String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].startsWith("-package:")) { - destinationPackage = args[i].substring("-package:".length()); - } else { - typelibFilename = args[i]; - } - } - log.debug("destinationPackage = '" + destinationPackage + "'"); - log.debug("typelibFilename = '" + typelibFilename + "'"); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java deleted file mode 100755 index 013499f..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumerator.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterEnumerator extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterEnumerator.class); - private EEnum createEEnum; - private String enumName; - - public AdapterEnumerator(final EPackage companyPackage) { - super("CLASS ", companyPackage); - } - - public EEnum getCreateEEnum() { - assert null != createEEnum; - return createEEnum; - } - - @Override - public boolean isAccepted(final String line) { - if (!super.isAccepted(line)) { - return false; - } - final StringTokenizer st = new StringTokenizer(line.substring(begining().length()).trim(), ";"); - if (st.countTokens() != 2) { - return false; - } - enumName = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final String parameters = st.nextToken().trim(); - return "TKIND_ENUM".equals(parameters); - } - - @Override - public void process(final String textLine) { - log.debug(enumName); - createEEnum = EcoreFactory.eINSTANCE.createEEnum(); - createEEnum.setName(enumName); - companyPackage.getEClassifiers().add(createEEnum); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java deleted file mode 100755 index 0195315..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterEnumeratorValues.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EEnumLiteral; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterEnumeratorValues extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterEnumeratorValues.class); - private final AdapterEnumerator enumerationClass; - - public AdapterEnumeratorValues(final EPackage companyPackage, final AdapterEnumerator enumerationClass) { - super("VAR_CONST;", companyPackage); - this.enumerationClass = enumerationClass; - } - - @Override - public void process(final String textLine) { - /* - * VAR_CONST;wbemImpersonationLevelAnonymous;VT_I4;1 - * VAR_CONST;wbemImpersonationLevelIdentify;VT_I4;2 - * VAR_CONST;wbemImpersonationLevelImpersonate;VT_I4;3 - * VAR_CONST;wbemImpersonationLevelDelegate;VT_I4;4 - */ - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String name = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - final int ordal = Integer.parseInt(st.nextToken().trim()); - final EEnumLiteral createEEnumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral(); - createEEnumLiteral.setValue(ordal); - createEEnumLiteral.setName(name); - createEEnumLiteral.setLiteral(name); - - enumerationClass.getCreateEEnum().getELiterals().add(createEEnumLiteral); - } - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java deleted file mode 100755 index 2426cbe..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/AdapterUtilities.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EParameter; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.EcorePackage; - -import com.jacob.com.Dispatch; -import com.jacob.com.Variant; - -public class AdapterUtilities { - private static EPackage comJacobComPackage; - - final public static Set ignoreAttributeList = new HashSet(); - - final static private Logger log = Logger.getLogger(AdapterUtilities.class); - static final public String UNDERSCORE_REPLACEMENT = "JACOB"; - private static EDataType vtDispatchType = null; - - private static EDataType vtVariantType = null; - - static { - ignoreAttributeList.add("defaultValue"); // FIXME Is it safe to - // ignore this? - ignoreAttributeList.add("DefaultValue"); // FIXME Is it safe to - // ignore this? - ignoreAttributeList.add("Name"); // FIXME Is it safe to ignore this? - ignoreAttributeList.add("_NewEnum"); // FIXME Is it safe to ignore - // this? - ignoreAttributeList.add(""); - ignoreAttributeList.add(null); - } - - public static String changeUnderscoredName(String className) { - className = className.trim(); - if (className.startsWith("_")) { // FIXME - className = AdapterUtilities.UNDERSCORE_REPLACEMENT + className; - } - return className; - } - - public static EStructuralFeature createAttribute(final String type, final String name, final EPackage companyPackage, final EClass classModel) { - final EClassifier classifier; - classifier = getClassifier(type, companyPackage); - if (classifier instanceof EClass) { - // Attribute is a different class - final EReference createEReference = EcoreFactory.eINSTANCE.createEReference(); - createEReference.setChangeable(false); - createEReference.setVolatile(true); - createEReference.setDerived(true); - createEReference.setName(name); - createEReference.setEType(classifier); - classModel.getEStructuralFeatures().add(createEReference); - return createEReference; - } else { - // Basic Attribute. - final EAttribute createEAttribute = AdapterUtilities.createEAttribute(name, classifier); - assert (null != classifier); - classModel.getEStructuralFeatures().add(createEAttribute); - return createEAttribute; - } - } - - public static EAttribute createEAttribute(final String name, final EClassifier classifier) { - final EAttribute createEAttribute = EcoreFactory.eINSTANCE.createEAttribute(); - createEAttribute.setDerived(true); // no need for a class attribute - createEAttribute.setTransient(true); - createEAttribute.setVolatile(true); - createEAttribute.setChangeable(false); - createEAttribute.setName(name); - createEAttribute.setEType(classifier); - return createEAttribute; - } - - public static void createMethod(final String textLine, final String returnType, final String functionName, final String parameters, final EPackage companyPackage, - final EClass classModel) { - log.debug(classModel.getName() + "\t" + functionName); - final EOperation method = EcoreFactory.eINSTANCE.createEOperation(); - final EClassifier classifier = AdapterUtilities.getClassifier(returnType, companyPackage); - method.setEType(classifier); - method.setName(functionName); - classModel.getEOperations().add(method); - - final String substring = parameters.substring(1, parameters.length() - 1); - log.debug("\t" + substring); - if (substring.length() != 0) { - final StringTokenizer paramterTokens = new StringTokenizer(substring, ","); - do { - final String paramterValues = paramterTokens.nextToken().trim(); - log.debug("\t\t" + paramterValues); - final StringTokenizer paramterToken = new StringTokenizer(paramterValues, ",} "); - - final String inOut; - final String type; - final String name; - if (paramterToken.countTokens() == 3) { - inOut = paramterToken.nextToken().trim(); - type = paramterToken.nextToken().trim(); - name = paramterToken.nextToken().trim(); - } else if (paramterToken.countTokens() == 2) { - inOut = null; - type = paramterToken.nextToken().trim(); - name = paramterToken.nextToken().trim(); - } else { - // log.error(paramterValues); - throw new RuntimeException("Could not process this line" + textLine); - } - - final EParameter createEParameter = EcoreFactory.eINSTANCE.createEParameter(); - createEParameter.setName(name); - - final EClassifier parameterClassifier = AdapterUtilities.getClassifier(type, companyPackage); - createEParameter.setEType(parameterClassifier); - method.getEParameters().add(createEParameter); - } while (paramterTokens.hasMoreTokens()); - } - }; - - /** - * @param packageTokenizer - * @param sup - * @param subPackageName - * @return - */ - public static EPackage createSubPackage(final EPackage sup, final String subPackageName) { - EPackage sub; - sub = EcoreFactory.eINSTANCE.createEPackage(); - sub.setName(subPackageName); - sub.setNsPrefix(subPackageName + "NS"); - sub.setNsURI("http://generator.jacob.sourceforge.net/" + subPackageName); - sup.getESubpackages().add(sub); - return sub; - } - - /** - * - * @param returnType - * @param companyPackage - * @return - */ - public static EClassifier getClassifier(final String returnType, final EPackage companyPackage) { - final EClassifier classifier; - - /* - * Eclipse Development using the Graphical Editing Framework and the - * Eclipse Modeling Framework - * - * Declaring datatypes EMF provides datatypes such as EString and EInt, - * which represent the basic Java types that you can use for simple - * attributes. If you need to use a different Java type, you need to - * create an EDataType to represent it. For example, we use EString to - * represent attributes such as condition of ConditionalOutputPort and - * whileCondition for LoopTask from the WorkflowModel for the sample - * application. If we wanted to represent these conditions with a - * specific existing Java type instead, we would declare an EDataType - * corresponding to that type, as follows: - */ - - if ("VT_VOID".equals(returnType)) { - classifier = null; - } else if ("VT_BOOL".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEBoolean(); - } else if ("VT_UI2".equals(returnType) || "VT_UINT".equals(returnType) || "VT_INT".equals(returnType) || "VT_UI4".equals(returnType) || "VT_I4".equals(returnType) - || "VT_HRESULT".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEInt(); - } else if ("VT_R4".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEFloat(); - } else if ("VT_R8".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEDouble(); - } else if ("VT_DATE".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEDate(); - } else if ("VT_BSTR".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEString(); - } else if ("GUID".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getELong(); - } else if ("VT_UNKNOWN".equals(returnType) || "EXCEPINFO".equals(returnType) || "DISPPARAMS".equals(returnType)) { - classifier = EcorePackage.eINSTANCE.getEObject(); - } else { - if ("VT_VARIANT".equals(returnType)) { - classifier = getVariant(companyPackage); - } else if ("VT_PTR".equals(returnType)) { - // FIXME Is a VT_PTR really a object? - classifier = EcorePackage.eINSTANCE.getEJavaObject(); - } else if ("IDispatch".equals(returnType) || "Dispatch".equals(returnType) || "VT_DISPATCH".equals(returnType)) { - classifier = getDispatch(companyPackage); - } else { - final EClassifier possibleValue = companyPackage.getEClassifier(returnType); - if (possibleValue == null) { - log.warn(returnType + "\t" + "Cannot be mapped"); - classifier = EcorePackage.eINSTANCE.getEJavaObject(); - } else - classifier = possibleValue; - } - } - return classifier; - } - - private static EPackage getComJacobComPackage(final EPackage companyPackage) { - if (null == comJacobComPackage) { - EPackage comPackage = companyPackage; - while (!comPackage.getName().equals("com")) { - comPackage = comPackage.getESuperPackage(); - } - final EPackage comJacobPackage = EcoreFactory.eINSTANCE.createEPackage(); - comJacobPackage.setName("jacob"); - comJacobPackage.setNsPrefix("jacob2" + "NS"); - comJacobPackage.setNsURI("http://generator.jacob.sourceforge.net/" + "jacob2"); - comPackage.getESubpackages().add(comJacobPackage); - - comJacobComPackage = EcoreFactory.eINSTANCE.createEPackage(); - comJacobComPackage.setName("com"); - comJacobComPackage.setNsPrefix("com2" + "NS"); - comJacobComPackage.setNsURI("http://generator.jacob.sourceforge.net/" + "com2"); - comJacobPackage.getESubpackages().add(comJacobComPackage); - } - return comJacobComPackage; - } - - public static EDataType getDispatch(final EPackage companyPackage) { - if (vtDispatchType == null) { - vtDispatchType = EcoreFactory.eINSTANCE.createEDataType(); - final Class dispatchClass = Dispatch.class; - vtDispatchType.setInstanceClassName(dispatchClass.getCanonicalName()); - vtDispatchType.setInstanceClass(dispatchClass); - vtDispatchType.setName(dispatchClass.getSimpleName()); - getComJacobComPackage(companyPackage).getEClassifiers().add(vtDispatchType); - } - return vtDispatchType; - } - - static public Set getIgnoreAttributeList() { - return ignoreAttributeList; - } - - public static EDataType getVariant(final EPackage companyPackage) { - if (vtVariantType == null) { - vtVariantType = EcoreFactory.eINSTANCE.createEDataType(); - final Class variantClass = Variant.class; - vtVariantType.setInstanceClassName(variantClass.getCanonicalName()); - vtVariantType.setInstanceClass(variantClass); - vtVariantType.setName(variantClass.getSimpleName()); - - getComJacobComPackage(companyPackage).getEClassifiers().add(vtVariantType); - } - return vtVariantType; - } - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java deleted file mode 100755 index c372823..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/BaseAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters; - -import org.eclipse.emf.ecore.EPackage; - -public abstract class BaseAdapter { - protected final EPackage companyPackage; - final private String TEXT; - - public BaseAdapter(final String text, final EPackage companyPackage) { - this.TEXT = text; - this.companyPackage = companyPackage; - } - - public String begining() { - return TEXT; - } - - public boolean isAccepted(final String line) { - if (line == null) { - return false; - } - if (line.length() < begining().length()) { - return false; - } - return line.startsWith(begining()); - } - - abstract public void process(final String textLine); -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java deleted file mode 100755 index 24f852c..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClass.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; -import net.sourceforge.jacob.generator.adapters.BaseAdapter; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; - -public class AdapterClass extends BaseAdapter { - final static private Logger log = Logger.getLogger(AdapterClass.class); - private String className; - private EClass createClass; - private EPackage implPackage; - private boolean isInterface; - - public AdapterClass(final EPackage companyPackage) { - super("CLASS ", companyPackage); - assert null != companyPackage; - } - - public EClass getCreateClass() { - assert null != createClass; - return createClass; - } - - @Override - public boolean isAccepted(final String line) { - if (!super.isAccepted(line)) { - return false; - } - final StringTokenizer st = new StringTokenizer(line.substring(begining().length()).trim(), ";"); - if (st.countTokens() != 2) { - return false; - } - className = st.nextToken().trim(); - className = AdapterUtilities.changeUnderscoredName(className); - final String parameters = st.nextToken().trim(); - isInterface = "TKIND_DISPATCH".equals(parameters) || "TKIND_INTERFACE".equals(parameters); - final boolean isClass = "TKIND_COCLASS".equals(parameters) || isInterface; - if (isClass) { - log.debug(className); - createClass = (EClass) companyPackage.getEClassifier(className); - } else - createClass = null; - return isClass; - } - - @Override - public void process(final String textLine) { - createClass = null; - createClass = EcoreFactory.eINSTANCE.createEClass(); - createClass.setInterface(isInterface); - createClass.setAbstract(isInterface); - createClass.setName(className); - log.debug(className + "\t Yes its an interface: " + isInterface); - if (isInterface) { - companyPackage.getEClassifiers().add(createClass); - final EClass createClass2 = EcoreFactory.eINSTANCE.createEClass(); - createClass2.setInterface(false); - createClass2.setAbstract(false); - createClass2.getESuperTypes().add(createClass); - createClass2.setName(className); - - final EStructuralFeature createAttribute2 = AdapterUtilities.createAttribute("Dispatch", "Dispatch", companyPackage, createClass2); - createAttribute2.setDerived(false); - createAttribute2.setChangeable(true); - createAttribute2.setVolatile(false); - if (companyPackage.getESubpackages().size() == 0) { - implPackage = AdapterUtilities.createSubPackage(companyPackage, "jacobimpl"); - } - implPackage.getEClassifiers().add(createClass2); - } else { - final EStructuralFeature createAttribute = AdapterUtilities.createAttribute("Dispatch", "Dispatch", companyPackage, createClass); - createAttribute.setDerived(false); - createAttribute.setChangeable(true); - createAttribute.setVolatile(false); - companyPackage.getEClassifiers().add(createClass); - } - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java deleted file mode 100755 index 60f4b88..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassExtends.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; - -public class AdapterClassExtends extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassExtends.class); - - public AdapterClassExtends(final EPackage companyPackage, final EClass classModel) { - super("EXTENDS;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String superClass = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - - log.debug("\t" + superClass); - EClass classifier = (EClass) companyPackage.getEClassifier(superClass); - assert (classifier != null); - if ("IDispatch".equals(superClass)) { - final EClassifier disClassifier = AdapterUtilities.getClassifier(superClass, companyPackage); - classifier = disClassifier.eClass(); - } - assert (classifier != null); - if (classifier != null) - classModel.getESuperTypes().add(classifier); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java deleted file mode 100755 index c84b694..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassGUID.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; - -public class AdapterClassGUID extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassGUID.class); - - public AdapterClassGUID(final EPackage companyPackage, final EClass classModel) { - super("GUID;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - if (classModel.isInterface()) - return; - // FIXME Nothing is done with the GUID!! - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String classGUID = st.nextToken(); - log.debug("\t" + classGUID); - final EAttribute guidEAttribute = AdapterUtilities.createEAttribute( // FIXME - "_GUID", EcorePackage.eINSTANCE.getEString()); - guidEAttribute.setDerived(false); // no need for a class attribute - guidEAttribute.setTransient(false); - guidEAttribute.setVolatile(false); - guidEAttribute.setChangeable(false); - guidEAttribute.setDefaultValue(classGUID); - classModel.getEStructuralFeatures().add(guidEAttribute); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java deleted file mode 100755 index 9b0ed81..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassMethod.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; - -public class AdapterClassMethod extends BaseAdapterClass { - final static Set ignoreList = new HashSet(); - final static private Logger log = Logger.getLogger(AdapterClassMethod.class); - - static { - ignoreList.add("QueryInterface"); - ignoreList.add("AddRef"); - ignoreList.add("Release"); - ignoreList.add("GetTypeInfoCount"); - ignoreList.add("GetTypeInfo"); - ignoreList.add("GetIDsOfNames"); - ignoreList.add("Invoke"); - ignoreList.add(""); - ignoreList.add(null); - }; - - public AdapterClassMethod(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_FUNC;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - // log.debug(textLine); - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String returnType = st.nextToken().trim(); - final String functionName = st.nextToken().trim(); - final String parameters = st.nextToken().trim(); - - if (!ignoreList.contains(functionName)) { - AdapterUtilities.createMethod(textLine, returnType, functionName, parameters, companyPackage, classModel); - } - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java deleted file mode 100755 index 2de92cc..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyGet.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; - -public class AdapterClassPropertyGet extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassPropertyGet.class); - - public AdapterClassPropertyGet(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_PROPERTYGET;", companyPackage, classModel); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine.substring(begining().length()).trim(), ";"); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - String name = st.nextToken().trim(); - final String inOut = st.nextToken().trim(); - log.debug(classModel.getName() + "\t" + name + "\t" + type + "\t" + inOut); - if (inOut.startsWith("[")) { - log.warn(inOut); - } - - if (AdapterUtilities.getIgnoreAttributeList().contains(name)) {// FIXME - log.warn("Can not add '" + name + "' to" + classModel.getName()); - return; - } - name = AdapterUtilities.changeUnderscoredName(name); - - final EStructuralFeature structuralFeature = classModel.getEStructuralFeature(name); - - if (!"[]".equals(inOut)) { - // Could already exist because of put - if (null == structuralFeature) { - final EStructuralFeature createAttribute = AdapterUtilities.createAttribute(type, name, companyPackage, classModel); - } - AdapterUtilities.createMethod(textLine, type, "get" + name, inOut, companyPackage, classModel); - } else { - AdapterUtilities.createAttribute(type, name, companyPackage, classModel); - } - } - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java deleted file mode 100755 index 0f85d84..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/AdapterClassPropertyPut.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import java.util.StringTokenizer; - -import net.sourceforge.jacob.generator.adapters.AdapterUtilities; - -import org.apache.log4j.Logger; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; - -public class AdapterClassPropertyPut extends BaseAdapterClass { - final static private Logger log = Logger.getLogger(AdapterClassPropertyPut.class); - - public AdapterClassPropertyPut(final EPackage companyPackage, final EClass classModel) { - super("INVOKE_PROPERTYPUT;", companyPackage, classModel); - } - - /* - * (non-Javadoc) - * - * @see net.sourceforge.jacob.generator.adapters.BaseAdapter#isAccepted(java.lang.String) - */ - @Override - public boolean isAccepted(final String line) { - if (super.isAccepted(line)) - return true; - else - return line.startsWith("INVOKE_PROPERTYPUTREF;"); - } - - @Override - public void process(final String textLine) { - final StringTokenizer st = new StringTokenizer(textLine, ";"); - final String value = st.nextToken().trim(); - final String type = AdapterUtilities.changeUnderscoredName(st.nextToken().trim()); - String name = st.nextToken().trim(); - log.debug(classModel.getName() + "\t" + name + "\t" + type); - if (AdapterUtilities.getIgnoreAttributeList().contains(name)) {// FIXME - log.warn("Can not add '" + name + "' to" + classModel.getName()); - return; - } - name = AdapterUtilities.changeUnderscoredName(name); - - EStructuralFeature structuralFeature = classModel.getEStructuralFeature(name); - if (null == structuralFeature) { - log.fatal("Attribute\t" + name); - final EClassifier classifier = AdapterUtilities.getDispatch(companyPackage); -// final EClassifier classifier = AdapterUtilities.getClassifier(type, companyPackage); - structuralFeature = AdapterUtilities.createEAttribute(name, classifier); - structuralFeature.setChangeable(false); - structuralFeature.setVolatile(true); - structuralFeature.setDerived(true); - classModel.getEStructuralFeatures().add(structuralFeature); - } - structuralFeature.setChangeable(true); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java b/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java deleted file mode 100755 index 518ba74..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/net/sourceforge/jacob/generator/adapters/classInfo/BaseAdapterClass.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package net.sourceforge.jacob.generator.adapters.classInfo; - -import net.sourceforge.jacob.generator.adapters.BaseAdapter; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; - -public abstract class BaseAdapterClass extends BaseAdapter { - protected final EClass classModel; - - public BaseAdapterClass(final String text, final EPackage companyPackage, final EClass classModel) { - super(text, companyPackage); - this.classModel = classModel; - } - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/plug/Activator.java b/jacobgenPluggin/JacobGeneratorEngine/src/plug/Activator.java deleted file mode 100644 index cb0f744..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/plug/Activator.java +++ /dev/null @@ -1,61 +0,0 @@ -package plug; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "PLUG"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java b/jacobgenPluggin/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java deleted file mode 100644 index 6315df7..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/src/plug/popup/actions/NewAction.java +++ /dev/null @@ -1,72 +0,0 @@ -package plug.popup.actions; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URI; - -import net.sourceforge.jacob.generator.TLBtoECOREtoCODE; - -import org.eclipse.core.internal.resources.File; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -public class NewAction implements IObjectActionDelegate { - - private URI rawLocationURI; - - /** - * Constructor for Action1. - */ - public NewAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { -// Shell shell = new Shell(); -// IMenuCreator menuCreator = action.getMenuCreator(); - try { - java.io.File file = new java.io.File (rawLocationURI); - String output = file.getParent() + file.separatorChar + "model/company"; - final TLBtoECOREtoCODE gener = new TLBtoECOREtoCODE("com.sourceforge.jacobGenerated", file.getAbsolutePath(), output); - gener.generate(); - } catch (RuntimeException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final FileNotFoundException e) { - System.out.flush(); - e.printStackTrace(); - } catch (final IOException e) { - System.out.flush(); - e.printStackTrace(); - } - System.out.println("Done"); - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - System.out.println("NewAction.selectionChanged()"); - TreeSelection treeSelection= (TreeSelection)selection; - Object firstElement2 = treeSelection.getFirstElement(); - System.out.println(firstElement2.getClass()); - File firstElement = (File) firstElement2; - rawLocationURI = firstElement.getRawLocationURI(); - } - -} diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/Header.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/Header.javajetinc deleted file mode 100755 index 0c43fe7..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/Header.javajetinc +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This file is auto generated. DO NOT ALTER IT!!! - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc deleted file mode 100755 index 11837ae..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/basicGetGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,66 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//basicGetGenFeature.TODO.override.javajetinc - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.get(dispatchComponent, funcName); - <% - String className = genFeature.getImportedType(genClass); - if (className.lastIndexOf('.')>0){ - className = className.substring(className.lastIndexOf('.')+1); - } - final org.eclipse.emf.ecore.EClass classifier; - if (genPackage.getEcorePackage().getName().equals("jacobimpl")) - classifier = (org.eclipse.emf.ecore.EClass) genPackage.getEcorePackage().getESuperPackage().getEClassifier(className); - else - classifier = (org.eclipse.emf.ecore.EClass) genPackage.getEcorePackage().getEClassifier(className); - - if ( null == classifier ) { - %> - //there is no class name here <%= className %> - return retInvoke.toJavaObject(); - <% } else if ( classifier.isInterface()) { - String classType = null; - classType = genFeature.getType().trim(); - final int lastIndexOf = classType.lastIndexOf('.'); - classType = classType.substring(0, lastIndexOf) + ".jacobimpl" + classType.substring(lastIndexOf); - %> - //is an interface <%= genFeature.getImportedType(genClass) %> - final <%= classType %> retVal = new <%= classType %>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } else { %> - //is a class - final <%=genFeature.getType().trim()%> retVal = new <%=genFeature.getType().trim()%>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } %> - - diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc deleted file mode 100755 index 750a3b0..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/getGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,70 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - - -//getGenFeature.TODO.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.get(dispatchComponent, funcName); - -<%@ include file="returnTypes.javajetinc" %> -<% - final String returnType = genFeature.getType().trim(); - final String func = map.get(returnType); - - if ("void".equals(returnType) ){ - } else if (null != func) { - stringBuffer.append("\n\t\treturn retInvoke"); - stringBuffer.append(func); - stringBuffer.append(";"); - } else if ("com.jacob.com.Variant".equals(returnType) ) { - stringBuffer.append("\n\t\treturn retInvoke;"); - } else if (genFeature.isEnumType()) { - stringBuffer.append("\n\t\tfinal int int1 = retInvoke.getInt();"); - stringBuffer.append("\n\t\treturn " + returnType + ".get(int1);"); - - } else { - stringBuffer.append("\n\t\treturn ("); - stringBuffer.append(returnType); - stringBuffer.append(")retInvoke."); - stringBuffer.append("toJavaObject();"); - } - stringBuffer.append("\n"); -%> diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc deleted file mode 100755 index eb76554..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/implementedGenOperation.todo.override.javajetinc +++ /dev/null @@ -1,136 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//implementedGenOperation.todo.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - -<% -final int wFlags; -String funcName = genOperation.getName().trim(); - if (funcName.startsWith("get")){ - funcName = funcName.substring(3); - wFlags = 2 ;/*com.jacob.com.Dispatch.Get;*/ - } else { - wFlags = 1 ;/*com.jacob.com.Dispatch.Method;*/ - } -%> -final int wFlags = <%= wFlags %>; - - - String funcName = "<% -if (funcName.startsWith("JACOB")) - stringBuffer.append(funcName.substring("JACOB".length())); -else - stringBuffer.append(funcName); -%>"; - - -<%@ include file="returnTypes.javajetinc" %> -<% -{ - final org.eclipse.emf.codegen.ecore.genmodel.GenOperation i = genOperation; - final org.eclipse.emf.common.util.EList genParameters = i.getGenParameters(); - - if (0 == genParameters.size()){ - stringBuffer.append("final com.jacob.com.Variant o[] = new com.jacob.com.Variant[0];"); - stringBuffer.append("final int uArgErr[] = new int[0];"); - } else { - stringBuffer.append("final int uArgErr[] = new int["+genParameters.size()+"];"); - stringBuffer.append("final com.jacob.com.Variant o[] = new com.jacob.com.Variant[]{"); - for (int j = 0; j < genParameters.size(); j++) { - final GenParameter genParameter = genParameters.get(j); - if (j !=0) - stringBuffer.append(" ,"); - if (genParameter.getType().trim().equals("com.jacob.com.Variant")){ - stringBuffer.append(genParameter.getName()); - }else { - stringBuffer.append(" new com.jacob.com.Variant("); - stringBuffer.append(genParameter.getName()); - stringBuffer.append(")"); - } - } - stringBuffer.append("};"); - } - stringBuffer.append("\n"); -} - final String returnType = genOperation.getType().trim(); - - final String func = map.get(returnType); -%> - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); - final com.jacob.com.Variant retInvoke = com.jacob.com.Dispatch.invoke(dispatchComponent, funcName, wFlags, o, uArgErr); - - <% - String className = returnType; - if (className.lastIndexOf('.')>0){ - className = className.substring(className.lastIndexOf('.')+1); - } - final org.eclipse.emf.ecore.EClass classifier; - if (genPackage.getEcorePackage().getName().equals("jacobimpl")){ - org.eclipse.emf.ecore.EClassifier classifier2 = null; - classifier2 = genPackage.getEcorePackage().getESuperPackage().getEClassifier(className); - if (classifier2 instanceof org.eclipse.emf.ecore.EClass ) - classifier = (org.eclipse.emf.ecore.EClass) classifier2; - else - classifier=null; - }else{ - org.eclipse.emf.ecore.EClassifier classifier2 = null; - classifier2 = genPackage.getEcorePackage().getEClassifier(className); - if (classifier2 instanceof org.eclipse.emf.ecore.EClass ) - classifier = (org.eclipse.emf.ecore.EClass) classifier2; - else - classifier=null; - } - - if (returnType.equals("void") ) { - } else if ( null == classifier) { - if ( null == func ) { - %> - //there is no class name here <%= className %> - return retInvoke<%= func %>; - <% } else { %> - return retInvoke<%= func %>; - <% } - } else if ( classifier.isInterface()) { - String classType = null; - classType = genOperation.getType().trim(); - final int lastIndexOf = classType.lastIndexOf('.'); - classType = classType.substring(0, lastIndexOf) + ".jacobimpl" + classType.substring(lastIndexOf); - %> - //is an interface <%= genOperation.getImportedType(genClass) %> - final <%= classType %> retVal = new <%= classType %>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } else { %> - //is a class - final <%=genOperation.getType().trim()%> retVal = new <%=genOperation.getType().trim()%>(); - retVal.setDispatch(retInvoke.toDispatch()); - return retVal; - <% } %> - diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc deleted file mode 100644 index beef3a4..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/returnTypes.javajetinc +++ /dev/null @@ -1,20 +0,0 @@ -<% - final HashMap map = new HashMap(); - map.put("java.util.Date", ".getJavaDate()"); - map.put("java.lang.String", ".getString()"); - map.put("boolean", ".getBoolean()"); - map.put("int", ".getInt()"); - map.put("java.lang.Float", ".getFloat()"); - map.put("float", ".getFloat()"); - map.put("double", ".getDouble()"); - map.put("java.lang.Double", ".getDouble()"); - map.put("com.jacob.com.Dispatch", ".getDispatch()"); - map.put("Dispatch", ".getDispatch()"); - map.put("Variant", ".toVariant()"); - map.put("com.jacob.com.Variant", ".toVariant()"); - map.put("Object", ".toJavaObject()"); - map.put("java.lang.Object", ".toJavaObject()"); - map.put("Date", ".toJavaDate()"); - map.put("java.util.Date", ".toJavaDate()"); -%> - diff --git a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc b/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc deleted file mode 100755 index 1731a3c..0000000 --- a/jacobgenPluggin/JacobGeneratorEngine/templates/model/Class/setGenFeature.TODO.override.javajetinc +++ /dev/null @@ -1,49 +0,0 @@ -<% -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -%> - -//setGenFeature.TODO.override.javajetinc -/* final String genClassName = "<% -{ -String name = genClass.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>";*/ - - - final String funcName = "<% -{ -String name = genFeature.getName().trim(); -if (name.startsWith("JACOB")) - stringBuffer.append(name.substring("JACOB".length())); -else - stringBuffer.append(name); -} -%>"; - final com.jacob.com.Dispatch dispatchComponent = getDispatch(); -<% if (genFeature.isEnumType()) { - stringBuffer.append("\n\t\tfinal Object o = new" + genFeature.getName().trim() + ".getValue();"); - } else { - stringBuffer.append("\n\t\tfinal Object o = new" + genFeature.getName().trim() + ";"); - } -%> - com.jacob.com.Dispatch.put(dispatchComponent, funcName, o); diff --git a/jacobgenPluggin/README b/jacobgenPluggin/README deleted file mode 100644 index e69de29..0000000 diff --git a/jacobgenPluggin/TestHarness/.classpath b/jacobgenPluggin/TestHarness/.classpath deleted file mode 100755 index c7e285f..0000000 --- a/jacobgenPluggin/TestHarness/.classpath +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/jacobgenPluggin/TestHarness/.project b/jacobgenPluggin/TestHarness/.project deleted file mode 100755 index 8314416..0000000 --- a/jacobgenPluggin/TestHarness/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - TestHarness - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/jacobgenPluggin/TestHarness/src/TestExcel11.java b/jacobgenPluggin/TestHarness/src/TestExcel11.java deleted file mode 100755 index 8234e5c..0000000 --- a/jacobgenPluggin/TestHarness/src/TestExcel11.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -import junit.framework.TestCase; - -import com.Excel.Application; -import com.Excel.Range; -import com.Excel.Workbook; -import com.Excel.Workbooks; -import com.Excel.Worksheet; -import com.Excel.XlWindowState; -import com.Excel.XlXmlImportResult; -import com.jacob.activeX.ActiveXComponent; -import com.jacob.com.Dispatch; -import com.jacob.com.Variant; -import com.sun.java.swing.plaf.windows.resources.windows; - -public class TestExcel11 extends TestCase { - private ActiveXComponent activeXcomponent; - private Application excelApp; - private Workbook workbook; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - activeXcomponent = new ActiveXComponent("Excel.Application"); - excelApp = new Application(); - excelApp.setDispatch(activeXcomponent); - } - - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (workbook != null){ - workbook.Close(Variant.VT_FALSE, Variant.VT_MISSING, Variant.VT_MISSING); - workbook = null; - } - excelApp.Quit(); - activeXcomponent.safeRelease(); - } - - - public void testLoad() { - excelApp.setVisible(true); - assertEquals("11.0", excelApp.getVersion()); - } - - public void testWorkbook() throws Exception { - testLoad(); - final Workbooks workbooks = excelApp.getWorkbooks(); - workbook = workbooks.Add(Variant.VT_MISSING); - } - - public void testWorksheet() throws Exception { - testWorkbook(); - final Worksheet sheet = new Worksheet(); - final Variant activeSheet = new Variant( workbook.getActiveSheet()); - sheet.setDispatch(activeSheet.toDispatch()); - final Range range_A1 = (Range) sheet.getRange(new Variant("a1"),new Variant("a1")); - range_A1.setValue(new Variant("123.456")); - final Range range_A2 = (Range) sheet.getRange(new Variant("a2"),new Variant("a2")); - range_A2.setFormula(new Variant("=A1*2")); - assertEquals(123.456, range_A1.getValue().getDouble()); - assertEquals(246.912, range_A2.getValue().getDouble()); - } - - public void testWindowState() throws Exception { - testWorkbook(); - final Worksheet sheet = new Worksheet(); - final Variant activeSheet = new Variant( workbook.getActiveSheet()); - sheet.setDispatch(activeSheet.toDispatch()); - - XlWindowState windowState ; - - excelApp.getActiveWindow().setWindowState(XlWindowState.XL_NORMAL); - windowState = excelApp.getActiveWindow().getWindowState(); - assertEquals(XlWindowState.XL_NORMAL, windowState); - - excelApp.getActiveWindow().setWindowState(XlWindowState.XL_MAXIMIZED); - windowState = excelApp.getActiveWindow().getWindowState(); - assertEquals(XlWindowState.XL_MAXIMIZED, windowState); - - } - -} diff --git a/jacobgenPluggin/TestHarness/src/TestWord11.java b/jacobgenPluggin/TestHarness/src/TestWord11.java deleted file mode 100644 index 34bd5c7..0000000 --- a/jacobgenPluggin/TestHarness/src/TestWord11.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2007 Robert Searle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -import junit.framework.TestCase; - -import com.Word.Application; -import com.Word.Document; -import com.Word.Documents; -import com.Word.Selection; -import com.jacob.activeX.ActiveXComponent; -import com.jacob.com.Variant; - -public class TestWord11 extends TestCase { - private ActiveXComponent activeXcomponent; - private Application wordApp; - private Document document; - - - @Override - protected void setUp() throws Exception { - super.setUp(); - activeXcomponent = new ActiveXComponent("Word.Application"); - wordApp = new Application(); - wordApp.setDispatch(activeXcomponent); - } - - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - if (document != null){ - document.Close(new Variant(false), null, null); - document = null; - } - wordApp.Quit(); - activeXcomponent.safeRelease(); - } - - - public void testLoad() { - wordApp.setVisible(true); - assertEquals("11.0", wordApp.getVersion()); - } - - public void testNewDocument() { - testLoad(); - wordApp.Activate(); - - Documents documents = wordApp.getDocuments(); - - Document add = documents.Add(Variant.VT_MISSING, Variant.VT_MISSING, Variant.VT_MISSING, Variant.VT_MISSING); - add.Activate(); - Selection selection = wordApp.getSelection(); - selection.TypeText("This is a simple test"); - - add.PrintPreview(); - add.ClosePrintPreview(); - add.Close(Variant.VT_FALSE, Variant.VT_MISSING, Variant.VT_MISSING); - } - -} diff --git a/jacobgenPluggin/index.html b/jacobgenPluggin/index.html deleted file mode 100755 index 8f58a99..0000000 --- a/jacobgenPluggin/index.html +++ /dev/null @@ -1,44 +0,0 @@ - -

What is JAva COm Bridge (JACOB) Plug-In?

- -

What is EMF?

-
-The Eclipse Modeling Framework is a Java/XML framework for generating tools and other applications based on simple class models. EMF helps you rapidly turn models into efficient, correct, and easily customizable Java code. It is intended to provide the benefits of formal modeling, but with a very low cost of entry. In addition to code generation, it provides the ability to save objects as XML documents for interchange with other tools and applications. Models can be created using annotated Java, XML documents, or modeling tools like Rational Rose, then imported into EMF. The code generator turns a model into a set of Java implementation classes. These classes are extensible and regenerable - you can modify them by adding user-defined methods and instance variables. When the model changes, you can regenerate the implementation classes, and your modifications will be retained. This works both ways - changes in the Java code can be used to update the model. -See EMF FAQ -
- -

Why is an eclipse plug-in needed

- - -

How does the plug-in work

-

The plug-in uses the old, JacobGen 0.7, c++ program (dll) which reads in Microsoft's proprietary TLB files and writes out what it finds on stdout. -From the information gathered from the TLB / stdout, the plug-in produces an ecore model based of what is found inside the TLB. -At this point the plug-in has created a model of what's inside the DLL file. -I.E. what classes and enums exist. -

- -

From there, this is sketchy for now, the plug-in will use Java Emitter Templates (JET2) to generate java code based on the above ecore model. -I hope JET2 can also generate java method bodies for the above model / java code. -Why are method bodies important... -I hope JET2 can generate method bodies to automatically call JACOB methods with the correct parameters. -This will create a strongly typed java proxy, via JACOB, into the windows DLL.

- -

So to wrap up. The plug-in reads the TLB file (using the existing JacobGEN DLL), creates a model based on the TLB / DLL file, and then produces a java proxy. -The JET2 generated classes are really a proxy into the DLL via JACOB. -So the end result is a set of java classes hiding all JACOB internal knowledge.

- -

Software needed...

-See jet2 for more information. -
    -
  1. S-3.4M2-200709210919 or later. See release notes for more information.
  2. -
  3. emf-sdo-xsd-SDK-2.4.0M2.zip
  4. -
  5. m2t-jet-SDK-incubation-0.9.0M2.zip
  6. -
- -

Other Documents / Articles

- - \ No newline at end of file