Author: fejj
Date: 2007-08-31 18:47:14 -0400 (Fri, 31 Aug 2007)
New Revision: 85156
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/brush.cpp
trunk/moon/src/clock.cpp
trunk/moon/src/collection.cpp
trunk/moon/src/collection.h
trunk/moon/src/dirty.cpp
trunk/moon/src/geometry.cpp
trunk/moon/src/list.cpp
trunk/moon/src/list.h
trunk/moon/src/namescope.cpp
trunk/moon/src/panel.cpp
trunk/moon/src/text.cpp
trunk/moon/src/transform.cpp
trunk/moon/src/trigger.cpp
trunk/moon/src/xaml.cpp
Log:
2007-08-31 Jeffrey Stedfast <[EMAIL PROTECTED]>
*.cpp: Updated for the slightly different List API (list nodes no
longer have Next() or Prev() methods, just access the pointers
directly).
* animation.cpp: Made sorted_list a GPtrArray and updated to sue
g_ptr_array_insert_sorted(). Also, a lot of the 'list' (not
sorted_list) accesses assumed nodes were of type KeyFrameNode,
which they were not. Fixed.
* xaml.cpp: Made XamlElementInstance.dtor virtual.
* collection.h: Made the Collection::Node.dtor virtual.
* list.cpp: Rewritten, if we add a virtual .dtor to List::Node, we
can no longer guarantee that List::Node->next will have the same
address as the List::Node object and so the list implementation
broke. This rewrite is a bit less fancy, but doesn't rely on that
feature.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/ChangeLog 2007-08-31 22:47:14 UTC (rev 85156)
@@ -1,3 +1,24 @@
+2007-08-31 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ *.cpp: Updated for the slightly different List API (list nodes no
+ longer have Next() or Prev() methods, just access the pointers
+ directly).
+
+ * animation.cpp: Made sorted_list a GPtrArray and updated to sue
+ g_ptr_array_insert_sorted(). Also, a lot of the 'list' (not
+ sorted_list) accesses assumed nodes were of type KeyFrameNode,
+ which they were not. Fixed.
+
+ * xaml.cpp: Made XamlElementInstance.dtor virtual.
+
+ * collection.h: Made the Collection::Node.dtor virtual.
+
+ * list.cpp: Rewritten, if we add a virtual .dtor to List::Node, we
+ can no longer guarantee that List::Node->next will have the same
+ address as the List::Node object and so the list implementation
+ broke. This rewrite is a bit less fancy, but doesn't rely on that
+ feature.
+
2007-08-31 Sebastien Pouliot <[EMAIL PROTECTED]>
* media.cpp, panel.cpp, shape.cpp, text.cpp: Calling GrowBy
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/animation.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <math.h>
+#include "garray-ext.h"
#include "animation.h"
#include "color.h"
@@ -677,19 +678,12 @@
}
-class KeyFrameNode : public List::Node {
-public:
- KeyFrame *key_frame;
-
- KeyFrameNode (KeyFrame *kf) { key_frame = kf; }
-};
-
static int
-KeyFrameNodeComparer (List::Node *kfn1, List::Node *kfn2)
+KeyFrameComparer (gconstpointer kf1, gconstpointer kf2)
{
// Assumes timespan keytimes only
- TimeSpan ts1 = ((KeyFrameNode *) kfn1)->key_frame->resolved_keytime;
- TimeSpan ts2 = ((KeyFrameNode *) kfn2)->key_frame->resolved_keytime;
+ TimeSpan ts1 = ((KeyFrame *) kf1)->resolved_keytime;
+ TimeSpan ts2 = ((KeyFrame *) kf2)->resolved_keytime;
TimeSpan tsdiff = ts1 - ts2;
if (tsdiff == 0)
@@ -702,14 +696,13 @@
KeyFrameCollection::KeyFrameCollection ()
{
- sorted_list = new List ();
+ sorted_list = g_ptr_array_new ();
resolved = false;
}
KeyFrameCollection::~KeyFrameCollection ()
{
- sorted_list->Clear (true);
- delete sorted_list;
+ g_ptr_array_free (sorted_list, true);
}
bool
@@ -743,31 +736,30 @@
KeyFrameCollection::Clear ()
{
resolved = false;
- sorted_list->Clear (true);
+ g_ptr_array_set_size (sorted_list, 0);
Collection::Clear ();
}
-KeyFrame*
+KeyFrame *
KeyFrameCollection::GetKeyFrameForTime (TimeSpan t, KeyFrame **prev_frame)
{
KeyFrame *current_keyframe = NULL;
KeyFrame *previous_keyframe = NULL;
- List::Node *cur, *prev = NULL;
+ guint i;
/* figure out what segment to use (this assumes the list is sorted) */
- for (cur = sorted_list->First (); cur; prev = cur, cur = cur->Next ()) {
- KeyFrame *keyframe = ((KeyFrameNode *) cur)->key_frame;
+ for (i = 0; i < sorted_list->len; i++) {
+ KeyFrame *keyframe = (KeyFrame *) sorted_list->pdata[i];
TimeSpan key_end_time = keyframe->resolved_keytime;
- if (key_end_time >= t || cur->Next() == NULL) {
+ if (key_end_time >= t || (i + 1) >= sorted_list->len) {
current_keyframe = keyframe;
- if (prev)
- previous_keyframe = ((KeyFrameNode *)
prev)->key_frame;
+ if (i > 0)
+ previous_keyframe = (KeyFrame *)
sorted_list->pdata[i - 1];
break;
}
-
}
if (prev_frame != NULL)
@@ -1084,15 +1076,15 @@
TimeSpan highest_keytime_timespan = 0;
List::Node *cur;
- for (cur = col->list->First (); cur; cur = cur->Next ()) {
- KeyFrame *keyframe = ((KeyFrameNode *) cur)->key_frame;
+ for (cur = col->list->First (); cur; cur = cur->next) {
+ KeyFrame *keyframe = (KeyFrame *) ((Collection::Node *)
cur)->obj;
keyframe->resolved_keytime = 0;
keyframe->resolved = false;
}
/* resolve TimeSpan keyframes (step 1 from url) */
- for (cur = col->list->First (); cur; cur = cur->Next ()) {
- KeyFrame *keyframe = ((KeyFrameNode *) cur)->key_frame;
+ for (cur = col->list->First (); cur; cur = cur->next) {
+ KeyFrame *keyframe = (KeyFrame *) ((Collection::Node *)
cur)->obj;
if (keyframe->GetKeyTime()->HasTimeSpan()) {
has_timespan_keyframe = true;
TimeSpan ts = keyframe->GetKeyTime()->GetTimeSpan ();
@@ -1118,8 +1110,8 @@
/* use the total interpolation time to resolve percent keytime
keyframes (step 3 from url) */
- for (cur = col->list->First (); cur; cur = cur->Next ()) {
- KeyFrame *keyframe = ((KeyFrameNode *) cur)->key_frame;
+ for (cur = col->list->First (); cur; cur = cur->next) {
+ KeyFrame *keyframe = (KeyFrame *) ((Collection::Node *)
cur)->obj;
if (keyframe->GetKeyTime()->HasPercent()) {
keyframe->resolved_keytime =
(TimeSpan)(total_interpolation_time * keyframe->GetKeyTime()->GetPercent ());
keyframe->resolved = true;
@@ -1131,7 +1123,7 @@
KeyTime *kt;
/* if the last frame is KeyTime Uniform or Paced, resolve it
to be equal to the total interpolation time */
- keyframe = ((KeyFrameNode *)col->list->Last ())->key_frame;
+ keyframe = (KeyFrame *) ((Collection::Node *) col->list->Last ())->obj;
kt = keyframe->GetKeyTime ();
if (*kt == KeyTime::Paced || *kt == KeyTime::Uniform) {
keyframe->resolved_keytime = total_interpolation_time;
@@ -1146,7 +1138,7 @@
** note 1 is handled in the above block so we only have to
** handle 2 here.
*/
- keyframe = ((KeyFrameNode *)col->list->First ())->key_frame;
+ keyframe = (KeyFrame *) ((Collection::Node *) col->list->First ())->obj;
kt = keyframe->GetKeyTime ();
if (!keyframe->resolved && *kt == KeyTime::Paced) {
@@ -1166,17 +1158,15 @@
/* insert the nodes into the sorted list using a stable sort
with resolved keytime as primary key, declaration order as
secondary key (step 8 from url) */
- col->sorted_list->Clear (false);
-
- for (cur = col->list->First (); cur; cur = cur->Next ()) {
- KeyFrame *keyframe = ((KeyFrameNode *) cur)->key_frame;
+ g_ptr_array_set_size (col->sorted_list, 0);
+
+ for (cur = col->list->First (); cur; cur = cur->next) {
+ KeyFrame *keyframe = (KeyFrame *) ((Collection::Node *)
cur)->obj;
if (!keyframe->resolved) {
g_warning ("***** unresolved keyframe!");
}
-
- KeyFrameNode *kfn = new KeyFrameNode (keyframe);
-
- col->sorted_list->InsertSorted (kfn, KeyFrameNodeComparer);
+
+ g_ptr_array_insert_sorted (col->sorted_list, KeyFrameComparer,
keyframe);
}
}
@@ -1282,15 +1272,15 @@
}
Duration
-DoubleAnimationUsingKeyFrames::GetNaturalDurationCore (Clock* clock)
+DoubleAnimationUsingKeyFrames::GetNaturalDurationCore (Clock *clock)
{
DoubleKeyFrameCollection *key_frames = GetValue
(DoubleAnimationUsingKeyFrames::KeyFramesProperty)->AsDoubleKeyFrameCollection
();
-
+
KeyFrameAnimation_ResolveKeyFrames (this, key_frames);
- KeyFrameNode *node = (KeyFrameNode*)key_frames->sorted_list->Last ();
- if (node)
- return node->key_frame->resolved_keytime;
+ guint len = key_frames->sorted_list->len;
+ if (len > 0)
+ return ((KeyFrame *) key_frames->sorted_list->pdata[len -
1])->resolved_keytime;
else
return Duration::Automatic;
}
@@ -1411,10 +1401,10 @@
ColorAnimationUsingKeyFrames::GetNaturalDurationCore (Clock *clock)
{
ColorKeyFrameCollection *key_frames = GetValue
(ColorAnimationUsingKeyFrames::KeyFramesProperty)->AsColorKeyFrameCollection ();
-
- KeyFrameNode *node = (KeyFrameNode*)key_frames->sorted_list->Last ();
- if (node)
- return node->key_frame->resolved_keytime;
+
+ guint len = key_frames->sorted_list->len;
+ if (len > 0)
+ return ((KeyFrame *) key_frames->sorted_list->pdata[len -
1])->resolved_keytime;
else
return Duration::Automatic;
}
@@ -1535,10 +1525,10 @@
PointAnimationUsingKeyFrames::GetNaturalDurationCore (Clock* clock)
{
PointKeyFrameCollection *key_frames = GetValue
(PointAnimationUsingKeyFrames::KeyFramesProperty)->AsPointKeyFrameCollection ();
-
- KeyFrameNode *node = (KeyFrameNode*)key_frames->sorted_list->Last ();
- if (node)
- return node->key_frame->resolved_keytime;
+
+ guint len = key_frames->sorted_list->len;
+ if (len > 0)
+ return ((KeyFrame *) key_frames->sorted_list->pdata[len -
1])->resolved_keytime;
else
return Duration::Automatic;
}
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/animation.h 2007-08-31 22:47:14 UTC (rev 85156)
@@ -282,7 +282,7 @@
virtual bool Insert (int index, DependencyObject *data);
virtual void Clear ();
- List *sorted_list;
+ GPtrArray *sorted_list;
bool resolved;
Modified: trunk/moon/src/brush.cpp
===================================================================
--- trunk/moon/src/brush.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/brush.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -307,7 +307,7 @@
double opacity = GetTotalOpacity (uielement);
node = (Collection::Node *) children->list->First ();
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
GradientStop *stop = (GradientStop *) node->obj;
Color *color = gradient_stop_get_color (stop);
double offset = gradient_stop_get_offset (stop);
Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/clock.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -835,7 +835,7 @@
Collection::Node *node;
node = (Collection::Node *) collection->list->First ();
- for ( ; node != NULL; node = (Collection::Node *) node->Next ())
+ for ( ; node != NULL; node = (Collection::Node *) node->next)
group->AddChild (((Timeline *) node->obj)->AllocateClock ());
return group;
@@ -870,7 +870,7 @@
if (!node)
return Duration::FromSeconds (0);
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
Timeline *timeline = (Timeline *) node->obj;
Duration duration = timeline->GetNaturalDuration (clock);
Modified: trunk/moon/src/collection.cpp
===================================================================
--- trunk/moon/src/collection.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/collection.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -143,13 +143,11 @@
generation++;
Node *old = (Collection::Node *) list->Replace (new Collection::Node
(data, this), index);
-
- old->Unlink ();
-
+
data->Attach (NULL, this);
old->obj->Detach (NULL, this);
-
- if (closure){
+
+ if (closure) {
closure->OnCollectionChanged (this,
CollectionChangeTypeItemRemoved, old->obj, NULL);
closure->OnCollectionChanged (this,
CollectionChangeTypeItemAdded, data, NULL);
}
@@ -177,7 +175,7 @@
if (!(n = (Collection::Node *) list->Find (CollectionNodeFinder, data)))
return false;
- n->Unlink ();
+ list->Unlink (n);
data->Detach (NULL, this);
@@ -206,8 +204,8 @@
generation++;
- n->Unlink ();
-
+ list->Unlink (n);
+
n->obj->Detach (NULL, this);
if (closure) {
@@ -231,7 +229,7 @@
Collection::Node *n;
generation++;
- for (n = (Collection::Node*)list->First(); n; n =
(Collection::Node*)n->Next()) {
+ for (n = (Collection::Node *) list->First (); n; n = (Collection::Node
*) n->next) {
n->obj->Detach (NULL, this);
NameScope *ns = NameScope::GetNameScope (n->obj);
@@ -350,7 +348,7 @@
return 1;
}
- List::Node *next = iterator->current->Next ();
+ List::Node *next = iterator->current->next;
if (next == NULL)
return 0;
@@ -409,12 +407,6 @@
UIElementNode (UIElement *v) : item (v) { }
};
-static bool
-UIElementNodeFinder (List::Node *uin, void *data)
-{
- return ((UIElementNode *) uin)->item == (UIElement *) data;
-}
-
static int
UIElementZIndexComparer (gconstpointer ui1, gconstpointer ui2)
{
Modified: trunk/moon/src/collection.h
===================================================================
--- trunk/moon/src/collection.h 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/collection.h 2007-08-31 22:47:14 UTC (rev 85156)
@@ -26,7 +26,7 @@
DependencyObject *obj;
Node (DependencyObject *dob, DependencyObject *parent);
- ~Node ();
+ virtual ~Node ();
};
int generation;
Modified: trunk/moon/src/dirty.cpp
===================================================================
--- trunk/moon/src/dirty.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/dirty.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -80,7 +80,7 @@
// because that causes the element to
recompute
// its local transform as well, which
isn't necessary.
add_dirty_element ((UIElement *)
n->obj, DirtyTransform);
- n = (Collection::Node *) n->Next ();
+ n = (Collection::Node *) n->next;
}
}
else if (el->Is (Type::CONTROL)) {
@@ -103,7 +103,7 @@
Collection::Node* n = (Collection::Node *)
children->list->First ();
while (n != NULL) {
((UIElement *)
n->obj)->UpdateTotalOpacity ();
- n = (Collection::Node *) n->Next ();
+ n = (Collection::Node *) n->next;
}
}
else if (el->Is (Type::CONTROL)) {
Modified: trunk/moon/src/geometry.cpp
===================================================================
--- trunk/moon/src/geometry.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/geometry.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -136,7 +136,7 @@
Geometry::Draw (path, cr);
node = (Collection::Node *) children->list->First ();
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
Geometry *geometry = (Geometry *) node->obj;
geometry->Draw (path, cr);
}
@@ -354,7 +354,7 @@
Geometry::Draw (path, cr);
node = (Collection::Node *) children->list->First ();
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
PathFigure *pf = (PathFigure *) node->obj;
pf->Draw (path, cr);
}
@@ -538,7 +538,7 @@
cairo_move_to (cr, start->x, start->y);
node = (Collection::Node *) children->list->First ();
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
PathSegment *ps = (PathSegment *) node->obj;
ps->Draw (cr);
}
Modified: trunk/moon/src/list.cpp
===================================================================
--- trunk/moon/src/list.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/list.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -13,68 +13,42 @@
#include <config.h>
#endif
-#include <stdio.h>
#include "list.h"
List::Node::Node ()
{
- next = this;
- prev = this;
+ next = 0;
+ prev = 0;
}
-List::Node *
-List::Node::Next ()
-{
- return next->next ? next : 0;
-}
-
-
-List::Node *
-List::Node::Prev ()
-{
- return prev->prev ? prev : 0;
-}
-
-
-List::Node *
-List::Node::Unlink ()
-{
- next->prev = prev;
- prev->next = next;
-
- return this;
-}
-
-
List::List ()
{
- head = (List::Node *) &tail;
+ head = 0;
tail = 0;
- tailpred = (List::Node *) &head;
}
List::Node *
List::First ()
{
- return head->next ? head : 0;
+ return head;
}
List::Node *
List::Last ()
{
- return head->next ? tailpred : 0;
+ return tail;
}
bool
List::IsEmpty ()
{
- return head == (List::Node *) &tail;
+ return !head;
}
@@ -85,7 +59,7 @@
int n = 0;
node = head;
- while (node->next) {
+ while (node) {
node = node->next;
n++;
}
@@ -101,27 +75,31 @@
List::Node *n, *nn;
n = head;
- while (n->next) {
+ while (n) {
nn = n->next;
delete n;
n = nn;
}
}
- head = (List::Node *) &tail;
+ head = 0;
tail = 0;
- tailpred = (List::Node *) &head;
}
List::Node *
List::Append (List::Node *node)
{
- node->next = (List::Node *) &tail;
- node->prev = tailpred;
- tailpred->next = node;
- tailpred = node;
+ node->prev = tail;
+ node->next = 0;
+ if (tail)
+ tail->next = node;
+ else
+ head = node;
+
+ tail = node;
+
return node;
}
@@ -130,8 +108,13 @@
List::Prepend (List::Node *node)
{
node->next = head;
- node->prev = (List::Node *) &head;
- head->prev = node;
+ node->prev = 0;
+
+ if (head)
+ head->prev = node;
+ else
+ tail = node;
+
head = node;
return node;
@@ -144,63 +127,36 @@
List::Node *n = head;
int i = 0;
- while (n->next && i < index) {
- n = n->next;
- i++;
+ if (head) {
+ while (n->next && i < index) {
+ n = n->next;
+ i++;
+ }
+
+ if (i == index) {
+ if (n == tail)
+ tail = node;
+
+ n->prev->next = node;
+ node->prev = n->prev;
+ node->next = n;
+ n->prev = node;
+ } else {
+ tail = n->next = node;
+ node->prev = n;
+ node->next = 0;
+ }
+ } else {
+ head = tail = node;
+ node->next = 0;
+ node->prev = 0;
}
- node->prev = n->prev;
- node->next = n;
- n->prev->next = node;
- n->prev = node;
-
return node;
}
List::Node *
-List::InsertSorted (List::Node *node, NodeComparer cmp)
-{
- List::Node *n = head;
-
- if (!cmp)
- return Append (node);
-
- while (n->next && cmp (n, node) < 0)
- n = n->next;
-
- node->prev = n->prev;
- node->next = n;
- n->prev->next = node;
- n->prev = node;
-
- return node;
-}
-
-
-List::Node *
-List::InsertSorted (List::Node *node, NodeComparer cmp, bool stable)
-{
- List::Node *n = Last ();
-
- if (!cmp || !n)
- return Append (node);
-
- if (!stable)
- return InsertSorted (node, cmp);
-
- while (n->prev && cmp (n, node) > 0)
- n = n->prev;
-
- node->prev = n->prev;
- node->next = n;
- n->prev->next = node;
- n->prev = node;
-
- return node;
-}
-
-List::Node *
List::Replace (List::Node *node, int index)
{
List::Node *n;
@@ -210,12 +166,20 @@
node->next = n->next;
node->prev = n->prev;
- n->prev->next = node;
- n->next->prev = node;
- n->next = n;
- n->prev = n;
+ if (n->prev)
+ n->prev->next = node;
+ else
+ head = node;
+ if (n->next)
+ n->next->prev = node;
+ else
+ tail = node;
+
+ n->next = 0;
+ n->prev = 0;
+
return n;
}
@@ -227,7 +191,7 @@
if (!find)
return 0;
- while (n->next) {
+ while (n) {
if (find (n, data))
return n;
@@ -244,11 +208,26 @@
List::Node *n;
if ((n = Find (find, data))) {
- n->Unlink ();
+ Unlink (n);
delete n;
}
}
+
+void
+List::Unlink (List::Node *node)
+{
+ if (head == node)
+ head = node->next;
+
+ if (tail == node)
+ tail = node->prev;
+
+ node->prev = 0;
+ node->next = 0;
+}
+
+
List::Node *
List::Index (int index)
{
@@ -258,7 +237,7 @@
if (index < 0)
return 0;
- while (n->next && i < index) {
+ while (n && i < index) {
n = n->next;
i++;
}
@@ -275,7 +254,7 @@
List::Node *n = head;
int i = 0;
- while (n->next && n != node) {
+ while (n && n != node) {
n = n->next;
i++;
}
@@ -293,7 +272,7 @@
if (!find)
return -1;
- while (n->next) {
+ while (n) {
if (find (n, data))
return i;
@@ -306,29 +285,6 @@
-
-void
-Stack::Push (List::Node *node)
-{
- Prepend (node);
-}
-
-
-List::Node *
-Stack::Pop ()
-{
- List::Node *n = head;
-
- if (!n->next)
- return 0;
-
- n->next->prev = n->prev;
- head = n->next;
-
- return n;
-}
-
-
//#define TEST_PROGRAM
#ifdef TEST_PROGRAM
@@ -361,24 +317,22 @@
node = list->Append (new IntNode (1));
printf ("appended node with id = %d\n", ((IntNode *) node)->id);
+ node = list->Append (new IntNode (3));
+ printf ("appended node with id = %d\n", ((IntNode *) node)->id);
node = list->Append (new IntNode (4));
printf ("appended node with id = %d\n", ((IntNode *) node)->id);
- node = list->Append (new IntNode (5));
- printf ("appended node with id = %d\n", ((IntNode *) node)->id);
node = list->Insert (new IntNode (2), 1);
printf ("inserted node with id = %d at index = %d\n",
((IntNode *) node)->id, list->IndexOf (node));
node = list->Prepend (new IntNode (0));
printf ("prepended node with id = %d\n", ((IntNode *) node)->id);
- node = list->InsertSorted (new IntNode (3), IntNodeCompare);
- printf ("insert sorted node with id = %d\n", ((IntNode *) node)->id);
printf ("\nlist contains (in order):\n");
- for (node = list->First (); node != NULL; node = node->Next ())
+ for (node = list->First (); node != NULL; node = node->next)
printf ("node id = %d\n", ((IntNode *) node)->id);
printf ("\nlist contains (in reverse order):\n");
- for (node = list->Last (); node != NULL; node = node->Prev ())
+ for (node = list->Last (); node != NULL; node = node->prev)
printf ("node id = %d\n", ((IntNode *) node)->id);
list->Clear (true);
Modified: trunk/moon/src/list.h
===================================================================
--- trunk/moon/src/list.h 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/list.h 2007-08-31 22:47:14 UTC (rev 85156)
@@ -17,26 +17,20 @@
public:
class Node {
public:
- // these should be treated as private
Node *next;
Node *prev;
// public
Node ();
-
- Node *Next ();
- Node *Prev ();
-
- Node *Unlink ();
+ virtual ~Node () { }
};
- typedef int (* NodeComparer) (Node *n0, Node *n1);
typedef bool (* NodeFinder) (Node *node, void *data);
protected:
Node *head;
Node *tail;
- Node *tailpred;
+
public:
// constructors
List ();
@@ -53,13 +47,12 @@
Node *Append (Node *node);
Node *Prepend (Node *node);
Node *Insert (Node *node, int index);
- Node *InsertSorted (Node *node, NodeComparer cmp);
- Node *InsertSorted (Node *node, NodeComparer cmp, bool stable);
Node *Replace (Node *node, int index);
Node *Find (NodeFinder find, void *data);
void Remove (NodeFinder find, void *data);
+ void Unlink (Node *node);
Node *Index (int index);
@@ -67,16 +60,4 @@
int IndexOf (NodeFinder find, void *data);
};
-
-class Stack : public List {
-public:
- // constructors
- Stack () { }
-
- // methods
- void Push (Node *node);
- Node *Pop ();
-};
-
-
#endif /* __LIST_H__ */
Modified: trunk/moon/src/namescope.cpp
===================================================================
--- trunk/moon/src/namescope.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/namescope.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -58,7 +58,7 @@
if (o)
return o;
- for (NameScopeNode *n =
(NameScopeNode*)merged_child_namescopes->First(); n; n =
(NameScopeNode*)n->Next()) {
+ for (NameScopeNode *n = (NameScopeNode *)
merged_child_namescopes->First (); n; n = (NameScopeNode *) n->next) {
o = n->ns->FindName (name);
if (o)
return o;
Modified: trunk/moon/src/panel.cpp
===================================================================
--- trunk/moon/src/panel.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/panel.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -89,7 +89,7 @@
printf ("Panel: Enter ComputeBounds\n");
#endif
cn = (Collection::Node *) children->list->First ();
- for ( ; cn != NULL; cn = (Collection::Node *) cn->Next ()) {
+ for ( ; cn != NULL; cn = (Collection::Node *) cn->next) {
UIElement *item = (UIElement *) cn->obj;
// if the item doesn't take part in layout
@@ -462,7 +462,7 @@
Collection::Node *cn;
cn = (Collection::Node *) children->list->First ();
- for ( ; cn != NULL; cn = (Collection::Node *) cn->Next ()) {
+ for ( ; cn != NULL; cn = (Collection::Node *) cn->next) {
UIElement *item = (UIElement *) cn->obj;
item->OnLoaded ();
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/text.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -634,7 +634,7 @@
pango_attr_list_insert (attrs, fg_attr);
loop:
- node = (Collection::Node *) node->Next ();
+ node = (Collection::Node *) node->next;
}
}
Modified: trunk/moon/src/transform.cpp
===================================================================
--- trunk/moon/src/transform.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/transform.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -445,7 +445,7 @@
cairo_matrix_init_identity (&_matrix);
- for ( ; node != NULL; node = (Collection::Node *) node->Next ()) {
+ for ( ; node != NULL; node = (Collection::Node *) node->next) {
Transform *transform = (Transform *) node->obj;
cairo_matrix_t matrix;
Modified: trunk/moon/src/trigger.cpp
===================================================================
--- trunk/moon/src/trigger.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/trigger.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -69,7 +69,7 @@
TriggerActionCollection *actions = trigger->GetValue
(EventTrigger::ActionsProperty)->AsTriggerActionCollection();
Collection::Node *n = (Collection::Node *) actions->list->First ();
- for ( ; n != NULL; n = (Collection::Node *) n->Next ()) {
+ for ( ; n != NULL; n = (Collection::Node *) n->next) {
TriggerAction *action = (TriggerAction *) n->obj;
action->Fire ();
}
Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp 2007-08-31 22:23:30 UTC (rev 85155)
+++ trunk/moon/src/xaml.cpp 2007-08-31 22:47:14 UTC (rev 85156)
@@ -97,12 +97,12 @@
children = new List ();
}
- ~XamlElementInstance ()
+ virtual ~XamlElementInstance ()
{
children->Clear (true);
delete children;
- if (instance_name)
- delete instance_name;
+ // if (instance_name)
+ // delete instance_name;
// if (element_name && element_type == PROPERTY)
// delete element_name;
}
@@ -594,7 +594,7 @@
else
g_warning ("Attempting to set property on
unknown type %s\n",
info->current_element->parent->element_name);
- walk = walk->Next ();
+ walk = walk->next;
}
break;
}
@@ -696,7 +696,7 @@
v = el->item->GetValue (DependencyObject::NameProperty);
printf ("%s (%s)\n", el->element_name, v ? v->AsString () : "-no
name-");
- for (List::Node *walk = el->children->First (); walk != NULL; walk =
walk->Next ()) {
+ for (List::Node *walk = el->children->First (); walk != NULL; walk =
walk->next) {
XamlElementInstance *el = (XamlElementInstance *) walk;
print_tree (el, depth + 1);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches