11package com .nativelibs4java .opencl .generator ;
22
33import com .nativelibs4java .opencl .*;
4- import com .ochafik .io .IOUtils ;
54import com .ochafik .lang .jnaerator .*;
6- import com .ochafik .lang .jnaerator .PreprocessorUtils .MacroUseCallback ;
75import com .ochafik .lang .jnaerator .TypeConversion .JavaPrimitive ;
86import com .ochafik .lang .jnaerator .TypeConversion .TypeConversionMode ;
97import com .ochafik .lang .jnaerator .UniversalReconciliator ;
2220import java .io .PrintStream ;
2321
2422import java .util .regex .Pattern ;
25- import org .anarres .cpp .LexerException ;
2623
2724public class JavaCLGenerator extends JNAerator {
2825
@@ -37,7 +34,7 @@ public JavaCLGenerator(JNAeratorConfig config) {
3734 config .genCPlusPlus = false ;
3835 config .gccLong = true ;
3936 config .putTopStructsInSeparateFiles = false ;
40- config .runtime = JNAeratorConfig .Runtime .JNAerator ;//NL4JStructs;
37+ config .runtime = JNAeratorConfig .Runtime .BridJ ;//NL4JStructs;
4138 config .fileToLibrary = new Adapter <File , String >() {
4239 @ Override
4340 public String adapt (File value ) {
@@ -89,6 +86,11 @@ protected com.ochafik.lang.jnaerator.parser.ObjCppParser newObjCppParser(TypeCon
8986 public Result createResult (final ClassOutputter outputter , Feedback feedback ) {
9087 return new Result (config , outputter , feedback ) {
9188
89+ @ Override
90+ public Identifier getLibraryClassFullName (String library ) {
91+ return null ;
92+ }
93+
9294 @ Override
9395 public void init () {
9496 typeConverter = new BridJTypeConversion (this ) {
@@ -343,7 +345,13 @@ private Conversion convertTypeToJavaCL(Result result, String argName, TypeRef va
343345 ret .outerJavaTypeRef = typeRef (ident (CLBuffer .class , expr (typeRef (pair .getSecond ()))));
344346 return ret ;
345347 }
348+ Identifier ref = result .typeConverter .findRef (starget .getName (), target , libraryClassName , true );
349+ if (ref != null ) {
350+ ret .outerJavaTypeRef = typeRef (ident (CLBuffer .class , expr (typeRef (ref ))));
351+ return ret ;
352+ }
346353 }
354+ throw new UnsupportedConversionException (valueType , "Unknown pointed target type" );
347355 } else if (valueType instanceof TypeRef .SimpleTypeRef ) {
348356 TypeRef .SimpleTypeRef sr = (TypeRef .SimpleTypeRef )valueType ;
349357 String name = sr .getName () == null ? sr .toString () : sr .getName ().toString ();
@@ -492,31 +500,31 @@ public SampleUserProgram(CLContext context) throws IOException {
492500 }
493501 }
494502
495-
496- @ Override
497- protected void autoConfigure () {
498- super .autoConfigure ();
499-
500- /*
501- __OPENCL_VERSION__
502- __ENDIAN_LITTLE__
503-
504- __IMAGE_SUPPORT__
505- __FAST_RELAXED_MATH__
506- */
507-
508- }
503+ //
504+ // @Override
505+ // protected void autoConfigure() {
506+ // super.autoConfigure();
507+ //
508+ // /*
509+ // __OPENCL_VERSION__
510+ // __ENDIAN_LITTLE__
511+ //
512+ // __IMAGE_SUPPORT__
513+ // __FAST_RELAXED_MATH__
514+ // */
515+ //
516+ // }
509517
510518 public static void main (String [] args ) {
511519 JNAerator .main (new JavaCLGenerator (new JNAeratorConfig ()),
512520 new String [] {
513- "-o" , "target/generated-sources/main/java " ,
521+ "-o" , "target/generated-sources/test " ,
514522 //"-o", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/generated-sources/main/java",
515523 "-noJar" ,
516524 "-noComp" ,
517525 "-v" ,
518- "-addRootDir" , "src/main /opencl" ,
519- "src/main /opencl" ,
526+ "-addRootDir" , "src/test /opencl" ,
527+ "src/test /opencl/com/nativelibs4java/opencl/generator/Structs.c " ,
520528 //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/target/../src/main/opencl",
521529 //"/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/src/main/opencl/com/nativelibs4java/opencl/blas/LinearAlgebraKernels.c"
522530 //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/../src/main/opencl",
0 commit comments