diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2016-08-04 14:29:18 +0000 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2016-08-04 15:18:06 +0000 |
commit | 2d32c586cbaa61a158637224e0d2cfedb4c4b45d (patch) | |
tree | a896318f609fbc5f60a23c8bd5619401f7068413 /src/main/java/com/google/devtools/build/lib/skylarkinterface | |
parent | a8a8f75910a75d4803ca08583f58c9633a16164b (diff) |
Enable named arguments for SkylarkCallable annotation
This just add the support on the Skylark side, the documentation generator
still needs to be updated.
--
Change-Id: Ic26547cdb8d2c5c01839a4014c10f1b9b209b92b
Reviewed-on: https://bazel-review.googlesource.com/#/c/4247/
MOS_MIGRATED_REVID=129328278
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkinterface')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkCallable.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkCallable.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkCallable.java index 86d2c88e3d..1b193fe1f1 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkCallable.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkCallable.java @@ -45,12 +45,27 @@ public @interface SkylarkCallable { /** * If true, this method will be considered as a field of the enclosing Java object. E.g., if set - * to true on a method {@code foo}, then the callsites of this method will look like - * {@code bar.foo} instead of {@code bar.foo()}. The annotated method must be parameterless. + * to true on a method {@code foo}, then the callsites of this method will look like {@code + * bar.foo} instead of {@code bar.foo()}. The annotated method must be parameterless and {@link + * #parameters()} should be empty. */ boolean structField() default false; /** + * Number of parameters in the signature that are mandatory positional parameters. Any parameter + * after {@link #mandatoryPositionals()} must be specified in {@link #parameters()}. A negative + * value (default is {@code -1}), means that all arguments are mandatory positionals if {@link + * #parameters()} remains empty. If {@link #parameters()} is non empty, then a negative value for + * {@link #mandatoryPositionals()} is taken as 0. + */ + int mandatoryPositionals() default -1; + + /** + * List of parameters this function accept after the {@link #mandatoryPositionals()} parameters. + */ + Param[] parameters() default {}; + + /** * Set it to true if the Java method may return <code>null</code> (which will then be converted to * <code>None</code>). If not set and the Java method returns null, an error will be raised. */ |