Author: toshok
Date: 2007-10-15 18:05:41 -0400 (Mon, 15 Oct 2007)
New Revision: 87538
Modified:
trunk/moon/ChangeLog
trunk/moon/TODO
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/dependencyobject.cpp
trunk/moon/src/dependencyobject.h
trunk/moon/src/type.cpp
trunk/moon/src/type.cpp.in
trunk/moon/src/typegen.cs
Log:
from .:
2007-10-15 Chris Toshok <[EMAIL PROTECTED]>
* TODO: add blurb about collapsing Base and EventObject into 1
class.
from src/:
2007-10-15 Chris Toshok <[EMAIL PROTECTED]>
* animation.[h,cpp]: remove the strong reference from
AnimationStorage to its target object, and instead use the
EventObject::DestroyEvent to implement a weak reference. See the
TODO for a blurb about generalizing this.
* typegen.cs (GenerateTypeCpp): remove the special case code that
makes INVALID the parent of DEPENDENCY_OBJECT - we need it to have
EVENTOBJECT as the parent for the DestroyedEvent to line up
properly in the event tables.
* type.cpp.in, type.cpp (types_init_register_events): register the
Destroyed event.
* dependencyobject.[h,cpp]: add EventObject::DestroyedEvent,
emitted just before we clean up the EventObject's event list.
Modified: trunk/moon/ChangeLog
===================================================================
--- trunk/moon/ChangeLog 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/ChangeLog 2007-10-15 22:05:41 UTC (rev 87538)
@@ -1,3 +1,8 @@
+2007-10-15 Chris Toshok <[EMAIL PROTECTED]>
+
+ * TODO: add blurb about collapsing Base and EventObject into 1
+ class.
+
2007-10-01 Andrew Jorgensen <[EMAIL PROTECTED]>
* src/Makefile.am: Added fullscreen.h to dist
Modified: trunk/moon/TODO
===================================================================
--- trunk/moon/TODO 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/TODO 2007-10-15 22:05:41 UTC (rev 87538)
@@ -1,6 +1,16 @@
Feel free to add items to this TODO list
+* Base classes / Reference counting:
+
+ Right now we have two base classes below DependencyObject
+ (Base and EventObject). These should be merged into 1 class
+ that provides both sets of functionality (reference counting
+ and events, respectively.) This would allow us to write a
+ more general weak reference system instead of the special case
+ one that exists now (The EventObject::DestroyedEvent stuff
+ used by the AnimationStorage class).
+
* Samples:
Although we are going to need to have API coverage through
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/ChangeLog 2007-10-15 22:05:41 UTC (rev 87538)
@@ -1,3 +1,21 @@
+2007-10-15 Chris Toshok <[EMAIL PROTECTED]>
+
+ * animation.[h,cpp]: remove the strong reference from
+ AnimationStorage to its target object, and instead use the
+ EventObject::DestroyEvent to implement a weak reference. See the
+ TODO for a blurb about generalizing this.
+
+ * typegen.cs (GenerateTypeCpp): remove the special case code that
+ makes INVALID the parent of DEPENDENCY_OBJECT - we need it to have
+ EVENTOBJECT as the parent for the DestroyedEvent to line up
+ properly in the event tables.
+
+ * type.cpp.in, type.cpp (types_init_register_events): register the
+ Destroyed event.
+
+ * dependencyobject.[h,cpp]: add EventObject::DestroyedEvent,
+ emitted just before we clean up the EventObject's event list.
+
2007-10-15 Jeffrey Stedfast <[EMAIL PROTECTED]>
* text.cpp (Layout): I think I finally figured out the scaling to
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/animation.cpp 2007-10-15 22:05:41 UTC (rev 87538)
@@ -37,13 +37,24 @@
{
clock->AddHandler (clock->CurrentTimeInvalidatedEvent,
update_property_value, this);
+ targetobj->AddHandler (EventObject::DestroyedEvent,
target_object_destroyed, this);
baseValue = new Value(*targetobj->GetValue (targetprop));
+}
- targetobj->ref();
+void
+AnimationStorage::target_object_destroyed (EventObject *, gpointer, gpointer
closure)
+{
+ ((AnimationStorage*)closure)->TargetObjectDestroyed ();
}
void
+AnimationStorage::TargetObjectDestroyed ()
+{
+ targetobj = NULL;
+}
+
+void
AnimationStorage::update_property_value (EventObject *, gpointer, gpointer
closure)
{
((AnimationStorage*)closure)->UpdatePropertyValue ();
@@ -52,6 +63,9 @@
void
AnimationStorage::UpdatePropertyValue ()
{
+ if (targetobj == NULL)
+ return;
+
Value *current_value = clock->GetCurrentValue (baseValue, NULL/*XXX*/);
if (current_value != NULL)
targetobj->SetValue (targetprop, *current_value);
@@ -64,6 +78,9 @@
void
AnimationStorage::ResetPropertyValue ()
{
+ if (targetobj == NULL)
+ return;
+
targetobj->SetValue (targetprop, *baseValue);
}
@@ -71,8 +88,6 @@
{
if (baseValue)
delete baseValue;
-
- targetobj->unref();
}
AnimationClock::AnimationClock (Animation/*Timeline*/ *timeline)
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/animation.h 2007-10-15 22:05:41 UTC (rev 87538)
@@ -121,6 +121,9 @@
void ResetPropertyValue ();
private:
+ void TargetObjectDestroyed ();
+ static void target_object_destroyed (EventObject *sender, gpointer
calldata, gpointer data);
+
void UpdatePropertyValue ();
static void update_property_value (EventObject *sender, gpointer
calldata, gpointer data);
Modified: trunk/moon/src/dependencyobject.cpp
===================================================================
--- trunk/moon/src/dependencyobject.cpp 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/dependencyobject.cpp 2007-10-15 22:05:41 UTC (rev 87538)
@@ -863,6 +863,9 @@
void
dependencyobject_init(void)
{
+ Type *t = Type::Find(Type::EVENTOBJECT);
+ EventObject::DestroyedEvent = t->LookupEvent ("Destroyed");
+
DependencyObject::NameProperty = DependencyObject::Register
(Type::DEPENDENCY_OBJECT, "Name", Type::STRING);
}
@@ -873,6 +876,8 @@
gpointer data;
} EventClosure;
+int EventObject::DestroyedEvent = -1;
+
EventObject::EventObject ()
{
events = NULL;
@@ -886,6 +891,8 @@
EventObject::~EventObject ()
{
+ Emit (DestroyedEvent);
+
if (events) {
for (int i = 0; i < GetType()->GetEventCount(); i ++)
g_slist_foreach (events[i], (GFunc)deleter, NULL);
Modified: trunk/moon/src/dependencyobject.h
===================================================================
--- trunk/moon/src/dependencyobject.h 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/dependencyobject.h 2007-10-15 22:05:41 UTC (rev 87538)
@@ -121,6 +121,8 @@
virtual Type::Kind GetObjectType () { return Type::EVENTOBJECT; }
+ static int DestroyedEvent;
+
protected:
void Emit (char *event_name, gpointer calldata = NULL);
void Emit (int event_id, gpointer calldata = NULL);
Modified: trunk/moon/src/type.cpp
===================================================================
--- trunk/moon/src/type.cpp 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/type.cpp 2007-10-15 22:05:41 UTC (rev 87538)
@@ -250,6 +250,9 @@
{
Type* t;
+ t = Type::Find (Type::EVENTOBJECT);
+ t->RegisterEvent ("Destroyed");
+
t = Type::Find (Type::STORYBOARD);
t->RegisterEvent ("Completed");
@@ -308,7 +311,7 @@
void
types_init (void)
{
- Type::RegisterType ("DependencyObject", Type::DEPENDENCY_OBJECT, false);
+ Type::RegisterType ("DependencyObject", Type::DEPENDENCY_OBJECT,
Type::EVENTOBJECT);
Type::RegisterType ("Animation", Type::ANIMATION, Type::TIMELINE);
Type::RegisterType ("AnimationClock", Type::ANIMATIONCLOCK,
Type::CLOCK);
Type::RegisterType ("ArcSegment", Type::ARCSEGMENT, Type::PATHSEGMENT);
Modified: trunk/moon/src/type.cpp.in
===================================================================
--- trunk/moon/src/type.cpp.in 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/type.cpp.in 2007-10-15 22:05:41 UTC (rev 87538)
@@ -245,6 +245,9 @@
{
Type* t;
+ t = Type::Find (Type::EVENTOBJECT);
+ t->RegisterEvent ("Destroyed");
+
t = Type::Find (Type::STORYBOARD);
t->RegisterEvent ("Completed");
Modified: trunk/moon/src/typegen.cs
===================================================================
--- trunk/moon/src/typegen.cs 2007-10-15 21:46:36 UTC (rev 87537)
+++ trunk/moon/src/typegen.cs 2007-10-15 22:05:41 UTC (rev 87538)
@@ -268,11 +268,9 @@
if (hash.ContainsKey (c))
p = (string) hash [c];
- if (p != null && p != string.Empty && c !=
"DependencyObject") {
+ if (p != null && p != string.Empty) {
text.AppendLine (string.Format
("\tType::RegisterType (\"{0}\", Type::{1}, Type::{2});", c, getU(c), getU
(p)));
- } else if (c == "DependencyObject"){
- text.AppendLine (string.Format
("\tType::RegisterType (\"{0}\", Type::{1}, false);", c, getU(c)));
- }
+ }
}
text.AppendLine ("\ttypes_init_manually ();");
text.AppendLine ("\ttypes_init_register_events ();");
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches