[Swfdec] some patches for swfdec

Benjamin Otte otte at gnome.org
Wed Jun 6 00:09:36 PDT 2007


On 6/4/07, Nguyen Thai Ngoc Duy <pclouds at gmail.com> wrote:
> Anyway, about assertions, error handling.. do
> you have any guideline to follow up? I was a little confused when
> implementing actions/new methods. What should I do if something goes
> wrong, such as not enough parameters, wrong type...
>
Here's how I handle it:
Rule number 1: Check everything. Swfdec must not crash. People get
very annoyed when it takes down their browser. An example:
swfdec_as_value_to_object() can return NULL.
Rule number 2: If I encounter some thing you don't know, write a test
that exposes it. (I need to update my blog with a test-writing howto.)
Rule number 3: If I'm too lazy to write a test or can't find a way to
expose the problem, I add a FIXME debug message. Something like this:
if (!SWFDEC_AS_VALUE_IS_OBJECT (value)) {
  SWFDEC_FIXME ("value is not an object, converting");
}
object = swfdec_as_value_to_object (cx, value);
This makes it a lot easier to find possible problems later on. Just
implementing something that looks ok can cause problems later on, when
I debug Flash files that rely on some weird behaviour.

> Well I thought about subclassing (wrongly) context for that. I
> searched back the history but not found any implementation for
> SwfdecAsWith. Will look into it again to see what I can improve.
>
I have started implementing With now. It's not complete, but should be
at the end of today.

> Okay. I'll leave that for you ;) Those movie/sprite things seem
> over-complicated to me.
>
Anything in particular that seems over-complicated? I'm very
interested in the parts of the code people struggle with, as people
reading the code are the best indicators of code that needs
improvements or at least comments.

> Er.. _levelN isn't implemented at all or am I missing something? Maybe
> it's just inaccessible from ActionScript?
>
You're right. That's a bug that needs to be fixed. It used to work,
but doesn't anymore. Guess I need a test for that.

Cheers,
Benjamin


More information about the Swfdec mailing list