Closed
Bug 108719
Opened 23 years ago
Closed 22 years ago
FunctionObject.getDeclaringClass() unambiguously identifies wrapped method
Categories
(Rhino Graveyard :: Core, enhancement)
Rhino Graveyard
Core
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: john, Assigned: norrisboyd)
Details
Attachments
(1 file)
1.05 KB,
patch
|
Details | Diff | Splinter Review |
In an IdScriptable/ jsFunction context, both arguments and "thisObj" can be a
function with scope "global" and prototype "function". If we want the class to
which the wrapped function is a member -- in order to call another function for
example user help about the function, our options are limited.
For example, implementing `help(name)' or equivalently "help('name')" where name
evaluates to a known (constructor or) function.
`FunctionObject.getDeclaringClass()' returns the `Method.getDeclaringClass' when
`method' is not null.
In org/mozilla/javascript/FunctionObject:
/**
* If the method exists in the current state, return the Java
* class of which this function's method is a member. Otherwise
* return null. */
public Class getDeclaringClass(){
if ( null != method)
return method. getDeclaringClass();
else
return null;
}
This appears to work well.
An alternative would be for FunctionObject to implement Wrapper, and unwrap to
Method. This may or may not be appropriate, I'm not sure.
Comment 1•22 years ago
|
||
The new method returns Method or Constructor instance that FunctionObject
represents which can be used to get their declared class as well.
I do not think implementing Wrapper interface by FunctionObject is a good idea.
AFAICS it is only useful when calling Java methods that take Method or
Constructor arguments which is rare. An other hand it would unwrap
FunctionObject when calling to Java methods taking Object as argument like
Array or Hashtable methods. Which in turn would make FunctionObject to behaves
differently from other Function instances which is unnatural.
Comment 2•22 years ago
|
||
I committed the patch.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•