OSLUG Planet
Class inheritence in C
For a while now I have been slowly developing a touchscreen music player to replace the stereo in my car. Although that concept should be fairly simple the project has turned into a bit of a playground for learning how to implement an X toolkit using nothing but C, XCB, and Cairo. One of the more recent legs this project has grown is an object oriented system for C which supports class inheritance and method overriding for use in my toolkit.
At this point I've got it almost the way I like it. Defining a class in a header looks something like this:
CLASS(mtk_widget, mtk_object) int x, y, w, h; struct mtk_window *window; struct mtk_widget *parent; cairo_surface_t *surface; METHODS(mtk_widget, mtk_object, int x, int y, int w, int h) void (*init)(mtk_widget_t *this, mtk_widget_t* parent); void (*draw)(mtk_widget_t *this); /* children must implement this */ void (*update)(mtk_widget_t *this); void (*mouse_press)(mtk_widget_t *this, int x, int y); void (*mouse_release)(mtk_widget_t *this, int x, int y); void (*mouse_move)(mtk_widget_t *this, int x, int y); void (*set_geometry)(mtk_widget_t *this, int x, int y, int w, int h); void (*set_parent)(mtk_widget_t *this, mtk_widget_t *parent); ENDThis defines a new class named mtk_widget based on the base class mtk_object. The extra arguments to the METHODS macro are additional arguments for the object constructor.
To actually implement the class the corresponding C file will have something like this:
/* more methods up here */ static void set_parent(mtk_widget_t *this, mtk_widget_t *parent) { this->parent = parent; } mtk_widget_t* mtk_widget_new(size_t size, int x, int y, int w, int h) { mtk_widget_t* this = mtk_widget(mtk_object_new(size)); SET_CLASS(this, mtk_widget); this->x = x; this->y = y; this->w = w; this->h = h; return this; } METHOD_TABLE_INIT(mtk_widget, mtk_object) METHOD(init); METHOD(draw); METHOD(set_geometry); METHOD(set_parent); METHOD_TABLE_ENDMethods can (and probably should) be static functions. The METHOD_TABLE_INIT macro defines the function _mtk_widget_class_init() to fill up a hidden structure named _mtk_widget_class which is the class virtual method table. Each object then has a pointer tucked away inside to its class's method table (set by the SET_CLASS macro). One thing that is a bit clunky about this is that the program must somehow call _mtk_widget_class_init() before the class is ever used. I would like to be able to do away with that by using GCC's constructor function attribute so it magically runs before main(). However the class hierarchy must be initialized in order but a way to order the constructors was not added until GCC 4.3. I'm using 4.1 on my system so that feature will have to wait for now.
Actually using objects looks something like this:
int main (int argc, char *argv[]) { mtk_window_t *window; mtk_widget_t *widget; mtk_init(); window = new(mtk_window,640, 480); widget = mtk_widget(new(mtk_text, 0, 0, 640, 480, "WHEE")); call(window, mtk_container, add_widget, widget); mtk_main(); mtk_cleanup(); return 0; }Pretty strait forward, call() is a bit weird though. It takes the arguments (object, class name that defined the method, method name, method arguments). I would like to be able to get rid of the class argument somehow (it is used to cast object to the correct type) but I haven't come up with a solution yet. I have a similar clunkyness with my super() macro for calling a parent class's method when doing method overriding.
That's pretty much it. As with the rest of this project it is a good example of making things more complicated than they need to be but it was an interesting challenge to put together.
The code for the above macros and base class can be found in this header and c file.
BarCamp Portland May 2-4
Portland BarCamp is coming up this weekend! Show up (or better yet register as a camper) to partake in food, fun, and interesting tech talks. This is also a great opportunity to get input on personal projects or hold your own talk/mini session.
Where: Cubespace
622 SE Grand Ave.
Portland, OR 97214
When: Friday May 2 @ 6PM - Sunday May 4 @ 3PM
For people interested in going:
If you are driving to BarCamp Portland and have room for extra passengers or if you want to go but can’t get there or don’t have somewhere to stay please post either in the LUG mailing list, wiki or the BarCamp Portland wiki.
First Add-on shirt sighting….
Remember those shirt we promised to add-on developers for updating to Firefox 3? Looks like people are starting to get them…
State of the add-ons report: April 21st
Preface: There is a lot of tracking going on with regards to what add-ons are up to date. I’m going to try to keep a regular discussion going about the current status, hang-ups, and wish list of add-ons compatible with Firefox 3. With that, here goes the first edition of the “State of the add-ons report”.
AMO add-on compatibility
Addons.mozilla.org is currently allowing developers to mark their add-ons compatible with 3.0pre. 3.0 will be available in when RC1 is released, which is expected late April, or early May.
Top 95% compatibility
We are currently at 60% compatibility (by usage, of the top 95% of addons), 80% if we count add-ons that we know are in the works. See our compatibility chart for latest info.
Top add-on we wish was available
PicLens. PicLens has roughly 500,000 daily users, but is only compatible with 2.0.0.*. Help by sending feedback, or updating the bug, encouraging the PicLens development team to update to 3.0.
[UPDATE: the tracking bug says there is a beta in the works! no word on ETA yet]
Feel free to nominate next week’s in the comments.
Top add-on we are worried about
Tab Mix Plus. We’ve seen traffic on TMP development forums, but no word of when it will be released on addons.mozilla.org. Please comment on any news in the tracking bug.
Feel free to nominate next week’s in the comments.
Top add-on that is on its way
Firebug. Yes, that’s right, Firebug is getting close to compatibility. Find out and help at the tracking bug. In fact, Firebug is currently blocking the Firefox 3 release — meaning we will not release Firefox 3 without it up to date.
Feel free to nominate next week’s in the comments.
Other news
Adblock (not Adblock Plus, which is ready for prime time), is not going to be updated to Firefox 3. In the tracking bug, we’re trying to figure out if we should update all the Adblock users to Adblock Plus. Should we? Or should we just let the add-on die? Weigh in to a solution after reading the tracking bug.
That concludes this state of the add-ons report. I would really appreciate feedback into format, content, and overall message. Thanks!
Don’t fall asleep, drummer!
“Don’t fall asleep!” — a nice reminder for the drummer of the big band I play in, on the 1943 Tommy Dorsy piece “Opus One”.
And because you’ve been such a good readership lately, here’s the original record for you. Enjoy!
Heh
Just stumbled across this:
- Friend: “I heard about this thing called ‘Linux’.”
- Me: “Oh, I use Linux.”
- Friend: “What is it?”
- Me: “An operating system.”
- Friend: “Like Firefox?”
Haha
Last exam ever!
Just to give you a piece of unwanted knowledge, I just passed my last exam ever! It was about parallel programming, by the way.
Now it’s really only my masters thesis that stands between me and graduation. Yay!
Jack Aboutboul Visits Campus
Jack Aboutboul, Redhat’s community engineer, came to Oregon State on Monday to meet students involved in the open source community as well as share his experiences in open source and at Redhat.
The day started with a tour of the EECS department, focusing on Carlos Jensen’s work with social computing and Tim Budd’s involvement with open source education. After lunch, Jack visited the Open Source Lab then met the director of EECS.
For many, the highlight of Jack’s visit was his colloquium presentation in Kelly. Students literally lined the walls to listen to Jack talk about what he describes as how a billion little collisions define everything. In the case of open source, many small events have compounded to make a huge impact.
Favicon Collective breaks 500 favicons!
Woohoo! After my last post, and a few additional users, we now have over 500 unique favicons in the favicon collection. I think if we can push through 1000 favicons, we will have the largest favicon collection on the internet.
If you would like to help add to the collection, install the Firefox 3 add-on.
This project has been a good skill-set tester… as it has required me to hack in Javascript/XUL, Firefox 3 apis (devmo++), google app engine, python, and django. If you find any bugs while interacting with this sausage factory, please be sure to file a bug on my google code project.
No Cat
Albert Einstein, when asked to describe radio, replied:
“You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat.”
(seen on nocat.net)
Slime Line?
Something tells me, this sign I came across in a German store has one “e” too much:
Or maybe I just missed the latest trend and in fact, slime is the new black.
Help me create a huge favicon collection
I really like favicons. So, I created a Firefox 3 add-on that sends all my favicons to a web service. Then, the stars aligned, and google released app engine. Now we’re enabled to collect all the favicons in the world. But I cannot do it alone, I need your help.
You can see the progress here. If you want to add favicons that you encounter (in Firefox 3), please see this page.
The add-on is alpha alpha alpha, so please let me know if you run into any issues.
“The Future is a Big-Ass Table”
This parody on Microsoft “Surface” made me laugh today:
Reborn as a Bug?
Oh thank heaven for the beauty of context-sensitive advertising.
As most people on the Mozilla project, I get quite a bit of bugmail from bugzilla. Needless to say, Google mail tries to adapt to this situation by delivering me the ads that they believe are the most appropriate for the mail I am currently looking at:
“Will you be reincarnated as a bug?”
Well, I hope not! What if they resolve me INVALID?
Minefield?
Minefield, pfft… what kind of name is that?
From a funny love letter Mozilla received. It’s part of a nice picture series wired.com took at the Mozilla headquarters. Check it out.
I love miro more than Chris Blizzard
… because I donated $200.
Along with a weak attempt at trumping the blizz, it will help Miro sustain. These amazing folks are out trying to liberate media. They are taking the control of our daily impression away from empires and enabling us all to get our message out. And they all do it while living together in a giant house on barely any resources. Hooorraaahhh.
Anyone else willing to match Chris Blizzard or myself? Please donate now, they really need the help.
Here are some of my favorite channels I’ve found only because of Miro.
- therealnews - a daily, independent, news segment.
- Global Pulse - they take a topic (weekly) and report it from various media outlets around the world. US v. Iran? See how it is reported from China, Russia, and the US — only a *few* differences…
- Shralp! Snowboarding - always great to watch people hucking off mountain tops with your neighbors on the plane
- A-Z of bushcraft - P is for plants, S is for spoon… check out how to be useful post-apocalypse
I <3 Miro. If you do too, now is the time to show a little love.
Fees, fees, fees
If there’s one word that can summarize US Visa applications, it’s fees…
Today I already had the pleasure to pay three of them:
- SEVIS fee (= a database entry in the student exchange database), USD 100.-
- Visa appointment scheduling fee, USD 10.-
- Visa application fee, EUR 89.08 which is about USD 140.-
So before the application form is filed, you are already spending 250 Dollars in fees (not to mention the cost of driving to the embassy in Frankfurt). What eases the pain a little is the good euro-to-dollar exchange rate at the moment.
But of course unlike last time I don’t seem to be required to prove my proficiency in English so that saves me another few hundred dollars. Looks like it’s my lucky day.
Statistik mit Stifti
Als ich gestern dieses Flugblatt gesehen habe:
… dachte ich: Wieviel beliebter könnten eigentlich Statstikvorlesungen sein, wenn man sie Statistik mit Stifti taufen würde? Spiel, Spaß und Spannung in einem! Abenteuer im Zahlenraum zwischen 0 und 1!
Kein Wunder, dass die Vorlesungen einen eher schlechten Ruf haben. Alles eine Frage des Marketings.
Firefox Sculpture
There are a couple stories here — but the main one is that my Aunty M’s Firefox sculpture made it into Wired!
My Aunt Margaret is an artist from Loxahatchee, Florida — where she runs Goodhaven Farms. On top of Firefox art, she sculpts and paints. Check out her art, including a web page I made 6 years ago, here.
Hmm… maybe I need to ask her to send another piece of art to the office….
Snail Mail
Wow. I just unsubscribed from a Barnes and Noble promotion mailing list (that I didn’t even subscribe to in the first place…) and they literally ask for 10 business days to unsubscribe me from the list:
If they delivered their books as “fast” as they manage their mailing lists they’d probably have lost all their customers by now…