[Mono-osx] [Mono-Mac] ImageKit bindings and sample
Miguel de Icaza
miguel at novell.com
Wed Feb 2 11:00:08 EST 2011
Hello,
> I noticed that all the uints in PdfKit were changed to ints, so I did the
> same here.
The use of ints instead of uints is needed to support languages that
do not expose unsigned data types.
When it is clear that the full range of a uint will be needed, we keep
the signature, but when we the likelihood of the use of the full range
is in doubt, we can move that to an int. For example, GoToPage in a
PDF file for a PDF that has more than 2^31 pages is very unlikely, so
we turn the uint into an int.
> But I am confused. What happens if a client passes a negative int to a objC
> method that is expecting a uint,
They would get a very large uint value.
The only case where it would be required is if you actually need a
value beyond 2^31, so you would use:
(int) some_uint value
That would give you the full range you need.
> It seems using uint would allow the compiler to help keep the code sane.
> What am I missing?
That every API that is exposed as uints is not CLS-compliant and
prevents some programming languages from accessing the API.
> I made some changes to AppKit for the sample: I added two dragging
> protocols. I only needed NSDraggingDestination, but you get the
> NSDraggingSource for free.
> Not sure if they are generally useful, but here they are. I noticed a
> binding for a type called
> NSDragDestination which is not a Apple type, and the methods are same as
> NSDraggingInfo It seems like it should be removed, but I don't know its
> history.
You are right, I am not sure what that thing was for.
In general, we do have a problem here with the bindings. The
NSDraggingDestination and NSDraggingSource are protocols that are
implemented by certain objects (not sure which). Ideally we would
declare these as interfaces and expose this contract explicitly,
instead of replicating it when we find that they implement the
protocol.
But looking at the source code does not make it obvious which methods
explicitly implement this support.
> It's been fun, and I've learned a ton, but I have to give up this hobby for
> a month or so to complete other obligations. Hopefully there will be more
> to do when I return.
Glad to hear that! Thank you for your contributions, you helped us
improve MonoMac with your carefully crafted code!
Miguel
More information about the Mono-osx
mailing list