@@ -157,17 +157,15 @@ private static String name(VariableElement obj) {
157157 private static final class CApiBuiltinDesc {
158158 public final Element origin ;
159159 public final String name ;
160- public final boolean inlined ;
161160 public final VariableElement [] arguments ;
162161 public final VariableElement returnType ;
163162 public final String call ;
164163 public final String factory ;
165164 public int id ;
166165
167- public CApiBuiltinDesc (Element origin , String name , boolean inlined , VariableElement returnType , VariableElement [] arguments , String call , String factory ) {
166+ public CApiBuiltinDesc (Element origin , String name , VariableElement returnType , VariableElement [] arguments , String call , String factory ) {
168167 this .origin = origin ;
169168 this .name = name ;
170- this .inlined = inlined ;
171169 this .returnType = returnType ;
172170 this .arguments = arguments ;
173171 this .call = call ;
@@ -350,10 +348,10 @@ private void addCApiBuiltins(RoundEnvironment re, List<CApiBuiltinDesc> javaBuil
350348 }
351349 var ret = findValue (builtin , "ret" , VariableElement .class );
352350 String call = name (findValue (builtin , "call" , VariableElement .class ));
353- boolean inlined = findValue (builtin , "inlined" , Boolean .class );
351+ // boolean inlined = findValue(builtin, "inlined", Boolean.class);
354352 VariableElement [] args = findValues (builtin , "args" , VariableElement .class ).toArray (new VariableElement [0 ]);
355353 if (((TypeElement ) element ).getQualifiedName ().toString ().equals ("com.oracle.graal.python.builtins.objects.cext.capi.CApiFunction.Dummy" )) {
356- additionalBuiltins .add (new CApiBuiltinDesc (element , builtinName , inlined , ret , args , call , null ));
354+ additionalBuiltins .add (new CApiBuiltinDesc (element , builtinName , ret , args , call , null ));
357355 } else {
358356 if (!isValidReturnType (ret )) {
359357 processingEnv .getMessager ().printError (
@@ -380,7 +378,7 @@ private void addCApiBuiltins(RoundEnvironment re, List<CApiBuiltinDesc> javaBuil
380378 genName += "NodeGen" ;
381379 }
382380 verifyNodeClass (((TypeElement ) element ), builtin );
383- javaBuiltins .add (new CApiBuiltinDesc (element , name , inlined , ret , args , call , genName ));
381+ javaBuiltins .add (new CApiBuiltinDesc (element , name , ret , args , call , genName ));
384382 }
385383 }
386384 }
@@ -522,21 +520,25 @@ private void generateCApiSource(List<CApiBuiltinDesc> javaBuiltins, List<String>
522520 lines .add (" return sizes;" );
523521 lines .add ("}" );
524522
523+ updateResource ("capi.gen.c.h" , javaBuiltins , lines );
524+ }
525+
526+ private void updateResource (String name , List <CApiBuiltinDesc > javaBuiltins , List <String > lines ) throws IOException {
525527 var origins = javaBuiltins .stream ().map ((jb ) -> jb .origin ).toArray (Element []::new );
526528 String oldContents = "" ;
527529 String newContents = String .join (System .lineSeparator (), lines );
528530 try {
529- oldContents = processingEnv .getFiler ().getResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , "capi.gen.c.h" ).getCharContent (true ).toString ();
531+ oldContents = processingEnv .getFiler ().getResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , name ).getCharContent (true ).toString ();
530532 } catch (IOException e ) {
531533 // pass to regenerate
532534 }
533535 if (!oldContents .equals (newContents )) {
534- var file = processingEnv .getFiler ().createResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , "capi.gen.c.h" , origins );
536+ var file = processingEnv .getFiler ().createResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , name , origins );
535537 try (var w = file .openWriter ()) {
536538 w .append (newContents );
537539 }
538540 } else {
539- processingEnv .getMessager ().printNote ("Python capi.gen.c.h is up to date" );
541+ processingEnv .getMessager ().printNote ("Python %s is up to date" . formatted ( name ) );
540542 }
541543 }
542544
@@ -597,22 +599,7 @@ private void generateCApiHeader(List<CApiBuiltinDesc> javaBuiltins, Map<String,
597599 lines .add ("#define " + entry .getKey () + " " + entry .getValue ());
598600 }
599601
600- var origins = javaBuiltins .stream ().map ((jb ) -> jb .origin ).toArray (Element []::new );
601- String oldContents = "" ;
602- String newContents = String .join (System .lineSeparator (), lines );
603- try {
604- oldContents = processingEnv .getFiler ().getResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , "capi.gen.c.h" ).getCharContent (true ).toString ();
605- } catch (IOException e ) {
606- // pass to regenerate
607- }
608- if (!oldContents .equals (newContents )) {
609- var file = processingEnv .getFiler ().createResource (StandardLocation .NATIVE_HEADER_OUTPUT , "" , "capi.gen.h" , origins );
610- try (var w = file .openWriter ()) {
611- w .append (String .join (System .lineSeparator (), lines ));
612- }
613- } else {
614- processingEnv .getMessager ().printNote ("Python capi.gen.h is up to date" );
615- }
602+ updateResource ("capi.gen.h" , javaBuiltins , lines );
616603 }
617604
618605 /**
0 commit comments