2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
24 #include "swfdec_as_internal.h"
25 #include "swfdec_as_object.h"
26 #include "swfdec_as_strings.h"
27 #include "swfdec_as_context.h"
28 #include "swfdec_as_frame_internal.h"
29 #include "swfdec_debug.h"
33 SWFDEC_AS_NATIVE (101, 12, broadcastMessage
)
35 broadcastMessage (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
36 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
39 SwfdecAsObject
*listeners
, *o
;
42 GSList
*list
= NULL
, *walk
;
49 name
= swfdec_as_value_to_string (cx
, argv
[0]);
53 swfdec_as_object_get_variable (object
, SWFDEC_AS_STR__listeners
, &val
);
54 if (!SWFDEC_AS_VALUE_IS_COMPOSITE (*&val
))
57 listeners
= SWFDEC_AS_VALUE_GET_COMPOSITE (*&val
);
58 swfdec_as_object_get_variable (listeners
, SWFDEC_AS_STR_length
, &val
);
59 length
= swfdec_as_value_to_integer (cx
, &val
);
61 /* return undefined if we won't try to call anything */
65 /* FIXME: solve this wth foreach, so it gets faster for weird cases */
66 for (i
= 0; i
< length
; i
++) {
67 swfdec_as_object_get_variable (listeners
, swfdec_as_integer_to_string (cx
, i
), &val
);
68 o
= swfdec_as_value_to_object (cx
, &val
);
71 list
= g_slist_prepend (list
, o
);
76 list
= g_slist_reverse (list
);
77 for (walk
= list
; walk
; walk
= walk
->next
) {
78 swfdec_as_object_call (walk
->data
, name
, argc
, argv
, &val
);
82 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, TRUE
);