New generation
Ok, so now it’s time for a boring work post. I wish I could show pictures of where I work but no recording devices of any kind are allowed in the building. Security is reasonably tight. I can’t even get back from the toilet without a swipe card.
Yeah, Cecil guys & gals, I have been there before, but this time knocking on the door is not allowed. I once forgot my card when I went to the toilet. I had to get the security person (her name is Barbra) to ring into the office so that someone could walk out with my swipecard. No swipecard, no entry. Our swipecards have our pictures on them too.
Anyway, So I am writing code (no specifics). The design is finished and one of our key problems is interfacing with a particular API. This API is all done in unmanaged C++ libraries and we’re programming in C#. Non-programmers, continue reading at your peril…
You geeks can immediately see the problem of course: native C++ libraries don’t interoperate easily with .Net. You need to recompile the C++ in “common language runtime” mode so that “it just works” or do a bunch of old fashioned dllimports.
Now, we don’t have the source code and the nature of the headers is such that dllimport is out of the question. So, the only solution is a managed C++ wrapper. Do you think there’s a way to generate a managed C++ wrapper to an unmanaged C++ library? No. A tool called Swig can get part-way there but because its implementation of the C++ parsing rules is incomplete it basically choked on 90% of the headers I threw at it.
My team lead was in favour of going ahead and writing the wrapper by hand. So, we started doing that. By the second day I was just getting into the swing of things when my Intellisense stopped working. Well, rather it went into overdrive and killed the CPU on my computer. Why? A bug in the implementation of the intellisense in VC++ 8 (.Net 2005) causes it to go into an infinite loop.
So, that was the last straw. There’s no way you can write a wrapper to a foreign API (particularly not this one) without heaps of code completion. So, I rolled up my metaphorical sleeves and wrote my own parser to parse the headers and then code to generate the wrappers myself. The headers follow a pattern so it was easier than writing a C++ compiler, it was still quite a challenge.
I generated over 60,000 lines of code with my generator today and I am only about half way through (the API is somewhat symmetrical around getters and setters). Imagine having to hand-code 120,000 lines worth of wrappers? I am glad I saved myself (and my team) from that particular nightmare.
August 11th, 2006 at 9:07 pm
Stephen: “…..Yeah, Cecil guys & gals………”
Sally: ZzzzzzzzZzzzz
Sorry…
August 11th, 2006 at 11:02 pm
Jesus christ! (Re code stufF)
August 12th, 2006 at 3:19 am
tsk tsk, I am sure Jesus wouldn’t appretiate you using his name in vain
August 13th, 2006 at 5:17 pm
oh my! this story turns me on … in a geeky kindda way. No chance of getting frisky and looking at the source huh.
August 14th, 2006 at 8:41 am
Sorry, dude, I’d have to kill you
Or at least make you go through security clearance which is about as bad
August 16th, 2006 at 7:55 pm
Just a thought. Its really odd how the name of our Lord is used more in every day life by people who don’t believe in Him than by those of us who do.
August 17th, 2006 at 2:17 pm
*grins* It is strage.
That said, it cuts both ways. I have caught myself saying “holy cow” which would be offensive to many people of different faiths & cultural backgrounds to me.
August 18th, 2006 at 7:39 am
Hi! I’m a really old friend of Susan’s from school in Durban and am trying to get into contact with her. Any chance you could send me her email address or send her mine? Thanks, Lindel
August 18th, 2006 at 11:16 am
Hi Stephen, i left a message somewhere else on your website. just in case you dont get it i thought i’d post one here too. I am an old school friend of Susans from Durban. Please oh please can you send me her email address!! I am so looking forward to contacting her.
thank you!!
Christine Bernard (used to CAZIN)
August 18th, 2006 at 5:13 pm
Hi Lindel. I remember you! Good to hear from you. I have sent you an email
August 18th, 2006 at 5:22 pm
Hi Christine, I have sent you an email. Thank you for posting, I am sure Susan will get a kick out of it