Fix bug in ScriptableObject that make classes with jsGet_ but not jsFunction_ work improperly.

Also update Foo example to conform to new defineClass API.


git-svn-id: svn://10.0.0.236/trunk@38406 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
norris%netscape.com 1999-07-06 17:13:33 +00:00
parent ca33cfa3da
commit ac3c06b6c9
3 changed files with 16 additions and 4 deletions

View File

@ -96,7 +96,7 @@ public class Foo extends ScriptableObject {
*
* Resets the counter to 0.
*/
public void resetCounter() {
public void jsFunction_resetCounter() {
counter = 0;
}
@ -106,7 +106,7 @@ public class Foo extends ScriptableObject {
* If "setCounter" had been defined in this class, the runtime would
* call the setter when the property is assigned to.
*/
public int getCounter() {
public int jsGet_counter() {
return counter++;
}
@ -128,8 +128,8 @@ public class Foo extends ScriptableObject {
* thread is not associated with a Context
* @see org.mozilla.javascript.ScriptableObject#getTopLevelScope
*/
public static Object varargs(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
public static Object jsFunction_varargs(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
{
StringBuffer buf = new StringBuffer();
buf.append("this = ");

View File

@ -787,6 +787,12 @@ public abstract class ScriptableObject implements Scriptable {
prefix = functionPrefix;
else if (name.startsWith(staticFunctionPrefix))
prefix = staticFunctionPrefix;
else if (name.startsWith(propertyPrefix))
prefix = propertyPrefix;
else if (name.startsWith(getterPrefix))
prefix = getterPrefix;
else if (name.startsWith(setterPrefix))
prefix = setterPrefix;
if (prefix != null) {
hasPrefix = true;
name = name.substring(prefix.length());

View File

@ -787,6 +787,12 @@ public abstract class ScriptableObject implements Scriptable {
prefix = functionPrefix;
else if (name.startsWith(staticFunctionPrefix))
prefix = staticFunctionPrefix;
else if (name.startsWith(propertyPrefix))
prefix = propertyPrefix;
else if (name.startsWith(getterPrefix))
prefix = getterPrefix;
else if (name.startsWith(setterPrefix))
prefix = setterPrefix;
if (prefix != null) {
hasPrefix = true;
name = name.substring(prefix.length());