summaryrefslogtreecommitdiff
path: root/ridljar
diff options
context:
space:
mode:
authorKay Ramme <kr@openoffice.org>2001-04-17 14:01:37 +0000
committerKay Ramme <kr@openoffice.org>2001-04-17 14:01:37 +0000
commitdd9a9f8616007395d43c58af9d74a308c42b3267 (patch)
tree9e6e21ab32059b3a8c39fa7c493a0a50fba5e448 /ridljar
parenta7ef28c7fb1b9b13a524989d1cc68f108f2dad41 (diff)
fixed xinterface <-> any bug
Diffstat (limited to 'ridljar')
-rw-r--r--ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java130
-rw-r--r--ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java49
2 files changed, 56 insertions, 123 deletions
diff --git a/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java
index 8c0a9bc3bd46..b5c279140e24 100644
--- a/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java
+++ b/ridljar/com/sun/star/lib/uno/typedesc/MethodDescription.java
@@ -2,9 +2,9 @@
*
* $RCSfile: MethodDescription.java,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: kr $ $Date: 2001-04-04 13:41:41 $
+ * last change: $Author: kr $ $Date: 2001-04-17 15:01:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,7 +70,7 @@ import com.sun.star.lib.uno.typeinfo.ParameterTypeInfo;
import com.sun.star.lib.uno.typeinfo.TypeInfo;
-public class MethodDescription {
+public class MethodDescription extends MethodTypeInfo {
static private final TypeDescription __xInterface = TypeDescription.getTypeDescription(com.sun.star.uno.XInterface.class);
static private TypeDescription __xInterfaceArray;
static private TypeDescription __xInterfaceArrayArray;
@@ -85,9 +85,6 @@ public class MethodDescription {
}
}
- protected int _index;
- protected int _flags;
- protected String _name;
protected int _offset;
protected TypeDescription _in_sig[];
protected TypeDescription _out_sig[];
@@ -96,46 +93,16 @@ public class MethodDescription {
protected ParameterTypeInfo _parameterTypeInfos[];
- public MethodDescription(String name, int index, int flags) {
- _name = name;
- _flags = flags;
-
- _index = index;
+ public MethodDescription(String name, int index, int flags) {
+ super(name, index, flags);
}
public MethodDescription(MethodTypeInfo methodTypeInfo) {
this(methodTypeInfo.getName(), methodTypeInfo.getIndex(), methodTypeInfo.getFlags());
}
- public String getName() {
- return _name;
- }
-
public int getIndex() {
- return _index + _offset;
- }
-
- public boolean isOneway() {
- return (_flags & TypeInfo.ONEWAY) != 0;
- }
-
- public boolean isConst() {
- return (_flags & TypeInfo.CONST) != 0;
- }
-
- public boolean isUnsigned()
- {
- return (_flags & TypeInfo.UNSIGNED) != 0;
- }
-
- public boolean isAny()
- {
- return (_flags & TypeInfo.ANY) != 0;
- }
-
- public boolean isInterface()
- {
- return (_flags & TypeInfo.INTERFACE) != 0;
+ return super.getIndex() + _offset;
}
@@ -152,92 +119,17 @@ public class MethodDescription {
// init _in_sig
_in_sig = new TypeDescription[signature.length];
for(int i = 0; i < _in_sig.length; ++i)
- _in_sig[i] = __takeCareOf_XInterface_and_java_lang_Object_as_in(_parameterTypeInfos[i], signature[i]);
+ if(_parameterTypeInfos[i] == null || _parameterTypeInfos[i].isIN())
+ _in_sig[i] = TypeDescription.getTypeDescription(_parameterTypeInfos[i], signature[i]);
// init _out_sig
_out_sig = new TypeDescription[signature.length];
for(int i = 0; i < _out_sig.length; ++i)
- _out_sig[i] = __takeCareOf_XInterface_and_java_lang_Object_as_out(_parameterTypeInfos[i], signature[i]);
+ if(_parameterTypeInfos[i] != null && _parameterTypeInfos[i].isOUT())
+ _out_sig[i] = TypeDescription.getTypeDescription(_parameterTypeInfos[i], signature[i]);
// init _return_sig
- if(resultClass == Object.class && isInterface())
- if(resultClass.isArray())
- _return_sig = __xInterfaceArray;
- else
- _return_sig = __xInterface;
- else
- _return_sig = TypeDescription.getTypeDescription(resultClass);
- }
-
- static private TypeDescription __takeCareOf_XInterface_and_java_lang_Object_as_in(ParameterTypeInfo typeInfo, Class parameterClass) {
- TypeDescription typeDescription = TypeDescription.getTypeDescription(parameterClass);
-
- if(typeInfo != null) { // if there is special typeinfo, use it
- if(typeInfo.isIN()) {
- // blackdown 118 bug workaround
-// __getFields(parameterClass);
-
- // see if the typeinfo says, that the parameter is an interface
- // and the parameter is not assignable to xinterface (mapping of xinterface to java.lang.Object)
- // set the parameter to class of xinterface, cause it must be assignable
- int arrayNesting = 0;
- while(parameterClass.isArray()) {
- ++ arrayNesting;
-
- parameterClass = parameterClass.getComponentType();
- }
-
- if(typeInfo.isInterface() && !parameterClass.isInterface())
- for(int i = 0; i < arrayNesting; ++ i) {
- try {
- typeDescription = TypeDescription.getTypeDescription("[]" + typeDescription.getTypeName());
- }
- catch(ClassNotFoundException classNotFoundException) { // this could never happen, but anyway...
- throw new RuntimeException(classNotFoundException.toString());
- }
- }
- }
- else // this is an out parameter, and must not be passed
- typeDescription = null;
- }
-
- return typeDescription;
- }
-
- static private TypeDescription __takeCareOf_XInterface_and_java_lang_Object_as_out(ParameterTypeInfo typeInfo, Class parameterClass) {
- TypeDescription typeDescription = TypeDescription.getTypeDescription(parameterClass);
-
- if(typeInfo != null && typeInfo.isOUT()) { // if there is special typeinfo and it is an outparameter, use it
- // blackdown 118 bug workaround
-// __getFields(parameterClass);
-
- // see if the typeinfo says, that the parameter is an interface
- // and the parameter is not assignable to xinterface (mapping of xinterface to java.lang.Object)
- // set the parameter to class of xinterface, cause it must be assignable
- int arrayNesting = 0;
- while(parameterClass.isArray()) {
- ++ arrayNesting;
-
- parameterClass = parameterClass.getComponentType();
- }
-
- if(typeInfo.isInterface() && !parameterClass.isInterface()) {
- typeDescription = __xInterface;
-
- for(int i = 0; i < arrayNesting; ++ i) {
- try {
- typeDescription = TypeDescription.getTypeDescription("[]" + typeDescription.getTypeName());
- }
- catch(ClassNotFoundException classNotFoundException) { // this could never happen, but anyway...
- throw new RuntimeException(classNotFoundException.toString());
- }
- }
- }
- }
- else // this is not an out parameter
- typeDescription = null;
-
- return typeDescription;
+ _return_sig = TypeDescription.getTypeDescription(this, resultClass);
}
public TypeDescription[] getInSignature() {
diff --git a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
index 1e34c84eab11..354ce232bc3a 100644
--- a/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
+++ b/ridljar/com/sun/star/lib/uno/typedesc/TypeDescription.java
@@ -2,9 +2,9 @@
*
* $RCSfile: TypeDescription.java,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: kr $ $Date: 2001-02-21 12:10:25 $
+ * last change: $Author: kr $ $Date: 2001-04-17 15:01:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,7 +94,7 @@ import com.sun.star.lib.uno.typeinfo.TypeInfo;
* methods, which may be changed or moved in the furture, so please
* do not use these methods.
* <p>
- * @version $Revision: 1.5 $ $ $Date: 2001-02-21 12:10:25 $
+ * @version $Revision: 1.6 $ $ $Date: 2001-04-17 15:01:37 $
* @author Kay Ramme
* @since UDK2.0
*/
@@ -443,6 +443,47 @@ public class TypeDescription {
}
}
+ static public TypeDescription getTypeDescription(TypeInfo typeInfo, Class zClass) {
+ TypeDescription typeDescription = null;
+
+ if(typeInfo == null || !typeInfo.isInterface())
+ typeDescription = TypeDescription.getTypeDescription(zClass);
+
+ else {
+ // blackdown 118 bug workaround
+// __getFields(zClass);
+
+ // see if the typeinfo says, that the parameter is an interface
+ // and the parameter is not assignable to xinterface (mapping of xinterface to java.lang.Object)
+ // set the parameter to class of xinterface, cause it must be assignable
+
+ // unrole any arrays
+ int arrayNesting = 0;
+ while(zClass.isArray()) {
+ ++ arrayNesting;
+
+ zClass = zClass.getComponentType();
+ }
+
+ if(zClass.isInterface())
+ typeDescription = TypeDescription.getTypeDescription(zClass);
+
+ else {
+ typeDescription = TypeDescription.getTypeDescription(com.sun.star.uno.XInterface.class);
+
+ for(int i = 0; i < arrayNesting; ++ i) {
+ try {
+ typeDescription = TypeDescription.getTypeDescription("[]" + typeDescription.getTypeName());
+ }
+ catch(ClassNotFoundException classNotFoundException) { // this could never happen, but anyway...
+ throw new RuntimeException(classNotFoundException.toString());
+ }
+ }
+ }
+ }
+
+ return typeDescription;
+ }
static public TypeDescription getTypeDescription(Class zClass) {
TypeDescription typeDescription = (TypeDescription)__classToTypeDescription.get(zClass);
@@ -634,7 +675,7 @@ public class TypeDescription {
int superOffset = 0;
if(_class == com.sun.star.uno.XInterface.class) { // take special care for xinterface
- MethodDescription queryInterface = new MethodDescription("queryInterface", 0, TypeInfo.ANY);
+ MethodDescription queryInterface = new MethodDescription("queryInterface", 0, TypeInfo.ANY);
queryInterface.init(new Class[]{Type.class}, new ParameterTypeInfo[]{new ParameterTypeInfo(null, "queryInterface", 0, 0)},
Object.class);