gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...


From: zou lunkai
Subject: Re: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...
Date: Mon, 9 Apr 2007 18:15:38 +0800

On 4/9/07, Sandro Santilli <address@hidden> wrote:
On Mon, Apr 09, 2007 at 09:41:40AM +0800, zou lunkai wrote:
> +     // TODO: are we sure we shouldn't check for frames labeled with
> negative
> +    // numbers ?
> this case is already tested in swfdec/test/trace/gotoframe.swf.
>
> eg. x = "-2";
> GotoAndStop(x);
>
> x will be converted a NAN when calling "frame_spec.to_number()", then
> if there is a frame labeled as "-2", it will be found.

Really ?? "-2" converts to NaN ? How so ?


sorry, this was  my mistake.

x = "-2";
GotoAndStop(x) == GotoAndStop(-2) == DoNothing(don't stop the current
frame, and don't push any actions)


bool
sprite_instance::get_frame_number(const as_value& frame_spec, size_t&
frameno) const
{
        //GNASH_REPORT_FUNCTION;

        as_environment* env = const_cast<as_environment*>(&m_as_environment);

           //becuase the "toString()" is expected to be invoked...
        as_value str(frame_spec.to_std_string(env));

            //alway convert the std_string to a number first. If this
conversion succeeded,
           //then we try to fetch the number-th frame. We do this
even the result number
           //is not a valid frame index.
        double num =  str.to_number(env);

        if ( isnan(num) || isinf(num))
        {
        return m_def->get_labeled_frame(frame_spec.to_string(env), &frameno);
        }

        // TODO: are we sure we shouldn't check for frames labeled with negative
           //numbers ?
           // I think so, we are not going to look for a number-labeled frame.
        if ( num < 1 ) return false;

        // all frame numbers >= 0 are valid, but a valid frame number may still
        // reference a non-exist frame(eg. frameno > total_frames).
        frameno = num - 1;

        return true;
}


although currently implementation seems work, I don't like its signature.
Is this one better:

errorCode
sprite_instance::get_frame_number(const as_value& frame_spec, size_t&
frameno) const

errorCode might be just a "int"  type.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]