Skip to content

Commit 2b08b7e

Browse files
committed
Rename ConversionFactory and move to top level
1 parent eec579c commit 2b08b7e

File tree

6 files changed

+60
-53
lines changed

6 files changed

+60
-53
lines changed

graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/ArgumentClinic.java

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
* primitive values that are already boxed: those are always passed to the convertor.
7878
*
7979
* It is not necessary to set this when using a builtin conversion or
80-
* {@link #conversionClass()}. Built-in convertors and {@link ConversionFactory} provide their
80+
* {@link #conversionClass()}. Built-in convertors and {@link ClinicConverterFactory} provide their
8181
* own list of short circuit types, which is applied if this field is set to its default value.
8282
*/
8383
PrimitiveType[] shortCircuitPrimitive() default {};
@@ -97,7 +97,7 @@
9797

9898
/**
9999
* Specifies the name of the conversion node class, which must include a static factory method
100-
* annotated with {@link ConversionFactory}. Must not be used with {@link #customConversion()}.
100+
* annotated with {@link ClinicConverterFactory}. Must not be used with {@link #customConversion()}.
101101
*/
102102
Class<?> conversionClass() default void.class;
103103

@@ -149,49 +149,4 @@ enum ClinicConversion {
149149
*/
150150
Buffer,
151151
}
152-
153-
/**
154-
* Annotates the factory method (which must be static) in the class specified by
155-
* {@link #conversionClass()}.
156-
*/
157-
@Target(ElementType.METHOD)
158-
@interface ConversionFactory {
159-
160-
/**
161-
* Specifies which arguments will be provided by the clinic. These are passed to the factory
162-
* method before the argument supplied in {@link #args()}.
163-
*/
164-
ClinicArgument[] clinicArgs() default {};
165-
166-
/**
167-
* The boxing optimized execute method variants will not attempt to cast the listed
168-
* primitive types and will just pass them directly to the specializations. This does not
169-
* apply to primitive values that are already boxed: those are always passed to the
170-
* convertor.
171-
*/
172-
PrimitiveType[] shortCircuitPrimitive() default {};
173-
174-
enum ClinicArgument {
175-
/**
176-
* The default value {@link #defaultValue()}.
177-
*/
178-
DefaultValue,
179-
/**
180-
* The flag {@link #useDefaultForNone()}.
181-
*/
182-
UseDefaultForNone,
183-
/**
184-
* The name of the builtin function.
185-
*/
186-
BuiltinName,
187-
/**
188-
* The index of the argument.
189-
*/
190-
ArgumentIndex,
191-
/**
192-
* The name of the argument.
193-
*/
194-
ArgumentName,
195-
}
196-
}
197152
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.oracle.graal.python.annotations;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Target;
5+
6+
/**
7+
* Annotates the factory method (which must be static) in the class specified by
8+
* {@link ArgumentClinic#conversionClass()}.
9+
*/
10+
@Target(ElementType.METHOD)
11+
public @interface ClinicConverterFactory {
12+
13+
/**
14+
* Specifies which arguments will be provided by the clinic. These are passed to the factory
15+
* method before the argument supplied in {@link ArgumentClinic#args()}.
16+
*/
17+
ClinicArgument[] clinicArgs() default {};
18+
19+
/**
20+
* The boxing optimized execute method variants will not attempt to cast the listed
21+
* primitive types and will just pass them directly to the specializations. This does not
22+
* apply to primitive values that are already boxed: those are always passed to the
23+
* convertor.
24+
*/
25+
ArgumentClinic.PrimitiveType[] shortCircuitPrimitive() default {};
26+
27+
enum ClinicArgument {
28+
/**
29+
* The default value {@link ArgumentClinic#defaultValue()}.
30+
*/
31+
DefaultValue,
32+
/**
33+
* The flag {@link ArgumentClinic#useDefaultForNone()}.
34+
*/
35+
UseDefaultForNone,
36+
/**
37+
* The name of the builtin function.
38+
*/
39+
BuiltinName,
40+
/**
41+
* The index of the argument.
42+
*/
43+
ArgumentIndex,
44+
/**
45+
* The name of the argument.
46+
*/
47+
ArgumentName,
48+
}
49+
}

graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/ArgumentClinicProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import com.oracle.graal.python.annotations.ArgumentClinic;
7272
import com.oracle.graal.python.annotations.ArgumentClinic.PrimitiveType;
7373
import com.oracle.graal.python.annotations.ArgumentsClinic;
74+
import com.oracle.graal.python.annotations.ClinicConverterFactory;
7475
import com.oracle.graal.python.processor.ArgumentClinicModel.ArgumentClinicData;
7576
import com.oracle.graal.python.processor.ArgumentClinicModel.BuiltinAnnotation;
7677
import com.oracle.graal.python.processor.ArgumentClinicModel.BuiltinClinicData;
@@ -87,7 +88,7 @@ public Set<String> getSupportedAnnotationTypes() {
8788
HashSet<String> vals = new HashSet<>();
8889
vals.add(ArgumentClinic.class.getName());
8990
vals.add(ArgumentsClinic.class.getName());
90-
vals.add(ArgumentClinic.ConversionFactory.class.getName());
91+
vals.add(ClinicConverterFactory.class.getName());
9192
return vals;
9293
}
9394

graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/ConverterFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242

4343
import com.oracle.graal.python.annotations.ArgumentClinic;
4444
import com.oracle.graal.python.annotations.ArgumentClinic.PrimitiveType;
45-
import com.oracle.graal.python.annotations.ArgumentClinic.ConversionFactory.ClinicArgument;
45+
import com.oracle.graal.python.annotations.ClinicConverterFactory;
46+
import com.oracle.graal.python.annotations.ClinicConverterFactory.ClinicArgument;
4647

4748
import javax.lang.model.element.Element;
4849
import javax.lang.model.element.ElementKind;
@@ -137,7 +138,7 @@ public static ConverterFactory getForClass(TypeElement conversionClass) throws P
137138
return factory;
138139
}
139140
for (Element e : conversionClass.getEnclosedElements()) {
140-
ArgumentClinic.ConversionFactory annot = e.getAnnotation(ArgumentClinic.ConversionFactory.class);
141+
ClinicConverterFactory annot = e.getAnnotation(ClinicConverterFactory.class);
141142
if (annot != null) {
142143
if (!e.getModifiers().contains(Modifier.STATIC) || e.getKind() != ElementKind.METHOD) {
143144
throw new ProcessingError(conversionClass, "ConversionFactory annotation is applicable only to static methods.");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import java.util.Arrays;
5050

5151
import com.oracle.graal.python.PythonLanguage;
52-
import com.oracle.graal.python.annotations.ArgumentClinic;
52+
import com.oracle.graal.python.annotations.ClinicConverterFactory;
5353
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5454
import com.oracle.graal.python.builtins.modules.SysModuleBuiltins;
5555
import com.oracle.graal.python.builtins.objects.PNone;
@@ -580,7 +580,7 @@ Object doOthers(@SuppressWarnings("unused") VirtualFrame frame, Object value) {
580580
throw raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, className(), argNum, PythonBuiltinClassType.PString, value);
581581
}
582582

583-
@ArgumentClinic.ConversionFactory(clinicArgs = {ArgumentClinic.ConversionFactory.ClinicArgument.ArgumentIndex})
583+
@ClinicConverterFactory(clinicArgs = {ClinicConverterFactory.ClinicArgument.ArgumentIndex})
584584
public static ExpectStringNode create(int argNum, String className) {
585585
return BytesNodesFactory.ExpectStringNodeGen.create(argNum, className);
586586
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
import com.oracle.graal.python.annotations.ArgumentClinic;
4949
import com.oracle.graal.python.annotations.ArgumentClinic.PrimitiveType;
50+
import com.oracle.graal.python.annotations.ClinicConverterFactory;
5051
import com.oracle.graal.python.builtins.Builtin;
5152
import com.oracle.graal.python.builtins.CoreFunctions;
5253
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -135,7 +136,7 @@ int doOthers(VirtualFrame frame, Object value,
135136
throw raise(TypeError, ErrorMessages.SLICE_INDICES_TYPE_ERROR);
136137
}
137138

138-
@ArgumentClinic.ConversionFactory(shortCircuitPrimitive = PrimitiveType.Int, clinicArgs = {ArgumentClinic.ConversionFactory.ClinicArgument.DefaultValue})
139+
@ClinicConverterFactory(shortCircuitPrimitive = PrimitiveType.Int, clinicArgs = {ClinicConverterFactory.ClinicArgument.DefaultValue})
139140
public static SliceIndexNode create(int defaultValue) {
140141
return SliceIndexNodeGen.create(defaultValue);
141142
}

0 commit comments

Comments
 (0)