Commit Graph

2088 Commits

Author SHA1 Message Date
waldemar%netscape.com
a1e085023c Changed attributes and 'language' statement syntax, added interfaces, and removed ^*, ^?, |*, and |?. 2000-04-28 02:34:14 +00:00
rginda%netscape.com
ac3f62e80e don't generate print_args if super_has_print
comment fixes
2000-04-28 02:33:36 +00:00
waldemar%netscape.com
a6891ee49a Changed period to dot 2000-04-28 02:31:41 +00:00
waldemar%netscape.com
cee3bc879e Fixed syntax of (bottom) 2000-04-28 02:30:44 +00:00
waldemar%netscape.com
9c8cec86f9 First Checked In. 2000-04-28 02:30:19 +00:00
rginda%netscape.com
2b82c98539 moved comment so it made more sense 2000-04-28 02:26:14 +00:00
beard%netscape.com
d30332fed4 reordered inheritance graph of Linkage. 2000-04-28 02:23:08 +00:00
rginda%netscape.com
4f2ea173c2 printarg stubbed out 2000-04-28 02:20:23 +00:00
beard%netscape.com
6b94a5aefc testProto() 2000-04-28 01:43:03 +00:00
rogerl%netscape.com
f399ef5301 try/catch exercise changes 2000-04-28 00:11:18 +00:00
rogerl%netscape.com
7b1fe9f1b1 fixed bad constructor thing. 2000-04-28 00:10:22 +00:00
norris%netscape.com
ff5f45db12 Propagate changes from 1.21.2.3 into tip. 2000-04-27 18:39:10 +00:00
rogerl%netscape.com
d96a9a02a4 More exception handling handling. 2000-04-27 01:27:09 +00:00
norris%netscape.com
a0d8c78c2d Allow multiple uses of importClass on the same class. 2000-04-26 23:47:15 +00:00
norris%netscape.com
a5493a0353 Fix bug 37317. 2000-04-26 23:33:25 +00:00
norris%netscape.com
70aa69f0a0 Fix NullPointerException caused by clearing cache 2000-04-26 22:48:48 +00:00
beard%netscape.com
fec4f17019 oops. 2000-04-26 22:10:20 +00:00
beard%netscape.com
328d338eaf removed JSMap::operator[], added set/getPrototype(). 2000-04-26 22:06:17 +00:00
beard%netscape.com
8ec53e3c09 oops getProperty() can't be const unless map.find() is used everywhere. 2000-04-26 21:48:04 +00:00
beard%netscape.com
4fb22b1f43 Using getProperty/setProperty rather than JSMap::operator[]. This follows the prototype chain. 2000-04-26 21:38:14 +00:00
beard%netscape.com
3610f211ce added JSMap::setProperty()/getProperty(), and a prototype field. 2000-04-26 21:27:44 +00:00
rginda%netscape.com
db9c7f1a2a initial add of debugger vapors 2000-04-26 06:04:02 +00:00
beard%netscape.com
3b3617a676 Fixing windows bustage in Linkage. 2000-04-26 05:56:20 +00:00
beard%netscape.com
c9140f3cfb fixing bug: js2.cpp:328: Internal compiler error in scope_die_for, at dwarf2out.c:7794 Please submit a full bug report. See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for instructions. 2000-04-26 05:43:24 +00:00
beard%netscape.com
4d54a513ae testFactorial() now installs a Context::Listener to trace execution. 2000-04-26 05:37:00 +00:00
beard%netscape.com
4996f07b77 JSActivation -> Activation, JSLinkage --> Linkage. Linkage now implements the Context::Frame interface. Implemented simple Context::Listener support. 2000-04-26 05:35:07 +00:00
beard%netscape.com
31c7fe60f7 Added Context::Frame, Context::Listener abstract classes. Initial support for debugger. 2000-04-26 05:29:35 +00:00
beard%netscape.com
51b10bdffb JSFrame -> JSLinkage, using explicit linked list rather than a stack. 2000-04-26 01:42:00 +00:00
beard%netscape.com
14e2fadb8c removed intentionally private JSActivation/JSFrame types. The debugger should be able to ask questions of the interpreter to obtain this information. 2000-04-26 01:39:56 +00:00
jband%netscape.com
4ca5f185a3 be less aggresive in shutdown cleanup to avoid shutdown crashes. See bug 37058 for an example stack. 2000-04-25 07:26:02 +00:00
jband%netscape.com
97a6fcc778 release the threadcontextstack to avoid a shutdown leak 2000-04-25 04:59:21 +00:00
jband%netscape.com
35d002f3fe Cleanup at shutdown the JSContexts that xpconnect manages on a per thread basis. This should fix some shutdown leaks. 2000-04-25 04:57:32 +00:00
beard%netscape.com
b33c70b006 changed Context constructor to take JSObject* not JSObject&, to be able to control lifetime a little more carefully. 2000-04-25 03:32:53 +00:00
beard%netscape.com
02525db2ed warning removal 2000-04-25 03:28:41 +00:00
beard%netscape.com
1bc1bc77d5 fixing mac bustage (we do reference argc/argv, to initialize them to something sensible). 2000-04-25 02:58:30 +00:00
beard%netscape.com
88208308b6 renamed not() -> complement() (not is a keyword in C++), implemented complement(). 2000-04-25 02:55:08 +00:00
brendan%mozilla.org
1a90497652 Final destroy-context must await racing GCs before freeing atom state (32525, r=jband). 2000-04-25 01:12:36 +00:00
rogerl%netscape.com
43a5e02de9 Fixes for handling missing params. 2000-04-24 22:40:53 +00:00
rginda%netscape.com
cdf10d48f2 adding comments 2000-04-24 21:43:49 +00:00
rginda%netscape.com
9366e18dd5 NotARegister check in GenericBranch::print() 2000-04-24 20:08:16 +00:00
norris%netscape.com
600d365e30 Patch from Matthias Radestock <rade@logee.com>:
Subject:
             JavaAdapter return type conversion
        Date:
             Wed, 19 Apr 2000 12:12:47 +0100
       From:
             Matthias Radestock <rade@logee.com>
 Organization:
             Logee
         To:
             norris@netscape.com
         CC:
             mccabe@netscape.com, beard@netscape.com, rogerl@netscape.com




