[prev in list] [next in list] [prev in thread] [next in thread]
List: jibx-cvs
Subject: [Jibx-cvs] core/build/src/org/jibx/binding/def
From: Dennis Sosnoski <dsosnoski () users ! sourceforge ! net>
Date: 2008-07-26 2:13:36
Message-ID: E1KMZHs-0007fK-Ui () mail ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/jibx/core/build/src/org/jibx/binding/def
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv509/src/org/jibx/binding/def
Modified Files:
BindingDefinition.java
Log Message:
Fix issue with string size for blob of classes with binding code by instead using a \
method; convert to using StringArray where appropriate
Index: BindingDefinition.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/binding/def/BindingDefinition.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** BindingDefinition.java 22 Jul 2008 01:13:24 -0000 1.28
--- BindingDefinition.java 26 Jul 2008 02:13:34 -0000 1.29
***************
*** 54,57 ****
--- 54,58 ----
import org.jibx.runtime.JiBXException;
import org.jibx.runtime.QName;
+ import org.jibx.runtime.impl.StringArray;
/**
***************
*** 158,201 ****
private static final int PRIVATESTATICFINAL_ACCESS =
PRIVATESTATIC_ACCESS | Constants.ACC_FINAL;
- private static final String MARSHALLER_ARRAYNAME = "m_marshallers";
- private static final String UNMARSHALLER_ARRAYNAME = "m_unmarshallers";
- private static final String STRING_ARRAYTYPE = "java.lang.String[]";
- private static final String CLASSES_ARRAYNAME = "m_classes";
- private static final String URIS_ARRAYNAME = "m_uris";
- private static final String PREFIXES_ARRAYNAME = "m_prefixes";
- private static final String GNAMES_ARRAYNAME = "m_globalNames";
- private static final String GURIS_ARRAYNAME = "m_globalUris";
- private static final String IDNAMES_ARRAYNAME = "m_idNames";
private static final String TYPEMAP_NAME = "m_typeMap";
- private static final String CREATEMARSHAL_METHODNAME =
- "createMarshallingContext";
- private static final String MARSHALCONTEXT_INTERFACE =
- "org.jibx.runtime.IMarshallingContext";
- private static final String MARSHALCONTEXT_IMPLEMENTATION =
- "org.jibx.runtime.impl.MarshallingContext";
- private static final String MARSHALCONTEXTINIT_SIGNATURE =
- "([Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;" +
- "Lorg/jibx/runtime/IBindingFactory;)V";
- private static final String CREATEUNMARSHAL_METHODNAME =
- "createUnmarshallingContext";
- private static final String UNMARSHALCONTEXT_INTERFACE =
- "org.jibx.runtime.IUnmarshallingContext";
- private static final String UNMARSHALCONTEXT_IMPLEMENTATION =
- "org.jibx.runtime.impl.UnmarshallingContext";
- private static final String UNMARSHALCONTEXTINIT_SIGNATURE =
- "(I[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;" +
- "[Ljava/lang/String;Lorg/jibx/runtime/IBindingFactory;)V";
private static final String GETINST_METHODNAME = "getInstance";
- private static final String UNSUPPORTED_EXCEPTION_CLASS =
- "java.lang.UnsupportedOperationException";
private static final String GETVERSION_METHODNAME = "getCompilerVersion";
private static final String GETDISTRIB_METHODNAME =
"getCompilerDistribution";
- private static final String GETDEFINEDNSS_METHODNAME = "getNamespaces";
- private static final String GETDEFINEDPREFS_METHODNAME = "getPrefixes";
- private static final String GETCLASSES_METHODNAME = "getMappedClasses";
- private static final String GETELEMENTNSS_METHODNAME =
- "getElementNamespaces";
- private static final String GETELEMENTNAMES_METHODNAME = "getElementNames";
private static final String GETTYPEINDEX_METHODNAME = "getTypeIndex";
private static final String STRINGINT_MAPTYPE =
--- 159,167 ----
***************
*** 211,215 ****
"(Ljava/lang/String;)I";
private static final int MAX_STRING_LENGTH = 0x7FFF;
! private static final String CLASSLIST_FIELD_NAME = "s_classList";
//
--- 177,183 ----
"(Ljava/lang/String;)I";
private static final int MAX_STRING_LENGTH = 0x7FFF;
! private static final String CLASSLIST_METHOD_NAME = "getClassList";
! private static final String CLASSLIST_METHOD_SIGNATURE =
! "()Ljava/lang/String;";
//
***************
*** 256,259 ****
--- 224,230 ----
private File m_targetRoot;
+ /** Fully-qualified name of binding factory. */
+ private String m_factoryName;
+
/** Classes using unique (per class) identifiers. This is <code>null</code>
and unused when using global ID values. */
***************
*** 264,268 ****
/** Original prefixes for namespaces. */
! private ArrayList m_namespacePrefixes;
/** High mark in prefixes from from precompiled base bindings. */
--- 235,239 ----
/** Original prefixes for namespaces. */
! private StringArray m_namespacePrefixes;
/** High mark in prefixes from from precompiled base bindings. */
***************
*** 285,302 ****
/** Classes handled by in-line marshaller/unmarshaller references. */
! private ArrayList m_extraClasses;
/** Marshaller classes used in-line. */
! private ArrayList m_extraMarshallers;
/** Unmarshaller classes used in-line. */
! private ArrayList m_extraUnmarshallers;
/** Precompiled base binding names used by this binding. */
! private ArrayList m_baseBindings;
/** Factory class names for precompiled base bindings (same order as binding
names). */
! private ArrayList m_baseBindingFactories;
/** Hashes for base binding factories (same order as binding names). */
--- 256,273 ----
/** Classes handled by in-line marshaller/unmarshaller references. */
! private StringArray m_extraClasses;
/** Marshaller classes used in-line. */
! private StringArray m_extraMarshallers;
/** Unmarshaller classes used in-line. */
! private StringArray m_extraUnmarshallers;
/** Precompiled base binding names used by this binding. */
! private StringArray m_baseBindings;
/** Factory class names for precompiled base bindings (same order as binding
names). */
! private StringArray m_baseBindingFactories;
/** Hashes for base binding factories (same order as binding names). */
***************
*** 308,312 ****
/** Factory classes for base bindings of base bindings. */
! private ArrayList m_closureFactories;
/** Namespace index mapping tables for base bindings of base bindings (same
--- 279,283 ----
/** Factory classes for base bindings of base bindings. */
! private StringArray m_closureFactories;
/** Namespace index mapping tables for base bindings of base bindings (same
***************
*** 351,359 ****
m_majorVersion = major;
m_minorVersion = minor;
! m_baseBindings = new ArrayList();
! m_baseBindingFactories = new ArrayList();
m_baseHashes = new ArrayList();
m_baseNamespaceTables = new ArrayList();
! m_closureFactories = new ArrayList();
m_closureNamespaceTables = new ArrayList();
--- 322,330 ----
m_majorVersion = major;
m_minorVersion = minor;
! m_baseBindings = new StringArray();
! m_baseBindingFactories = new StringArray();
m_baseHashes = new ArrayList();
m_baseNamespaceTables = new ArrayList();
! m_closureFactories = new StringArray();
m_closureNamespaceTables = new ArrayList();
***************
*** 369,373 ****
m_namespaceUris = new ArrayMap();
m_namespaceUris.findOrAdd("");
! m_namespacePrefixes = new ArrayList();
m_namespacePrefixes.add("");
m_outerContext.addNamespace(NamespaceDefinition.buildNamespace
--- 340,344 ----
m_namespaceUris = new ArrayMap();
m_namespaceUris.findOrAdd("");
! m_namespacePrefixes = new StringArray();
m_namespacePrefixes.add("");
m_outerContext.addNamespace(NamespaceDefinition.buildNamespace
***************
*** 596,602 ****
m_isMappedDone = true;
m_mumIndex = s_mappedClasses.size();
! m_extraClasses = new ArrayList();
! m_extraMarshallers = new ArrayList();
! m_extraUnmarshallers = new ArrayList();
}
m_extraClasses.add(clas);
--- 567,573 ----
m_isMappedDone = true;
m_mumIndex = s_mappedClasses.size();
! m_extraClasses = new StringArray();
! m_extraMarshallers = new StringArray();
! m_extraUnmarshallers = new StringArray();
}
m_extraClasses.add(clas);
***************
*** 958,961 ****
--- 929,942 ----
}
}
+
+ /**
+ * Get the fully-qualified name of the binding factory class for this
+ * binding.
+ *
+ * @return class name
+ */
+ public String getFactoryName() {
+ return m_factoryName;
+ }
/**
***************
*** 983,986 ****
--- 964,974 ----
}
+ // set the class name to be used for binding factory
+ if (m_targetPackage.length() == 0) {
+ m_factoryName = getPrefix() + FACTORY_SUFFIX;
+ } else {
+ m_factoryName = m_targetPackage + '.' + getPrefix() + FACTORY_SUFFIX;
+ }
+
// handle basic linkage and child code generation
BoundClass.setModify(m_targetRoot, m_targetPackage);
***************
*** 996,1018 ****
// build the binding factory class
- String name;
- if (m_targetPackage.length() == 0) {
- name = getPrefix() + FACTORY_SUFFIX;
- } else {
- name = m_targetPackage + '.' + getPrefix() + FACTORY_SUFFIX;
- }
ClassFile base = ClassCache.getClassFile(FACTORY_BASE);
! ClassFile cf = new ClassFile(name, m_targetRoot, base,
Constants.ACC_PUBLIC, FACTORY_INTERFACES);
! // add static fields for instance and class list
ClassItem inst = cf.addField(FACTORY_INTERFACE,
FACTORY_INSTNAME, PRIVATESTATIC_ACCESS);
! ClassItem clasblob = cf.addField("java.lang.String",
! CLASSLIST_FIELD_NAME, PRIVATESTATIC_ACCESS);
// add the private constructor method
! MethodBuilder mb = new ExceptionMethodBuilder("<init>",
! Type.VOID, new Type[0], cf, Constants.ACC_PRIVATE);
// start superclass constructor call with name/versions, classes used
--- 984,1007 ----
// build the binding factory class
ClassFile base = ClassCache.getClassFile(FACTORY_BASE);
! ClassFile cf = new ClassFile(m_factoryName, m_targetRoot, base,
Constants.ACC_PUBLIC, FACTORY_INTERFACES);
! // add static field for instance
ClassItem inst = cf.addField(FACTORY_INTERFACE,
FACTORY_INSTNAME, PRIVATESTATIC_ACCESS);
!
! // add private method to return binding classes blob (replaced later)
! MethodBuilder mb = new ExceptionMethodBuilder(CLASSLIST_METHOD_NAME,
! Type.STRING, new Type[0], cf,
! Constants.ACC_PRIVATE|Constants.ACC_STATIC);
! mb.appendACONST_NULL();
! mb.appendReturn(Type.STRING);
! mb.codeComplete(false);
! ClassItem clasblobmeth = mb.addMethod();
// add the private constructor method
! mb = new ExceptionMethodBuilder("<init>", Type.VOID, new Type[0], cf,
! Constants.ACC_PRIVATE);
// start superclass constructor call with name/versions, classes used
***************
*** 1021,1025 ****
mb.appendLoadConstant(m_majorVersion);
mb.appendLoadConstant(m_minorVersion);
! mb.appendGetStatic(clasblob);
// load count of mapped classes
--- 1010,1014 ----
mb.appendLoadConstant(m_majorVersion);
mb.appendLoadConstant(m_minorVersion);
! mb.appendCall(clasblobmeth);
// load count of mapped classes
***************
*** 1134,1138 ****
// create argument blobs of abstract mapping information
! ArrayList allnames = new ArrayList();
int abmapcnt = 0;
StringBuffer buff = new StringBuffer();
--- 1123,1127 ----
// create argument blobs of abstract mapping information
! StringArray allnames = new StringArray();
int abmapcnt = 0;
StringBuffer buff = new StringBuffer();
***************
*** 1167,1180 ****
}
}
! codegenString(buildClassNamesBlob(allnames), mb);
codegenString(buff.toString(), mb);
// create argument blobs of precompiled base binding names and factories
int basecount = m_baseBindings.size();
! String[] bindings = new String[basecount];
! bindings = (String[])m_baseBindings.toArray(bindings);
! codegenString(buildNamesBlob(bindings), mb);
! String namesblob = buildClassNamesBlob(m_baseBindingFactories) +
! buildClassNamesBlob(m_closureFactories);
codegenString(namesblob, mb);
--- 1156,1168 ----
}
}
! codegenString(buildClassNamesBlob(allnames.toArray()), mb);
codegenString(buff.toString(), mb);
// create argument blobs of precompiled base binding names and factories
int basecount = m_baseBindings.size();
! codegenString(buildNamesBlob(m_baseBindings.toArray()), mb);
! String namesblob = buildClassNamesBlob
! (m_baseBindingFactories.toArray()) +
! buildClassNamesBlob(m_closureFactories.toArray());
codegenString(namesblob, mb);
***************
*** 1218,1222 ****
// get class names for types (abstract non-base mappings)
! ArrayList tnames = new ArrayList();
if (m_isForceClasses) {
for (int i = 0; i < count; i++) {
--- 1206,1210 ----
// get class names for types (abstract non-base mappings)
! StringArray tnames = new StringArray();
if (m_isForceClasses) {
for (int i = 0; i < count; i++) {
***************
*** 1342,1350 ****
// add factory class to generated registry
! cf = MungedClass.getUniqueSupportClass(cf);
! String link = name;
! if (!name.equals(cf.getName())) {
! link = cf.getName() + '=' + name;
! }
m_factoryClass = cf;
--- 1330,1335 ----
// add factory class to generated registry
! cf.codeComplete();
! MungedClass.addModifiedClass(cf);
m_factoryClass = cf;
***************
*** 1356,1360 ****
BoundClass bound = ((MappingBase)map).getBoundClass();
if (bound.getClassFile().isModifiable()) {
! bound.addFactory(link);
}
}
--- 1341,1345 ----
BoundClass bound = ((MappingBase)map).getBoundClass();
if (bound.getClassFile().isModifiable()) {
! bound.addFactory(m_factoryName);
}
}
***************
*** 1386,1394 ****
String[] refs = (String[])tree.toArray(new String[tree.size()]);
! // replace dummy static fields in factory with actual values
! m_factoryClass.deleteField(CLASSLIST_FIELD_NAME);
! String blob = buildClassNamesBlob(refs);
! m_factoryClass.addField("java.lang.String", CLASSLIST_FIELD_NAME,
! PRIVATESTATICFINAL_ACCESS, blob);
m_factoryClass.codeComplete();
}
--- 1371,1384 ----
String[] refs = (String[])tree.toArray(new String[tree.size()]);
! // replace private method to return binding classes blob
! m_factoryClass.deleteMethod(CLASSLIST_METHOD_NAME,
! CLASSLIST_METHOD_SIGNATURE);
! MethodBuilder mb = new ExceptionMethodBuilder(CLASSLIST_METHOD_NAME,
! Type.STRING, new Type[0], m_factoryClass,
! Constants.ACC_PRIVATE|Constants.ACC_STATIC);
! codegenString(buildClassNamesBlob(refs), mb);
! mb.appendReturn(Type.STRING);
! mb.codeComplete(false);
! mb.addMethod();
m_factoryClass.codeComplete();
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jibx-cvs mailing list
Jibx-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic