CEXPORT JSBool def_animate_class_constructor(JSContext *cx, unsigned argc, jsval *vp) { JS_BeginRequest(cx); JSObject *thiz = animate_create_ctor_object(cx, vp); jsval *argv = JS_ARGV(cx, vp); if (unlikely(argc < 2 || !JSVAL_IS_OBJECT(argv[0]) || !JSVAL_IS_OBJECT(argv[1]))) { LOG("{animate} ERROR: Animate constructor arguments were invalid!"); JS_EndRequest(cx); return JS_FALSE; } else { JSObject *js_timestep_view = JSVAL_TO_OBJECT(argv[0]), *js_group = JSVAL_TO_OBJECT(argv[1]); jsval __view; JS_GetProperty(cx, js_timestep_view, "__view", &__view); timestep_view *view = (timestep_view *)JS_GetPrivate(JSVAL_TO_OBJECT(__view)); if (view) { view_animation *anim = view_animation_init(view); JS_SetPrivate(thiz, (void*)anim); anim->js_anim = thiz; js_object_wrapper_root(&anim->js_group, js_group); } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(thiz)); JS_EndRequest(cx); return JS_TRUE; } }
bool timestep_view_add_subview(timestep_view *v, timestep_view *subview) { LOGFN("timestep_view_add_subview"); if (subview->superview == v) { return false; } if (subview->superview) { timestep_view_remove_subview(subview->superview, subview); } if (v->subview_array_size <= v->subview_count) { v->subview_array_size *= 2; v->subviews = (timestep_view**)realloc(v->subviews, sizeof(timestep_view*) * v->subview_array_size); } //LOG(">>> adding to view %i subview %i; current size %i", v->uid, subview->uid, v->subview_count); subview->subview_index = v->subview_count; v->subviews[v->subview_count++] = subview; subview->superview = v; subview->added_at = ++add_order; subview->needs_reflow = true; v->dirty_z_index = true; js_object_wrapper_root(&subview->pin_view, subview->js_view); LOGFN("end timestep_view_add_subview"); return true; }
static inline void build_func_frame(anim_frame *frame, JSObject *cb) { js_object_wrapper_root(&frame->cb, cb); frame->type = FUNC_FRAME; }