Code Monkey home page Code Monkey logo

Comments (12)

AArnott avatar AArnott commented on May 29, 2024

CC: @vbfox

from pinvoke.

vbfox avatar vbfox commented on May 29, 2024

Yes we need a list of all the pro/cons.

On the list of languages :

  • ✅ C# (unsafe / T* foo)
  • ✅ C++ (T* foo)
  • ✅ F# (let foo : nativeptr<'T>)
  • ✅ Boo (unsafe foo as T) didn't test myself but they had a unit test about unsafe (Language is now considered dead)
  • 🔵 VB.Net
  • 🔵 PowerShell
  • 🎱 Nemerle (?)
  • 🎱 IronSheme (?)
  • 🎱 IronPython (?)

✅: Can call pointer exposing method
🔵: Can call IntPtr overload even if pointer version exists
⁉️ Doesn't support the IntPtr overload if the pointer version is present
🎱: Didn't find anythging / not searched

Also for the two overloads solutions it's pretty easy to codegen the IntPtr overloads if we write the pointer ones.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

Can you add a legend for these icons above?

from pinvoke.

vbfox avatar vbfox commented on May 29, 2024

Ok I differentiated between VB that doesn't allow unsafe but can call the IntPtr version if also present with the same name and languages that support it natively.

Turn out that powershell is able to call an IntPtr version too if it exists (Just tested) with the same name so no problem here either.

Everything seem to point that the dual pointer/IntPtr is the good way to go, but we need to codegen it or it will be problematic pretty fast.

from pinvoke.

vbfox avatar vbfox commented on May 29, 2024

Also if we decide to go the "dual" way it's not really needed for a 0.x release, as we will only add overloads that aren't compatible and don't risk being picked by previously existing code.
But It would be nice to have that in 1.0 along with some variant of #70.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

Thanks, @vbfox. I agree: let's go for dual mode. Until we have the code gen going, we should at least offer IntPtr versions so we don't block out use by VB.
Presumably when we start code gen that converts IntPtr to pointers, we can remove any manually created pointer overloads.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

I just found out that unsafe code isn't allowed in C# iterator methods. That means that pointers aren't allowed in them, making it less convenient to call these methods even in a language that would otherwise allow it.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

An open question on resolving some of these is what to do about struct fields that are pointers. Should they be IntPtr or a native pointer type? Can we perhaps use native pointers, but offer properties that expose them as IntPtrs for the VB folks?

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

Progress on fixing kernel32 is blocked on AArnott/CodeGeneration.Roslyn#1

from pinvoke.

jmelosegui avatar jmelosegui commented on May 29, 2024

Well, if we want to be consistent, struct fields should be native pointer types and the codegen should inject property wrappers of those fields.

So I am leaning toward native pointer type and properties that expose them as IntPtrs.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

Agreed.

from pinvoke.

AArnott avatar AArnott commented on May 29, 2024

#130 tracks the struct fields now.

from pinvoke.

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.