Skip to content

Commit 603f73d

Browse files
committed
Removed support for customConversion
1 parent b207e4d commit 603f73d

File tree

3 files changed

+7
-45
lines changed

3 files changed

+7
-45
lines changed

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,6 @@
6464
*/
6565
ClinicConversion conversion() default ClinicConversion.None;
6666

67-
/**
68-
* Overrides the {@link #conversion()} value. Name of a method of the builtin class that should
69-
* be used as a factory to create the conversion node. When this value is set, then other
70-
* conversion options are ignored.
71-
*/
72-
String customConversion() default "";
73-
74-
/**
75-
* The boxing optimized execute method variants will not attempt to cast the listed primitive
76-
* types and will just pass them directly to the specializations. This does not apply to
77-
* primitive values that are already boxed: those are always passed to the converter.
78-
*
79-
* It is not necessary to set this when using a builtin conversion or
80-
* {@link #conversionClass()}. Built-in converters and {@link ClinicConverterFactory} provide
81-
* their own list of short circuit types, which is applied if this field is set to its default
82-
* value.
83-
*/
84-
PrimitiveType[] shortCircuitPrimitive() default {};
85-
8667
/**
8768
* The string should contain valid Java constant value expression, for example, {@code true}, or
8869
* {@code \"some string\"}. You may have to update the annotation processor to include import of
@@ -98,14 +79,13 @@
9879

9980
/**
10081
* Specifies the name of the conversion node class, which must include a static factory method
101-
* annotated with {@link ClinicConverterFactory}. Must not be used with
102-
* {@link #customConversion()}.
82+
* annotated with {@link ClinicConverterFactory}.
10383
*/
10484
Class<?> conversionClass() default void.class;
10585

10686
/**
107-
* Specifies arguments to the factory method, applicable only with {@link #conversionClass()}.
108-
* String literals must be explicitly quoted: {@code args = "\"abc\""}
87+
* Specifies arguments to the factory method. String literals must be explicitly quoted:
88+
* {@code args = "\"abc\""}
10989
*/
11090
String[] args() default {};
11191

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ private static ConverterFactory getFactory(ArgumentClinic annotation, TypeElemen
120120
if (factory == null && annotation.args().length != 0) {
121121
throw new ProcessingError(type, "No conversionClass specified but arguments were provided");
122122
}
123-
if (!annotation.customConversion().isEmpty()) {
124-
if (factory != null) {
125-
throw new ProcessingError(type, "Cannot specify both conversionClass and customConversion");
126-
}
127-
return ConverterFactory.forCustomConversion(type, annotation.customConversion());
128-
}
129123
if (factory != null) {
130124
return factory;
131125
}
@@ -135,22 +129,16 @@ private static ConverterFactory getFactory(ArgumentClinic annotation, TypeElemen
135129
return ConverterFactory.getBuiltin(annotation);
136130
}
137131

138-
public static ArgumentClinicData create(ArgumentClinic annotation, TypeElement type, BuiltinAnnotation builtinAnnotation, int index, ConverterFactory ofactory) throws ProcessingError {
132+
public static ArgumentClinicData create(ArgumentClinic annotation, TypeElement type, BuiltinAnnotation builtinAnnotation, int index, ConverterFactory annotationFactory)
133+
throws ProcessingError {
139134
if (annotation == null) {
140135
return new ArgumentClinicData(null, index, new HashSet<>(Arrays.asList(PrimitiveType.values())), null, Collections.emptySet());
141136
}
142-
ConverterFactory factory = getFactory(annotation, type, ofactory);
137+
ConverterFactory factory = getFactory(annotation, type, annotationFactory);
143138
if (annotation.args().length != factory.extraParamCount) {
144139
throw new ProcessingError(type, "Conversion %s.%s expects %d arguments", factory.fullClassName, factory.methodName, factory.extraParamCount);
145140
}
146141

147-
PrimitiveType[] acceptedPrimitives;
148-
if (annotation.shortCircuitPrimitive().length > 0) {
149-
acceptedPrimitives = annotation.shortCircuitPrimitive();
150-
} else {
151-
acceptedPrimitives = factory.acceptedPrimitiveTypes;
152-
}
153-
154142
String[] args = new String[factory.params.length];
155143
int extraParamIndex = 0;
156144
for (int i = 0; i < args.length; ++i) {
@@ -184,7 +172,7 @@ public static ArgumentClinicData create(ArgumentClinic annotation, TypeElement t
184172
imports.add("com.oracle.graal.python.builtins.objects.PNone");
185173
}
186174

187-
return new ArgumentClinicData(annotation, index, new HashSet<>(Arrays.asList(acceptedPrimitives)), castNodeFactory, imports);
175+
return new ArgumentClinicData(annotation, index, new HashSet<>(Arrays.asList(factory.acceptedPrimitiveTypes)), castNodeFactory, imports);
188176
}
189177
}
190178
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ public static ConverterFactory getForClass(TypeElement conversionClass) throws P
184184
return factory;
185185
}
186186

187-
public static ConverterFactory forCustomConversion(TypeElement type, String methodName) {
188-
String fullClassName = type.getQualifiedName().toString();
189-
String className = type.getSimpleName().toString();
190-
return new ConverterFactory(fullClassName, className, methodName, 0, new Param[0], new PrimitiveType[0]);
191-
}
192-
193187
private static ConverterFactory forBuiltin(Elements elementUtils, String className) throws ProcessingError {
194188
TypeElement type = elementUtils.getTypeElement(CLINIC_PACKAGE + "." + className);
195189
if (type == null) {

0 commit comments

Comments
 (0)