Dear Rhino team,

When returning an array from a scripted Java object (i.e. a JS object
that implements a Java interface), no type conversion is performed, ie.
a NativeArray is returned instead of a Java array. Example:

Java:
interface Foo {
        public String[] boo();
        }

JS:
FooI = {
        boo: function() { return ["Boo"];}
        }
myFoo = new Packages.Foo(FooI);
myFoo.boo(); //==> breaks with a ClassCastException


Looking at the JavaAdapter code, there is no code for array conversion.
This is particularly bad because precisely such a conversion *does*
happen when calling a Java method from JS. So we end up with a
discrepancy.

See attachment for a patch to fix this and little test program. The
patch works by calling the coerceType function on NativeJavaObject,
which is the function responsible for doing the conversion when calling
from JS to Java. I've simplified the code so that this function gets
called for all non-primitive return type, not just arrays. There are
probably more efficient solutions but I'm not a Java bytecode hacker.


Matthias
PS: I didn't open a bug for this because I wasn't sure whether you guys
would agree that this is indeed a problem ;)





public interface JSReturnTest {

  public boolean returnBoolean();
  public char returnChar();
  public int returnInt();
  public String returnString();
  public org.mozilla.javascript.Scriptable returnScriptable();
  public Object returnObject();
  public boolean[] returnBooleanA();
  public char[] returnCharA();
  public int[] returnIntA();
  public String[] returnStringA();
  public org.mozilla.javascript.Scriptable[] returnScriptableA();
  public Object[] returnObjectA();
  public Object[][] returnObjectAA();
}




