diff --git a/CHANGELOG.md b/CHANGELOG.md index fa2d80a92..05ff97c2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Have `Parser` output `setter` as dummy parameter name for setter methods to clarify usage * Add `Indexer.strides(long... sizes)` and use as default strides when not specified by the user * Add `long...` constructors, getters, and setters to `CLongPointer` and `SizeTPointer` for convenience * Fix some `Generator` issues with `FunctionPointer` passed or returned `@ByPtrPtr` diff --git a/README.md b/README.md index ddc1ff7a4..7e4b51464 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Introduction ------------ JavaCPP provides efficient access to native C++ inside Java, not unlike the way some C/C++ compilers interact with assembly language. No need to invent new languages such as with [SWIG](http://www.swig.org/), [SIP](http://riverbankcomputing.co.uk/software/sip/), [C++/CLI](http://www.ecma-international.org/publications/standards/Ecma-372.htm), [Cython](http://www.cython.org/), or [RPython](https://rpython.readthedocs.io/). Instead, similar to what [cppyy](https://cppyy.readthedocs.io/) strives to do for Python, it exploits the syntactic and semantic similarities between Java and C++. Under the hood, it uses JNI, so it works with all implementations of Java SE, in addition to [Android](http://www.android.com/), [Avian](https://readytalk.github.io/avian/), and [RoboVM](http://robovm.mobidevelop.com/) ([instructions](#instructions-for-android-avian-and-robovm)). -More specifically, when compared to the approaches above or elsewhere ([CableSwig](http://www.itk.org/ITK/resources/CableSwig.html), [JNIGeneratorApp](http://www.eclipse.org/swt/jnigen.php), [cxxwrap](http://cxxwrap.sourceforge.net/), [JNIWrapper](http://www.teamdev.com/jniwrapper/), [Platform Invoke](https://msdn.microsoft.com/en-us/library/aa719485.aspx), [GlueGen](http://jogamp.org/gluegen/www/), [LWJGL Generator](https://github.com/LWJGL/lwjgl3-wiki/wiki/4.5.-The-Generator), [JNIDirect](http://web.archive.org/web/20050329122501/http://homepage.mac.com/pcbeard/JNIDirect/), [ctypes](http://docs.python.org/library/ctypes.html), [JNA](https://github.com/twall/jna), [JNIEasy](https://github.com/jmarranz/jnieasy), [JniMarshall](http://flinflon.brandonu.ca/Dueck/SystemsProgramming/JniMarshall/), [JNative](http://jnative.free.fr/), [J/Invoke](http://web.archive.org/web/20110727133817/http://www.jinvoke.com/), [HawtJNI](http://fusesource.github.io/hawtjni/), [JNR](https://github.com/jnr/), [BridJ](http://code.google.com/p/bridj/), [CFFI](https://cffi.readthedocs.io/en/latest/), [fficxx](http://ianwookim.org/fficxx/), [CppSharp](https://github.com/mono/CppSharp), [cgo](https://golang.org/cmd/cgo/), [rust-bindgen](https://rust-lang-nursery.github.io/rust-bindgen/), etc.), it maps naturally and efficiently many common features afforded by the C++ language and often considered problematic, including overloaded operators, class and function templates, callbacks through function pointers, function objects (aka functors), virtual functions and member function pointers, nested struct definitions, variable length arguments, nested namespaces, large data structures containing arbitrary cycles, virtual and multiple inheritance, passing/returning by value/reference/string/vector, anonymous unions, bit fields, exceptions, destructors and shared or unique pointers (via either try-with-resources or garbage collection), and documentation comments. Obviously, neatly supporting the whole of C++ would require more work (although one could argue about the intrinsic neatness of C++), but we are releasing it here as a proof of concept. +More specifically, when compared to the approaches above or elsewhere ([CableSwig](http://www.itk.org/ITK/resources/CableSwig.html), [JNIGeneratorApp](http://www.eclipse.org/swt/jnigen.php), [cxxwrap](http://cxxwrap.sourceforge.net/), [JNIWrapper](http://www.teamdev.com/jniwrapper/), [Platform Invoke](https://docs.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke), [GlueGen](http://jogamp.org/gluegen/www/), [LWJGL Generator](https://github.com/LWJGL/lwjgl3-wiki/wiki/4.5.-The-Generator), [JNIDirect](http://web.archive.org/web/20050329122501/http://homepage.mac.com/pcbeard/JNIDirect/), [ctypes](http://docs.python.org/library/ctypes.html), [JNA](https://github.com/twall/jna), [JNIEasy](https://github.com/jmarranz/jnieasy), [JniMarshall](http://flinflon.brandonu.ca/Dueck/SystemsProgramming/JniMarshall/), [JNative](http://jnative.free.fr/), [J/Invoke](http://web.archive.org/web/20110727133817/http://www.jinvoke.com/), [HawtJNI](http://fusesource.github.io/hawtjni/), [JNR](https://github.com/jnr/), [BridJ](http://code.google.com/p/bridj/), [CFFI](https://cffi.readthedocs.io/), [fficxx](http://ianwookim.org/fficxx/), [CppSharp](https://github.com/mono/CppSharp), [cgo](https://golang.org/cmd/cgo/), [pybind11](https://pybind11.readthedocs.io/), [rust-bindgen](https://rust-lang.github.io/rust-bindgen/), [Panama Native](http://jdk.java.net/panama/), etc.), it maps naturally and efficiently many common features afforded by the C++ language and often considered problematic, including overloaded operators, class and function templates, callbacks through function pointers, function objects (aka functors), virtual functions and member function pointers, nested struct definitions, variable length arguments, nested namespaces, large data structures containing arbitrary cycles, virtual and multiple inheritance, passing/returning by value/reference/string/vector, anonymous unions, bit fields, exceptions, destructors and shared or unique pointers (via either try-with-resources or garbage collection), and documentation comments. Obviously, neatly supporting the whole of C++ would require more work (although one could argue about the intrinsic neatness of C++), but we are releasing it here as a proof of concept. As a case in point, we have already used it to produce complete interfaces to OpenCV, FFmpeg, libdc1394, PGR FlyCapture, OpenKinect, videoInput, ARToolKitPlus, Leptonica, Tesseract, GSL, LLVM, HDF5, MKL, CUDA, Caffe, MXNet, TensorFlow, System APIs, and others as part of the [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) subproject, also demonstrating early parsing capabilities of C/C++ header files that show promising and useful results. diff --git a/src/main/java/org/bytedeco/javacpp/tools/Parser.java b/src/main/java/org/bytedeco/javacpp/tools/Parser.java index 3d8e5b4c5..2681b2356 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Parser.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Parser.java @@ -2274,7 +2274,7 @@ boolean variable(Context context, DeclarationList declList) throws ParserExcepti indices += ", "; } String javaTypeWithoutAnnotations = dcl.type.javaName.substring(dcl.type.javaName.lastIndexOf(" ") + 1); - decl.text += " " + modifiers + setterType + javaName + "(" + indices + javaTypeWithoutAnnotations + " " + javaName + ");"; + decl.text += " " + modifiers + setterType + javaName + "(" + indices + javaTypeWithoutAnnotations + " setter);"; } decl.text += "\n"; if ((dcl.type.constValue || dcl.constPointer) && dcl.type.staticMember && indices.length() == 0) { @@ -2318,7 +2318,7 @@ boolean variable(Context context, DeclarationList declList) throws ParserExcepti if (indices.length() > 0) { indices += ", "; } - decl.text += " " + modifiers + setterType + javaName + "(" + indices + dcl.type.javaName + " " + javaName + ");"; + decl.text += " " + modifiers + setterType + javaName + "(" + indices + dcl.type.javaName + " setter);"; } decl.text += "\n"; }