@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 15:32:16 +00:00
|
|
|
| PHP Version 4 |
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 15:32:16 +00:00
|
|
|
| Copyright (c) 1997-2002 The PHP Group |
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-07-24 05:41:02 +00:00
|
|
|
| This source file is subject to version 2.02 of the PHP license, |
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
2000-07-24 05:41:02 +00:00
|
|
|
| http://www.php.net/license/2_02.txt. |
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Sam Ruby (rubys@us.ibm.com) |
|
|
|
|
+----------------------------------------------------------------------+
|
2000-07-24 05:41:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
package net.php;
|
|
|
|
|
|
|
|
import java.lang.reflect.*;
|
1999-12-06 05:00:40 +00:00
|
|
|
import java.util.*;
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
import java.beans.*;
|
|
|
|
|
2000-06-14 01:41:13 +00:00
|
|
|
public class reflect {
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
1999-11-29 15:36:25 +00:00
|
|
|
static { loadLibrary("reflect"); }
|
|
|
|
|
|
|
|
protected static void loadLibrary(String property) {
|
|
|
|
try {
|
|
|
|
ResourceBundle bundle = ResourceBundle.getBundle("net.php."+property);
|
|
|
|
System.loadLibrary(bundle.getString("library"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Native methods
|
|
|
|
//
|
2000-05-12 09:51:16 +00:00
|
|
|
private static native void setResultFromString(long result, byte value[]);
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
private static native void setResultFromLong(long result, long value);
|
|
|
|
private static native void setResultFromDouble(long result, double value);
|
|
|
|
private static native void setResultFromBoolean(long result, boolean value);
|
|
|
|
private static native void setResultFromObject(long result, Object value);
|
2000-02-20 12:09:34 +00:00
|
|
|
private static native void setResultFromArray(long result);
|
|
|
|
private static native long nextElement(long array);
|
2000-07-22 17:32:32 +00:00
|
|
|
private static native long hashUpdate(long array, byte key[]);
|
2000-07-22 20:36:11 +00:00
|
|
|
private static native long hashIndexUpdate(long array, long key);
|
2000-06-30 04:48:46 +00:00
|
|
|
private static native void setException(long result, byte value[]);
|
1999-11-29 15:36:25 +00:00
|
|
|
public static native void setEnv();
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Helper routines which encapsulate the native methods
|
|
|
|
//
|
2000-06-14 01:41:13 +00:00
|
|
|
public static void setResult(long result, Object value) {
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
if (value == null) return;
|
|
|
|
|
|
|
|
if (value instanceof java.lang.String) {
|
|
|
|
|
2000-05-12 09:51:16 +00:00
|
|
|
setResultFromString(result, ((String)value).getBytes());
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
} else if (value instanceof java.lang.Number) {
|
|
|
|
|
|
|
|
if (value instanceof java.lang.Integer ||
|
|
|
|
value instanceof java.lang.Short ||
|
|
|
|
value instanceof java.lang.Byte) {
|
|
|
|
setResultFromLong(result, ((Number)value).longValue());
|
|
|
|
} else {
|
|
|
|
/* Float, Double, BigDecimal, BigInteger, Double, Long, ... */
|
|
|
|
setResultFromDouble(result, ((Number)value).doubleValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (value instanceof java.lang.Boolean) {
|
|
|
|
|
|
|
|
setResultFromBoolean(result, ((Boolean)value).booleanValue());
|
|
|
|
|
2000-02-20 12:09:34 +00:00
|
|
|
} else if (value.getClass().isArray()) {
|
|
|
|
|
|
|
|
long length = Array.getLength(value);
|
|
|
|
setResultFromArray(result);
|
|
|
|
for (int i=0; i<length; i++) {
|
|
|
|
setResult(nextElement(result), Array.get(value, i));
|
|
|
|
}
|
|
|
|
|
2000-07-22 17:32:32 +00:00
|
|
|
} else if (value instanceof java.util.Hashtable) {
|
|
|
|
|
|
|
|
Hashtable ht = (Hashtable) value;
|
|
|
|
setResultFromArray(result);
|
|
|
|
for (Enumeration e = ht.keys(); e.hasMoreElements(); ) {
|
|
|
|
Object key = e.nextElement();
|
2000-07-22 20:36:11 +00:00
|
|
|
long slot;
|
|
|
|
if (key instanceof Number &&
|
|
|
|
!(key instanceof Double || key instanceof Float))
|
|
|
|
slot = hashIndexUpdate(result, ((Number)key).longValue());
|
|
|
|
else
|
|
|
|
slot = hashUpdate(result, key.toString().getBytes());
|
|
|
|
setResult(slot, ht.get(key));
|
2000-07-22 17:32:32 +00:00
|
|
|
}
|
|
|
|
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
setResultFromObject(result, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-09 04:16:31 +00:00
|
|
|
Throwable lastException = null;
|
2000-07-08 10:35:50 +00:00
|
|
|
|
2000-07-09 04:16:31 +00:00
|
|
|
void lastException(long result) {
|
2000-07-08 10:35:50 +00:00
|
|
|
setResult(result, lastException);
|
|
|
|
}
|
|
|
|
|
2000-07-09 04:16:31 +00:00
|
|
|
void clearException() {
|
2000-07-08 10:35:50 +00:00
|
|
|
lastException = null;
|
|
|
|
}
|
|
|
|
|
2000-07-09 04:16:31 +00:00
|
|
|
void setException(long result, Throwable e) {
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
if (e instanceof InvocationTargetException) {
|
|
|
|
Throwable t = ((InvocationTargetException)e).getTargetException();
|
|
|
|
if (t!=null) e=t;
|
|
|
|
}
|
|
|
|
|
2000-07-08 10:35:50 +00:00
|
|
|
lastException = e;
|
2000-06-30 04:48:46 +00:00
|
|
|
setException(result, e.toString().getBytes());
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create an new instance of a given class
|
|
|
|
//
|
2000-07-09 04:16:31 +00:00
|
|
|
public void CreateObject(String name, Object args[], long result) {
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
try {
|
2000-02-28 17:02:28 +00:00
|
|
|
Vector matches = new Vector();
|
|
|
|
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
Constructor cons[] = Class.forName(name).getConstructors();
|
|
|
|
for (int i=0; i<cons.length; i++) {
|
|
|
|
if (cons[i].getParameterTypes().length == args.length) {
|
2000-02-28 17:02:28 +00:00
|
|
|
matches.addElement(cons[i]);
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-28 17:02:28 +00:00
|
|
|
Constructor selected = (Constructor)select(matches, args);
|
|
|
|
|
|
|
|
if (selected == null) {
|
|
|
|
if (args.length > 0) {
|
|
|
|
throw new InstantiationException("No matching constructor found");
|
|
|
|
} else {
|
|
|
|
// for classes which have no visible constructor, return the class
|
|
|
|
// useful for classes like java.lang.System and java.util.Calendar.
|
|
|
|
setResult(result, Class.forName(name));
|
|
|
|
return;
|
|
|
|
}
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
|
2000-02-28 17:02:28 +00:00
|
|
|
Object coercedArgs[] = coerce(selected.getParameterTypes(), args);
|
2000-07-22 13:43:46 +00:00
|
|
|
setResultFromObject(result, selected.newInstance(coercedArgs));
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
setException(result, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-06 05:00:40 +00:00
|
|
|
//
|
|
|
|
// Select the best match from a list of methods
|
|
|
|
//
|
2000-02-28 17:02:28 +00:00
|
|
|
private static Object select(Vector methods, Object args[]) {
|
|
|
|
if (methods.size() == 1) return methods.firstElement();
|
1999-12-06 05:00:40 +00:00
|
|
|
|
2000-02-28 17:02:28 +00:00
|
|
|
Object selected = null;
|
1999-12-06 05:00:40 +00:00
|
|
|
int best = Integer.MAX_VALUE;
|
|
|
|
|
|
|
|
for (Enumeration e = methods.elements(); e.hasMoreElements(); ) {
|
2000-02-28 17:02:28 +00:00
|
|
|
Object element = e.nextElement();
|
1999-12-06 05:00:40 +00:00
|
|
|
int weight=0;
|
2000-02-28 17:02:28 +00:00
|
|
|
|
|
|
|
Class parms[] = (element instanceof Method) ?
|
|
|
|
((Method)element).getParameterTypes() :
|
|
|
|
((Constructor)element).getParameterTypes();
|
|
|
|
|
1999-12-06 05:00:40 +00:00
|
|
|
for (int i=0; i<parms.length; i++) {
|
|
|
|
if (parms[i].isInstance(args[i])) {
|
|
|
|
for (Class c=parms[i]; (c=c.getSuperclass()) != null; ) {
|
|
|
|
if (!c.isInstance(args[i])) break;
|
|
|
|
weight++;
|
|
|
|
}
|
2000-07-22 20:36:11 +00:00
|
|
|
} else if (parms[i].isAssignableFrom(java.lang.String.class)) {
|
|
|
|
if (!(args[i] instanceof byte[]) && !(args[i] instanceof String))
|
|
|
|
weight+=9999;
|
|
|
|
} else if (parms[i].isArray()) {
|
|
|
|
if (args[i] instanceof java.util.Hashtable)
|
|
|
|
weight+=256;
|
|
|
|
else
|
2000-05-12 09:51:16 +00:00
|
|
|
weight+=9999;
|
1999-12-06 05:00:40 +00:00
|
|
|
} else if (parms[i].isPrimitive()) {
|
|
|
|
Class c=parms[i];
|
|
|
|
if (args[i] instanceof Number) {
|
|
|
|
if (c==Boolean.TYPE) weight+=5;
|
|
|
|
if (c==Character.TYPE) weight+=4;
|
|
|
|
if (c==Byte.TYPE) weight+=3;
|
|
|
|
if (c==Short.TYPE) weight+=2;
|
|
|
|
if (c==Integer.TYPE) weight++;
|
|
|
|
if (c==Float.TYPE) weight++;
|
|
|
|
} else if (args[i] instanceof Boolean) {
|
|
|
|
if (c!=Boolean.TYPE) weight+=9999;
|
|
|
|
} else if (args[i] instanceof String) {
|
|
|
|
if (c== Character.TYPE || ((String)args[i]).length()>0)
|
|
|
|
weight+=((String)args[i]).length();
|
|
|
|
else
|
2000-10-27 10:27:19 +00:00
|
|
|
weight+=64;
|
1999-12-06 05:00:40 +00:00
|
|
|
} else {
|
|
|
|
weight+=9999;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
weight+=9999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weight < best) {
|
2000-02-28 17:02:28 +00:00
|
|
|
if (weight == 0) return element;
|
1999-12-06 05:00:40 +00:00
|
|
|
best = weight;
|
2000-02-28 17:02:28 +00:00
|
|
|
selected = element;
|
1999-12-06 05:00:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2000-02-28 17:02:28 +00:00
|
|
|
// Coerce arguments when possible to conform to the argument list.
|
|
|
|
// Java's reflection will automatically do widening conversions,
|
|
|
|
// unfortunately PHP only supports wide formats, so to be practical
|
|
|
|
// some (possibly lossy) conversions are required.
|
1999-12-06 05:00:40 +00:00
|
|
|
//
|
2000-02-28 17:02:28 +00:00
|
|
|
private static Object[] coerce(Class parms[], Object args[]) {
|
1999-12-06 05:00:40 +00:00
|
|
|
Object result[] = args;
|
|
|
|
for (int i=0; i<args.length; i++) {
|
2000-05-21 11:24:49 +00:00
|
|
|
if (args[i] instanceof byte[] && !parms[i].isArray()) {
|
2000-10-27 10:27:19 +00:00
|
|
|
Class c = parms[i];
|
|
|
|
String s = new String((byte[])args[i]);
|
|
|
|
result[i] = s;
|
|
|
|
try {
|
|
|
|
if (c == Boolean.TYPE) result[i]=new Boolean(s);
|
|
|
|
if (c == Byte.TYPE) result[i]=new Byte(s);
|
|
|
|
if (c == Short.TYPE) result[i]=new Short(s);
|
|
|
|
if (c == Integer.TYPE) result[i]=new Integer(s);
|
|
|
|
if (c == Float.TYPE) result[i]=new Float(s);
|
|
|
|
if (c == Long.TYPE) result[i]=new Long(s);
|
|
|
|
if (c == Character.TYPE && s.length()>0)
|
|
|
|
result[i]=new Character(s.charAt(0));
|
|
|
|
} catch (NumberFormatException n) {
|
|
|
|
// oh well, we tried!
|
|
|
|
}
|
2000-05-12 09:51:16 +00:00
|
|
|
} else if (args[i] instanceof Number && parms[i].isPrimitive()) {
|
1999-12-06 05:00:40 +00:00
|
|
|
if (result==args) result=(Object[])result.clone();
|
|
|
|
Class c = parms[i];
|
|
|
|
Number n = (Number)args[i];
|
|
|
|
if (c == Boolean.TYPE) result[i]=new Boolean(0.0!=n.floatValue());
|
|
|
|
if (c == Byte.TYPE) result[i]=new Byte(n.byteValue());
|
|
|
|
if (c == Short.TYPE) result[i]=new Short(n.shortValue());
|
|
|
|
if (c == Integer.TYPE) result[i]=new Integer(n.intValue());
|
|
|
|
if (c == Float.TYPE) result[i]=new Float(n.floatValue());
|
|
|
|
if (c == Long.TYPE && !(n instanceof Long))
|
|
|
|
result[i]=new Long(n.longValue());
|
2000-07-22 20:36:11 +00:00
|
|
|
} else if (args[i] instanceof Hashtable && parms[i].isArray()) {
|
|
|
|
try {
|
|
|
|
Hashtable ht = (Hashtable)args[i];
|
|
|
|
int size = ht.size();
|
|
|
|
|
|
|
|
// Verify that the keys are Long, and determine maximum
|
|
|
|
for (Enumeration e = ht.keys(); e.hasMoreElements(); ) {
|
|
|
|
int index = ((Long)e.nextElement()).intValue();
|
|
|
|
if (index >= size) size = index+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Object tempArray[] = new Object[size];
|
|
|
|
Class tempTarget[] = new Class[size];
|
|
|
|
Class targetType = parms[i].getComponentType();
|
|
|
|
|
|
|
|
// flatten the hash table into an array
|
|
|
|
for (int j=0; j<size; j++) {
|
|
|
|
tempArray[j] = ht.get(new Long(j));
|
|
|
|
if (tempArray[j] == null && targetType.isPrimitive())
|
|
|
|
throw new Exception("bail");
|
|
|
|
tempTarget[j] = targetType;
|
|
|
|
}
|
|
|
|
|
|
|
|
// coerce individual elements into the target type
|
|
|
|
Object coercedArray[] = coerce(tempTarget, tempArray);
|
|
|
|
|
|
|
|
// copy the results into the desired array type
|
|
|
|
Object array = Array.newInstance(targetType,size);
|
|
|
|
for (int j=0; j<size; j++) {
|
|
|
|
Array.set(array, j, coercedArray[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
result[i]=array;
|
|
|
|
} catch (Exception e) {
|
|
|
|
// leave result[i] alone...
|
|
|
|
}
|
1999-12-06 05:00:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
//
|
|
|
|
// Invoke a method on a given object
|
|
|
|
//
|
2000-07-09 04:16:31 +00:00
|
|
|
public void Invoke
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
(Object object, String method, Object args[], long result)
|
|
|
|
{
|
|
|
|
try {
|
1999-12-06 05:00:40 +00:00
|
|
|
Vector matches = new Vector();
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
1999-12-06 05:00:40 +00:00
|
|
|
// gather
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
for (Class jclass = object.getClass();;jclass=(Class)object) {
|
2000-02-20 12:09:34 +00:00
|
|
|
while (!Modifier.isPublic(jclass.getModifiers())) {
|
|
|
|
// OK, some joker gave us an instance of a non-public class
|
|
|
|
// This often occurs in the case of enumerators
|
|
|
|
// Substitute the first public interface in its place,
|
|
|
|
// and barring that, try the superclass
|
|
|
|
Class interfaces[] = jclass.getInterfaces();
|
|
|
|
jclass=jclass.getSuperclass();
|
|
|
|
for (int i=interfaces.length; i-->0;) {
|
|
|
|
if (Modifier.isPublic(interfaces[i].getModifiers())) {
|
|
|
|
jclass=interfaces[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
Method methods[] = jclass.getMethods();
|
|
|
|
for (int i=0; i<methods.length; i++) {
|
|
|
|
if (methods[i].getName().equalsIgnoreCase(method) &&
|
|
|
|
methods[i].getParameterTypes().length == args.length) {
|
1999-12-06 05:00:40 +00:00
|
|
|
matches.addElement(methods[i]);
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// try a second time with the object itself, if it is of type Class
|
1999-12-06 05:00:40 +00:00
|
|
|
if (!(object instanceof Class) || (jclass==object)) break;
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
|
2000-02-28 17:02:28 +00:00
|
|
|
Method selected = (Method)select(matches, args);
|
1999-12-06 05:00:40 +00:00
|
|
|
if (selected == null) throw new NoSuchMethodException(method);
|
|
|
|
|
2000-02-28 17:02:28 +00:00
|
|
|
Object coercedArgs[] = coerce(selected.getParameterTypes(), args);
|
1999-12-06 05:00:40 +00:00
|
|
|
setResult(result, selected.invoke(object, coercedArgs));
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
setException(result, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get or Set a property
|
|
|
|
//
|
2000-07-09 04:16:31 +00:00
|
|
|
public void GetSetProp
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
(Object object, String prop, Object args[], long result)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (Class jclass = object.getClass();;jclass=(Class)object) {
|
2000-02-28 17:02:28 +00:00
|
|
|
while (!Modifier.isPublic(jclass.getModifiers())) {
|
|
|
|
// OK, some joker gave us an instance of a non-public class
|
|
|
|
// Substitute the first public interface in its place,
|
|
|
|
// and barring that, try the superclass
|
|
|
|
Class interfaces[] = jclass.getInterfaces();
|
|
|
|
jclass=jclass.getSuperclass();
|
|
|
|
for (int i=interfaces.length; i-->0;) {
|
|
|
|
if (Modifier.isPublic(interfaces[i].getModifiers())) {
|
|
|
|
jclass=interfaces[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
BeanInfo beanInfo = Introspector.getBeanInfo(jclass);
|
|
|
|
PropertyDescriptor props[] = beanInfo.getPropertyDescriptors();
|
|
|
|
for (int i=0; i<props.length; i++) {
|
|
|
|
if (props[i].getName().equalsIgnoreCase(prop)) {
|
|
|
|
Method method;
|
|
|
|
if (args!=null && args.length>0) {
|
|
|
|
method=props[i].getWriteMethod();
|
2000-06-30 04:48:46 +00:00
|
|
|
args = coerce(method.getParameterTypes(), args);
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
} else {
|
|
|
|
method=props[i].getReadMethod();
|
|
|
|
}
|
|
|
|
setResult(result, method.invoke(object, args));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Field jfields[] = jclass.getFields();
|
|
|
|
for (int i=0; i<jfields.length; i++) {
|
|
|
|
if (jfields[i].getName().equalsIgnoreCase(prop)) {
|
|
|
|
if (args!=null && args.length>0) {
|
2000-06-30 04:48:46 +00:00
|
|
|
args = coerce(new Class[] {jfields[i].getType()}, args);
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
jfields[i].set(object, args[0]);
|
|
|
|
} else {
|
|
|
|
setResult(result, jfields[i].get(object));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// try a second time with the object itself, if it is of type Class
|
1999-12-06 05:00:40 +00:00
|
|
|
if (!(object instanceof Class) || (jclass==object)) break;
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
setException(result, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Helper routines for the C implementation
|
|
|
|
//
|
2000-07-09 04:16:31 +00:00
|
|
|
public Object MakeArg(boolean b) { return new Boolean(b); }
|
|
|
|
public Object MakeArg(long l) { return new Long(l); }
|
|
|
|
public Object MakeArg(double d) { return new Double(d); }
|
@ Added Zend OO syntax overloading support for Java components
#
# My lawyer made me do this:
#
Users of PHP are hereby granted a non-exclusive, irrevocable, world-wide,
royalty-free, non-transferable license to use, execute, prepare derivative
works of, and distribute (internally and externally, and including derivative
works) the code accompanying this license as part of, and integrated into PHP.
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT. THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF PHP. The owner of this code
represents and warrants that it is legally entitled to grant the above license.
1999-11-09 12:02:22 +00:00
|
|
|
}
|