gnash-commit
[Top][All Lists]
Advanced

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

Re: [Gnash-commit] gnash ChangeLog server/asobj/Date.cpp server/as...


From: Bastiaan Jacques
Subject: Re: [Gnash-commit] gnash ChangeLog server/asobj/Date.cpp server/as...
Date: Fri, 2 Feb 2007 14:43:05 +0100 (CET)



On Thu, 1 Feb 2007, Martin Guy wrote:

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Martin Guy <martinwguy>   07/02/01 23:18:21

Modified files:
        .              : ChangeLog
        server/asobj   : Date.cpp Global.cpp string.cpp

Log message:
        Convert all assert()s that triggered by illegal number of args in 
runtime
        ActionScript to IF_VERBOSE_ASCODING_ERRORS() warnings with and keep 
going,
        giving safe default return values.



Patches:
[snip]

+// Common code to warn and return if a required single arg is not present
+// and to warn if there are extra args.
+#define ASSERT_FN_ARGS_IS_1                                            \
+    if (fn.nargs < 1) {                                                     \
+       IF_VERBOSE_ASCODING_ERRORS(                                     \
+            log_aserror(__FUNCTION__ " needs one argument");         \
+            )                                                          \
+         return;                                                       \
+    }                                                                  \
+    IF_VERBOSE_ASCODING_ERRORS(                                                
\
+       if (fn.nargs > 1)                                            \
+            log_aserror(__FUNCTION__ " has more than one argument"); \
+    )

This macro shouldn't be called ASSERT_[..], unless it includes a call to
assert(). Also, you could modify this macro to be usable given any number of fn args. In addition, you may want to make the macro "return" when the fn.nargs is less than what is required. So, for example:


#define ENSURE_FN_ARGC(count, rv)              \
  if (fn.nargs > count) {                      \
    IF_VERBOSE_ASCODING_ERRORS(                \
      log_aserror("too many args");            \
    )                                          \
  } else if (fn.nargs < count) {               \
    IF_VERBOSE_ASCODING_ERRORS(                \
      log_aserror("too few args: returning."); \
    )                                          \
    return rv;                                 \
  }

This could then be used as:

void as_dosomething(fn)
{
  ENSURE_FN_ARGC(2, )
  // ..
}

class* as_dosomethingelse(fn)
{
  ENSURE_FN_ARGC(1, NULL)
  // ..
}


Bastiaan




reply via email to

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