mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 07:19:22 +00:00
API + javadoc
This commit is contained in:
parent
1a7bf028fe
commit
e8b127deef
@ -2,7 +2,7 @@ package def.js;
|
|||||||
/**
|
/**
|
||||||
* Creates a new function.
|
* Creates a new function.
|
||||||
*/
|
*/
|
||||||
public class Function extends def.js.Object {
|
public class Function extends def.js.Object implements FunctionalObject {
|
||||||
/**
|
/**
|
||||||
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
|
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
|
||||||
* @param thisArg The object to be used as the this object.
|
* @param thisArg The object to be used as the this object.
|
||||||
@ -40,5 +40,8 @@ public class Function extends def.js.Object {
|
|||||||
native public java.lang.Object apply(java.lang.Object thisArg);
|
native public java.lang.Object apply(java.lang.Object thisArg);
|
||||||
native public java.lang.Object caller(java.lang.Object... args);
|
native public java.lang.Object caller(java.lang.Object... args);
|
||||||
protected Function(){}
|
protected Function(){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
native public <R> R $apply(Object... arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
core-lib/es5/src/main/java/def/js/FunctionalObject.java
Normal file
19
core-lib/es5/src/main/java/def/js/FunctionalObject.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package def.js;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines the <code>$apply</code> signature that allows invoking
|
||||||
|
* an object.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The code <code>o.$apply(args)</code> is transpiled to <code>o(args)</code>.
|
||||||
|
* Implementing this interface is not mandatory to create a functional object.
|
||||||
|
* Just defining the <code>$apply</code> function is enough. It is however
|
||||||
|
* recommended to implement this interface for readbility sake.
|
||||||
|
*
|
||||||
|
* @author Renaud Pawlak
|
||||||
|
*/
|
||||||
|
public interface FunctionalObject {
|
||||||
|
|
||||||
|
<R> R $apply(Object... arguments);
|
||||||
|
|
||||||
|
}
|
||||||
@ -26,11 +26,6 @@ import java.lang.annotation.Target;
|
|||||||
* This annotation type is used on elements that should be erased at generation
|
* This annotation type is used on elements that should be erased at generation
|
||||||
* time (casts and constructor invocations are removed).
|
* time (casts and constructor invocations are removed).
|
||||||
*
|
*
|
||||||
* <p>
|
|
||||||
* This is mainly used for Java type disambiguation when the API defines two
|
|
||||||
* methods that have the same erasure. Most programmers will not have to use it
|
|
||||||
* directly.
|
|
||||||
*
|
|
||||||
* @author Renaud Pawlak
|
* @author Renaud Pawlak
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|||||||
@ -32,8 +32,7 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The replacing code can contain variables substituted using a mustache-like
|
* The replacing code can contain variables substituted using a mustache-like
|
||||||
* convention ({{variableName}}). Note that no space is allowed between the
|
* convention ({{variableName}}). Here is the list of supported variables:
|
||||||
* variable name and the mustaches. Here is the list of supported variables:
|
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{{className}}: the current class.</li>
|
* <li>{{className}}: the current class.</li>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package def.js;
|
|||||||
/**
|
/**
|
||||||
* Creates a new function.
|
* Creates a new function.
|
||||||
*/
|
*/
|
||||||
public class Function extends def.js.Object {
|
public class Function extends def.js.Object implements FunctionalObject {
|
||||||
/**
|
/**
|
||||||
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
|
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
|
||||||
* @param thisArg The object to be used as the this object.
|
* @param thisArg The object to be used as the this object.
|
||||||
@ -49,5 +49,8 @@ public class Function extends def.js.Object {
|
|||||||
native public java.lang.Object apply(java.lang.Object thisArg);
|
native public java.lang.Object apply(java.lang.Object thisArg);
|
||||||
native public java.lang.Object caller(java.lang.Object... args);
|
native public java.lang.Object caller(java.lang.Object... args);
|
||||||
protected Function(){}
|
protected Function(){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
native public <R> R $apply(Object... arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
core-lib/es6/src/main/java/def/js/FunctionalObject.java
Normal file
19
core-lib/es6/src/main/java/def/js/FunctionalObject.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package def.js;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines the <code>$apply</code> signature that allows invoking
|
||||||
|
* an object.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The code <code>o.$apply(args)</code> is transpiled to <code>o(args)</code>.
|
||||||
|
* Implementing this interface is not mandatory to create a functional object.
|
||||||
|
* Just defining the <code>$apply</code> function is enough. It is however
|
||||||
|
* recommended to implement this interface for readbility sake.
|
||||||
|
*
|
||||||
|
* @author Renaud Pawlak
|
||||||
|
*/
|
||||||
|
public interface FunctionalObject {
|
||||||
|
|
||||||
|
<R> R $apply(Object... arguments);
|
||||||
|
|
||||||
|
}
|
||||||
@ -26,11 +26,6 @@ import java.lang.annotation.Target;
|
|||||||
* This annotation type is used on elements that should be erased at generation
|
* This annotation type is used on elements that should be erased at generation
|
||||||
* time (casts and constructor invocations are removed).
|
* time (casts and constructor invocations are removed).
|
||||||
*
|
*
|
||||||
* <p>
|
|
||||||
* This is mainly used for Java type disambiguation when the API defines two
|
|
||||||
* methods that have the same erasure. Most programmers will not have to use it
|
|
||||||
* directly.
|
|
||||||
*
|
|
||||||
* @author Renaud Pawlak
|
* @author Renaud Pawlak
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|||||||
@ -32,8 +32,7 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The replacing code can contain variables substituted using a mustache-like
|
* The replacing code can contain variables substituted using a mustache-like
|
||||||
* convention ({{variableName}}). Note that no space is allowed between the
|
* convention ({{variableName}}). Here is the list of supported variables:
|
||||||
* variable name and the mustaches. Here is the list of supported variables:
|
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{{className}}: the current class.</li>
|
* <li>{{className}}: the current class.</li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user