Alternative Cocoa framework, anyone?

Interesting. I don’t think I’ve hit a use case for that yet in my increasingly insane Cojo project, though I think I recall doing it in some of my personal plugin code. I’ll keep it in mind.

So, Xojo is representing colors as genericRGB NSColors internally on OSX? Could I just grab a handle to that? It would be faster than converting the components every time.

It’s an on-demand conversion, so there isn’t one for every color all the time.

Ahh. Pity. But it would be kinda awesome to have this on-demand conversion routine exposed. Maybe I’ll file a feature request. :slight_smile:

	return [NSColor colorWithCalibratedRed:red / 255.0
	                                 green:green / 255.0
	                                  blue:blue / 255.0
	                                 alpha:(255 - alpha) / 255.0];

LOL! Here’s my routine;

[code]Function as_NSColor(extends c as Color) As NSPtr

dim col as NSPtr = Cojo.NSColor.colorWithCalibratedRedGreenBlueAlpha( c.Red/255, c.Green/255, c.Blue/255, (255-c.alpha)/255 )

col.Retain( True )

Return col
End Function[/code]

I guess I was on the right track.

So, something I started a few years ago but ran out of time (and then energy) to work on is a declare generator. The general gist of things:

  • libclang is used to parse the headers accurately
  • the AST is iterated over to extract declaration nodes
  • the declaration nodes are placed into buckets based off of the OS X framework they come from
  • each bucket is walked and corresponding Xojo declarations are created, each bucket mapping to one Xojo module
  • when the code is being written out, injectors can add additional predefined code based off of the module (e.g. it could add implicit conversions or helper methods)

There’s a lot of pesky details, but it’s doable and not rocket science.

That sounds infinitely more sophisticated than the Frankenstein’s monster I cobbled together to parse the HTML docs, (the internals of which are frankly embarrassing, although it does function.)

If you were ever tempted to let it out into the wild, even on a limited basis, I’d be interested in having a look.

Last update for awhile. Made some sensible changes, I think. See Cojo>Notes>Version for info.

All links in thread updated, but here it is again for courtesy’s sake;

https://dl.dropboxusercontent.com/u/28082075/Cojo%20Master.xojo_binary_project.zip

Also, @Eduardo Gutierrez de Oliveira; I recently learned that “cojo” in Spanish actually means “lame.” You sure you’re not having a little fun with us? :wink:

OK, no really. Last update for awhile. I swear. I was tired when I was editing the NSNumbers module, and made a bunch of really head-scratchy mistakes. For one thing, this resulted in unsigned 64-bit integers always coming back to Xojo as signed. There may have been other side effects, but hopefully they were wiped out as well. How embarrassing. Also, the NSNumber conversion routine needed to stop using string comparisons, so I redid that.

Just click any of the links above for the new version.

I swear I will put this down for awhile. Still feel free to call out any goofy mistakes I may have missed, however.

I know what I said. “Last update for awhile.” I guess I’m obsessed right now. It’s amazing how the simple act of making this available for download has motivated me to continue.

I added a bunch of new modules, and a few new demo panes. Lots of old junk was cleaned up. Not everything is thoroughly tested, but I ran through the new demos using Instruments, and nothing leaks. That’s something.

The big thing is the new CoreImage modules. There’s a demo pane that performs a simple gaussian blur on the application icon. None of this is perfect. It will improve over time. But it works. This pleases me.

Check the version notes for more ramblings.

https://dl.dropboxusercontent.com/u/28082075/Cojo%20Master.xojo_binary_project.zip

As ever, if anyone actually does anything with this, report any problems.