Comments (5)
Actually, I've added a new adapter for std::string, e.g.:
native @StdString String StringTest();
And with this recent fix
http://code.google.com/p/javacpp/source/detail?r=d2765542855984ad68ce04c9846dbb5
a083fc95e it generates code like this:
StringAdapter radapter(StringTest());
rpointer = radapter;
if (rpointer != NULL) {
r = e->NewStringUTF(rpointer);
}
So the std::string gets copied (but hopefully the compiler is smart enough to
do some return value optimization).
Thanks for pointing out this problem though. Maybe we should get rid of this
`@ByRef String` hack and just use the adapter, what do you think?
Original comment by [email protected]
on 20 Oct 2012 at 1:55
- Changed state: Accepted
from javacpp.
Seems reasonable.
Though I've been using the attached patch (against 0.2), If anyone else needs a
quick fix...
Original comment by [email protected]
on 20 Oct 2012 at 2:15
Attachments:
from javacpp.
Ah yes, in this case we only need to support std::string, no need to try and
figure out the type. I'll apply your patch, no need to break existing code for
no good reasons, thanks!
Original comment by [email protected]
on 20 Oct 2012 at 2:31
- Changed state: Started
from javacpp.
I did it a bit differently, but it should do the same thing. Let me know if you
encounter any issues with this change:
http://code.google.com/p/javacpp/source/detail?r=37228aa780eae24c64e8011763d4191
51b6ee6d1
thanks!
Original comment by [email protected]
on 21 Oct 2012 at 11:40
from javacpp.
I've included these changes in JavaCPP 0.3. Let me know if you still have some
problems with that, thanks!
Original comment by [email protected]
on 5 Nov 2012 at 11:20
- Changed state: Fixed
from javacpp.
Related Issues (20)
- Feature Suggestion : New annotation to specify output library name at java file. HOT 24
- Core dupmp with callback FunctionPointer HOT 16
- SIGSEGV on android when native method returns empty string HOT 13
- Improve debugging HOT 3
- Eliminate dependency on libjvm.so when not required HOT 5
- @StdString annotation is ignored for function pointers HOT 6
- Function pointer instances of the same type overwrite each other? HOT 4
- Enhancement request: User-defined exceptions HOT 3
- Can't run facedetection example HOT 5
- Nullpointer in Loader.load() HOT 6
- Exception NoSuchMethodError in the beginning of execution on Android 2.2 HOT 2
- What's the correct way to implement enums? HOT 2
- Current snapshot immediately crashes in Windows HOT 6
- javacpp.presets does not compile on a fresh checkout HOT 5
- Can't get LegacyLibrary example to compile in Windows HOT 7
- Documentation: How to implement 'return' arguments - side effect HOT 2
- ffmpeg presets produces uncompileable parsed .java file for avdevice.h HOT 6
- byte array data (google protobuf) corrupted HOT 1
- Error running ndk-build with javaCPP generated files HOT 3
- BytePointer with nulls getting truncated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javacpp.