Giter VIP home page Giter VIP logo

Comments (10)

saudet avatar saudet commented on June 12, 2024

JavaCPP needs a FunctionPointer peer class

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

Sure. The problem, if I understood well, is the @SharedPtr annotation not taken into account by the Generator when generating the peer class.

from javacpp.

saudet avatar saudet commented on June 12, 2024

Right, so where is that FunctionPointer class?

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024
@Properties(inherit = presets.P.class)
public class S_F extends FunctionPointer {
    static { Loader.load(); }
    /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
    public    S_F(Pointer p) { super(p); }
    protected S_F() { allocate(); }
    private native void allocate();
    public native @SharedPtr S call();
}

That's the class automatically generated by the parser from the C++ code above.

from javacpp.

saudet avatar saudet commented on June 12, 2024

You'll need to add at least a @Cast to that...

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024
public native @Cast({"", "std::shared_ptr<S>"}) @SharedPtr S call();

seems to work. Thanks.

Do we close this issue or keep it open in case there is something to fix to avoid this @Cast ?

from javacpp.

saudet avatar saudet commented on June 12, 2024

We need to specify the type somehow. As I've mentioned somewhere before, think of @Cast as if it were named @As instead.

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

@SharedPtr already means that the function returns a shared_ptr of S. For a normal function, that calls a native function of the object pointed by the Pointer instead of the native function directly pointed by the Pointer, we don't need the @Cast.

from javacpp.

saudet avatar saudet commented on June 12, 2024

No, it doesn't, for example, see issue #717

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

In #717 the @Cast is to disambiguate between 2 overloads of unique_ptr.operator=. The @Cast doesn't change the type of the field.

from javacpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.