Well that was... painless(ish).
Following the lead from GNUStep, I've had some success using a CFMutableDictionary to store retain counts keyed to object addresses. So far, so good. (GNUStep actually uses NSMapTables. These have only just been introduced in 10.5. I may move to them some day... but I need a working retain/release system before I can try to implement them.) Anyway, my NSObject subclassing test — the one described below — passed, so I'm happy.
Now on to CF-bridged class clusters. Looking into how to achieve these, all those NSCFStrings suddenly start to make sense.
Thursday, January 22, 2009
Foundation on Darwin (attempt #1)
The PureDarwin project seems to be coming along in leaps and bounds, recently releasing the PureDarwin Xmas VMWare image. Since this gives me a working Darwin install to play with — and since I've had some spare time this week — I thought I'd take a look at what it would take to get a binary compatible Foundation working on Darwin (a project which I've tentatively entitled "PureFoundation"). By 'binary compatible' I mean compile on OS X and run on Darwin. Since Apple gives us the Objective-C 2.0 runtime, the AutoZone Garbage Collector, and CFLite, how hard could it be?
As I'm sure you're aware, many CoreFoundation (henceforth CF) objects are toll-free bridged to their Foundation counterparts. To most intents and purposes they are identical structures. Since CFLite implements reference counting (and the documentation and source code even hints that it plays nicely with the Garbage Collector) I hit upon what I thought would be a simple approach: rather than having a mix of pure objective-C and bridged classes, I'd create a CF class which I could bridge to NSObject, meaning that all the "PureFoundation" objects inherited CF's memory management.
Long(-ish) story short, I got this working. More or less. I could compile a simple Foundation.framework in XCode and copy it across to the Darwin VM; compile a simple Cocoa command line app, also in XCode, which created an NSObject, sent it
CF objects arealmost identical to objective-C structures. They're 8 (or 12 under 64-bit) byte structures, the first 4 (or 8) bytes of which are the
Now, I had (rather over optimistically) hoped that the dynamism of the objective-C runtime stretched to defining Classes and assigning ivars. So that if you defined a class which extended NSObject by adding extra variables, the runtime — rather than the compiler — would allocated them after whichever already existed. The runtime certainly provides functions for doing so. Unfortunately, this isn't the case. Testing an NSObject subclass with one extra
So it's back to the drawing board. Next stop is the GNUStep source code, to see how they implement release/retain. The GNUStep source was always going to come into play at some point, so I guess this isn't too big a problem. It also looks like there's no getting away from patching CFLite to reinstate the bridging functions which were turned into no-ops by Apple before they released it. Which means setting up a darwinbuild environment and coding in Nano. Oh, well.
As I'm sure you're aware, many CoreFoundation (henceforth CF) objects are toll-free bridged to their Foundation counterparts. To most intents and purposes they are identical structures. Since CFLite implements reference counting (and the documentation and source code even hints that it plays nicely with the Garbage Collector) I hit upon what I thought would be a simple approach: rather than having a mix of pure objective-C and bridged classes, I'd create a CF class which I could bridge to NSObject, meaning that all the "PureFoundation" objects inherited CF's memory management.
Long(-ish) story short, I got this working. More or less. I could compile a simple Foundation.framework in XCode and copy it across to the Darwin VM; compile a simple Cocoa command line app, also in XCode, which created an NSObject, sent it
-retain and -release, and reported it's retainCount. The same binary ran in an identical fashion under both OS X and Darwin. At this point I was about ready to call up the Nobel people and suggest they started a computing prize just for me. But...CF objects are
isa pointer used to identify whether the object is an objective-C class and if so which one. The remaining 4 bytes holds other info, such as their CFTypeID and the lower 16 bits of the retain count. Since NSObject only allocates a single 4 (or 8) byte isa pointer, I had to pad the NSObject in my "PureFoundation" framework with another 4 dummy bytes, meaning that while the proper NSObject on OS X took up 4 bytes, my NSObject on (32-bit) Darwin took 8.Now, I had (rather over optimistically) hoped that the dynamism of the objective-C runtime stretched to defining Classes and assigning ivars. So that if you defined a class which extended NSObject by adding extra variables, the runtime — rather than the compiler — would allocated them after whichever already existed. The runtime certainly provides functions for doing so. Unfortunately, this isn't the case. Testing an NSObject subclass with one extra
NSUInteger ivar, compiled in XCode, showed it took up 8 bytes on both OS X (correctly) and Darwin (aargh!). Under "PureFoundation", retain and release worked fine immediately after the CF object was allocated, but once the -init ran the reference counting area of memory got stomped on.So it's back to the drawing board. Next stop is the GNUStep source code, to see how they implement release/retain. The GNUStep source was always going to come into play at some point, so I guess this isn't too big a problem. It also looks like there's no getting away from patching CFLite to reinstate the bridging functions which were turned into no-ops by Apple before they released it. Which means setting up a darwinbuild environment and coding in Nano. Oh, well.
Friday, December 12, 2008
This Sark Business
I don't usually let myself get wound up by stuff I read about in the news, but this Sark business has me pretty mad. If you've never heard of Sark, go read about it in Wikipedia. The island and its (former) way of government is living proof that the UK is old. This country wasn't created, but instead evolved over millennia, along the way accreting administrative cruft like the Chief Pleas. Titles like Seigneur and Seneschal are beautifully evocative, and it really didn't seem like the pseudo-feudal system was hurting the island's 600 inhabitants.
The hypocrisy of current events is simply stunning. The Barclay Brothers may claim to want democracy, but in reality they only wanted to place themselves as feudal lords over the island. When their nominees lost the popular vote, they chose to shutter all their concerns on the island in a fit of pique. I'd call it childish if it wasn't so far beyond that. It's downright criminal. The islanders wouldn't let the Barclays take over — probably with the intention of installing a new tax regime more favourable to themselves — and so they are being punished. Notice in the BBC article where the Barclay's spokesman says that they have no need to sell the properties. Rather than risking someone else moving in and giving these people their jobs back, they will board-up the hotels and other businesses and let them rot in order to spite the islanders.
I live just across the Channel from Sark, and I've got half a mind to grab a boat from the harbour and stage my own one-man invasion of Brecqhou — the Barclays' Bond-villan-esuqe island fortress — to see how they'd like it.
The hypocrisy of current events is simply stunning. The Barclay Brothers may claim to want democracy, but in reality they only wanted to place themselves as feudal lords over the island. When their nominees lost the popular vote, they chose to shutter all their concerns on the island in a fit of pique. I'd call it childish if it wasn't so far beyond that. It's downright criminal. The islanders wouldn't let the Barclays take over — probably with the intention of installing a new tax regime more favourable to themselves — and so they are being punished. Notice in the BBC article where the Barclay's spokesman says that they have no need to sell the properties. Rather than risking someone else moving in and giving these people their jobs back, they will board-up the hotels and other businesses and let them rot in order to spite the islanders.
I live just across the Channel from Sark, and I've got half a mind to grab a boat from the harbour and stage my own one-man invasion of Brecqhou — the Barclays' Bond-villan-esuqe island fortress — to see how they'd like it.
Thursday, November 06, 2008
I'm Looking for a Performer
I'm looking for a performer. A comedian or actor. Although not actively. Not quite yet. Just passively. Keeping my eyes peeled. I mention it here just on the off chance someone stumbles across it.
For some reason, I've found myself watching a lot of Daily Show and Colbert Report recently. Probably the US elections. The formula's pretty simple: five minutes of jokes, then a (usually toe-curling) interview. The BBC's Late Edition was a fairly accurate copy, albeit way more hit-and-miss. And now I'd like to try my own on the internet.
Of course, I wouldn't dream of sticking myself in front of the camera. Apart from always feeling uncomfortable, I simple haven't got the talent. Mind you, I see myself writing the thing and I certainly don't appear to have the talent for that. I've started another blog at hereisthenews.tumblr.com with the intention of posting short snappy jokes. So far, nothing. But give it time.
Anyway, this post is really more for me, to try and spur me into action. Although if anyone else reads this and is interested, drop me a message.
For some reason, I've found myself watching a lot of Daily Show and Colbert Report recently. Probably the US elections. The formula's pretty simple: five minutes of jokes, then a (usually toe-curling) interview. The BBC's Late Edition was a fairly accurate copy, albeit way more hit-and-miss. And now I'd like to try my own on the internet.
Of course, I wouldn't dream of sticking myself in front of the camera. Apart from always feeling uncomfortable, I simple haven't got the talent. Mind you, I see myself writing the thing and I certainly don't appear to have the talent for that. I've started another blog at hereisthenews.tumblr.com with the intention of posting short snappy jokes. So far, nothing. But give it time.
Anyway, this post is really more for me, to try and spur me into action. Although if anyone else reads this and is interested, drop me a message.
Sunday, November 02, 2008
Sarah Palin Prank Called
Apparently it was Russell Brand claiming responsibility for Bristol's sprog.
Sunday, September 28, 2008
What Kind of a Week Has it Been?
The $0.47 in my Google AdSense account says "not too shabby." Yeah, I know, but for the first week of the newly re-launched Apple Eclectic it really isn't bad. In the last 7 days we've posted 85 articles, knocked our WordPress template into a shape which we're reasonably happy with, and are even starting to find our voice. We've had 668 visitors since I started the stats thing counting on Thursday, over 400 of them today alone. We've even had a commentor.
I've got a good feeling about this. Unfortunately that's when things usually start to go wrong, but we'll see.
A few random thoughts:
I'm sure that when I was planning this earlier I had more things to say, but that will have to do for now. Next: find a cartoonist.
I've got a good feeling about this. Unfortunately that's when things usually start to go wrong, but we'll see.
A few random thoughts:
- Twitter: Just started following some people. One was Jason Calacanis, who instantly started following me back. I know it was just some machine of his somewhere being automatically polite, but it's still a weird feeling.
- Amazon: Having to sign up to a separate Associates programme in each country is a pain. Google doesn't require this, but then Google doesn't have to ship physical goods and follow pre-digital accounting practices. It's still a pain. I really need to find some way to get WordPress to present different Amazon widget according to the visitor's location.
- Trackbacks: We posted an article in reply to a TechCrunch piece, which got us a link on their page, which in turn generated some traffic. This feels weird in the same way as the Calacanis Twitter thing — I shouldn't be playing at the same level as these people, but I guess that's the beauty of this InterNet thingie. Go egalitarianism!
I'm sure that when I was planning this earlier I had more things to say, but that will have to do for now. Next: find a cartoonist.
Thursday, September 25, 2008
419, the Old-Fashioned Way
Just to show the world what kind of a technological backwater I've washed up in: someone has been going around my home town dropping letters through people's front doors claiming to be from the window of the President of Zambia, asking for help in moving millions of pounds through the banking system. Yes, that's right: it's a paper-based version of the 419 scams. Well, would-be-scammers, the jokes on you. People round her don't trust them new-fangled banks. Give a total stranger your money rather than keep it under your bed? Not likely.
via The Dorset Echo (our local rag).
via The Dorset Echo (our local rag).
Saturday, September 20, 2008
Checking Google Takes Only Seconds
PCW Laughs Last, Longest
In an attempt to distance myself from the rest of the Blogosphere, I followed my rant of a few months ago by shunning the typical passive-agressive stance and actually Doing Something About It. By which I mean I wrote a snarky letter (well, e-mail), which is what passes for Doing Something in the particular strata of Englishness to which I belong.
The staff of PCW, however, are professionals well-equiped to deal with uppity readers, and proceeded to implement the neatest bit of wrong-footing I've experienced in a long while, to whit: they awarded me the Letter of the Month. If you can find a copy of the October 2008 edition (which came out a few months ago in crazy magazine time — yeah, I should have blogged this sooner) and turn to page 20 you will see my words (slightly edited, but nothing to get all Giles Coren about).
You may also note that I won a prize: a Ricoh Aficio GX 2500 printer. As PCW Editor Kelvyn Taylor joked in his congratulatory e-mail, "I hope it comes with Mac drivers." Now, I was planning on ending with the words, "And we all know the answer to that," but bugger me sideways if the damn thing doesn'tactually have Mac drivers . A review shall follow.
The staff of PCW, however, are professionals well-equiped to deal with uppity readers, and proceeded to implement the neatest bit of wrong-footing I've experienced in a long while, to whit: they awarded me the Letter of the Month. If you can find a copy of the October 2008 edition (which came out a few months ago in crazy magazine time — yeah, I should have blogged this sooner) and turn to page 20 you will see my words (slightly edited, but nothing to get all Giles Coren about).
You may also note that I won a prize: a Ricoh Aficio GX 2500 printer. As PCW Editor Kelvyn Taylor joked in his congratulatory e-mail, "I hope it comes with Mac drivers." Now, I was planning on ending with the words, "And we all know the answer to that," but bugger me sideways if the damn thing doesn't
Sunday, August 17, 2008
How the Manic Street Preachers Invented Tech Blogging
1: Will it Blend?

From Little Baby Nothing at approx. 3 minutes 32 seconds.
2: The Gizmodo-style Pantsing

From You Love Us at approx. 1 minute 39 seconds.
Subscribe to:
Posts (Atom)