Index: JavaAdapter.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/JavaAdapter.java,v
retrieving revision 1.21
diff -r1.21 JavaAdapter.java
54c54,59
<
---
>
>     public static Object convertResult(Object result, String classname)
>     throws ClassNotFoundException {
>         return NativeJavaObject.coerceType(Class.forName(classname),
>                                            result);
>     }
467,474c472,474
<         } else  if (retType.equals(String.class)) {
<             cfw.add(ByteCode.INVOKESTATIC,
<                     "org/mozilla/javascript/Context",
<                     "toString", "(Ljava/lang/Object;)",
<                     "Ljava/lang/String;");
<             cfw.add(ByteCode.ARETURN);
<         } else if (retType.equals(Scriptable.class)) {
<             cfw.add(ByteCode.ALOAD_0);  // load 'this' to find scope from
---
>         } else {
>             String retTypeStr = retType.getName();
>             cfw.addLoadConstant(retTypeStr);
476,477c476,477
<                     "org/mozilla/javascript/Context",
<                     "toObject",
---
>                     "org/mozilla/javascript/JavaAdapter",
>                     "convertResult",
479,500c479,480
<                      "Lorg/mozilla/javascript/Scriptable;)",
<                     "Lorg/mozilla/javascript/Scriptable;");
<             cfw.add(ByteCode.ARETURN);
<         } else {
<             // If it is a wrapped type, cast to Wrapper and call unwrap()
<             cfw.add(ByteCode.DUP);
<             cfw.add(ByteCode.INSTANCEOF, "org/mozilla/javascript/Wrapper");
<             // skip 3 for IFEQ, 3 for CHECKCAST, and 5 for INVOKEINTERFACE
<             cfw.add(ByteCode.IFEQ, 11);
<             cfw.add(ByteCode.CHECKCAST, "org/mozilla/javascript/Wrapper");
<             cfw.add(ByteCode.INVOKEINTERFACE,
<                     "org/mozilla/javascript/Wrapper",
<                     "unwrap", "()", "Ljava/lang/Object;");
<
<             // If Undefined, return null
<             cfw.add(ByteCode.DUP);
<             cfw.add(ByteCode.INSTANCEOF, "org/mozilla/javascript/Undefined");
<             // skip 3 for IFEQ, 1 for ACONST_NULL, 1 for ARETURN
<             cfw.add(ByteCode.IFEQ, 5);
<             cfw.add(ByteCode.ACONST_NULL);
<             cfw.add(ByteCode.ARETURN);
<
---
>                     "Ljava/lang/String;)",
>                     "Ljava/lang/Object;");
502,503c482
<             String retTypeStr = retType.getName().replace('.', '/');
<             cfw.add(ByteCode.CHECKCAST, retTypeStr);
---
>             cfw.add(ByteCode.CHECKCAST, retTypeStr.replace('.', '/'));



   testpatch.js

               Name:
                     testpatch.js
                Type:
                     JavaScript Program (application/x-javascript)
             Encoding:
                     7bit
2000-04-24 19:36:51 +00:00
rginda%netscape.com
9c545008e5 quieting linux warnings 2000-04-24 18:41:05 +00:00
jband%netscape.com
fbf36f7076 belt and suspenders check of WITH_SERVICE results 2000-04-23 23:04:40 +00:00
jband%netscape.com
98eeec5119 fix a dangerous looking (but harmless) warning on Mac opt 2000-04-22 01:06:42 +00:00
rogerl%netscape.com
adfcfe0dca Added a beginning for exception handling. 2000-04-21 22:52:52 +00:00
mccabe%netscape.com
610a029cf5 Fix to 23532. Check validity of JS_ARENA_ALLOCATE call before using it as an argument of memcpy in JS_ArenaGrow.
Thanks to wyeung@real.com for noticing we were being unsafe here and suggesting the fix.
2000-04-21 09:25:43 +00:00
brendan%mozilla.org
27df4eb10b Spruce up a couple of comments. 2000-04-21 01:49:49 +00:00
brendan%mozilla.org
3bdfa83a05 Functions that use unqualified __parent__ or __proto__ must be heavyweight (36625, r=shaver). 2000-04-21 01:47:20 +00:00
rginda%netscape.com
8007074ccd Add nsIScriptError.idl. Build it here rather than back in xpfe/components/console. Checkin by McCabe, on rginda's mac. 2000-04-21 00:57:27 +00:00
rogerl%netscape.com
4683e4c869 oops 2000-04-21 00:46:48 +00:00