Author: miguel
Date: 2007-06-07 18:25:40 -0400 (Thu, 07 Jun 2007)
New Revision: 78900
Modified:
trunk/olive/class/agclr/ChangeLog
trunk/olive/class/agclr/Makefile
trunk/olive/class/agclr/Mono/ChangeLog
trunk/olive/class/agclr/Mono/NativeMethods.cs
trunk/olive/class/agclr/System.Windows.Controls/Canvas.cs
trunk/olive/class/agclr/System.Windows.Controls/ChangeLog
trunk/olive/class/agclr/System.Windows.Controls/Panel.cs
trunk/olive/class/agclr/System.Windows/ChangeLog
trunk/olive/class/agclr/System.Windows/DependencyObject.cs
trunk/olive/class/agclr/System.Windows/DependencyProperty.cs
trunk/olive/class/agclr/System.Windows/FrameworkElement.cs
trunk/olive/class/agclr/System.Windows/XamlReader.cs
trunk/olive/class/agclr/agclr.dll.sources
Log:
2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
* DependecyObject.cs: Partial implementation for GetValue.
Drop tons of dead code.
* DependencyProperty.cs: Rework to use the native dependency
objects instead of implementing a managed one.
Both DependencyObject and DependencyProperty are now wrappers to
the unmanaged version for now. We will need to extend this
later to support the managed components when we are ready.
* FrameworkElement.cs: Update to new DependencyProperty
framework.
2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
* Canvas.cs, Panel.cs: Rework to use the dependency properties
registered in the unmanaged side, remove dead code.
Modified: trunk/olive/class/agclr/ChangeLog
===================================================================
--- trunk/olive/class/agclr/ChangeLog 2007-06-07 22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/ChangeLog 2007-06-07 22:25:40 UTC (rev 78900)
@@ -1,3 +1,9 @@
+2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * Drop the use of the native XAML parser
+
+ * Add Value.cs
+
2007-06-05 Sebastien Pouliot <[EMAIL PROTECTED]>
* agclr.dll.sources: Added System.Windows.Media.Alignment[X|Y] enums,
Modified: trunk/olive/class/agclr/Makefile
===================================================================
--- trunk/olive/class/agclr/Makefile 2007-06-07 22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/Makefile 2007-06-07 22:25:40 UTC (rev 78900)
@@ -3,6 +3,6 @@
LIBRARY = agclr.dll
-LIB_MCS_FLAGS = -r:System -r:System.Xml -d:AGCLR
+LIB_MCS_FLAGS = -r:System -r:System.Xml -d:AGCLR -unsafe
include ../../build/library.make
Modified: trunk/olive/class/agclr/Mono/ChangeLog
===================================================================
--- trunk/olive/class/agclr/Mono/ChangeLog 2007-06-07 22:07:49 UTC (rev
78899)
+++ trunk/olive/class/agclr/Mono/ChangeLog 2007-06-07 22:25:40 UTC (rev
78900)
@@ -1,3 +1,11 @@
+2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * NativeMethods.cs: add new dependency_property_lookup,
+ dependency_object_get_value, dependency_object_set_value,
+ canvas_new.
+
+ update rectangle_new
+
2007-06-04 Miguel de Icaza <[EMAIL PROTECTED]>
* NativeMethods.cs: Added the beginning of the bindings to `moon'.
Modified: trunk/olive/class/agclr/Mono/NativeMethods.cs
===================================================================
--- trunk/olive/class/agclr/Mono/NativeMethods.cs 2007-06-07 22:07:49 UTC
(rev 78899)
+++ trunk/olive/class/agclr/Mono/NativeMethods.cs 2007-06-07 22:25:40 UTC
(rev 78900)
@@ -1,5 +1,5 @@
//
-// Panel.cs
+// NativeMethods.cs
//
// Author:
// Miguel de Icaza ([EMAIL PROTECTED])
@@ -33,6 +33,9 @@
internal static class NativeMethods {
+ [DllImport("moon")]
+ internal extern static void runtime_init ();
+
#region Base
[DllImport("moon")]
internal extern static void base_ref (IntPtr ptr);
@@ -41,6 +44,17 @@
internal extern static void base_unref (IntPtr ptr);
#endregion
+ [DllImport("moon")]
+ internal extern static IntPtr dependency_property_lookup
(Value.Kind type, string name);
+
+ [DllImport("moon")]
+ internal extern static IntPtr dependency_object_get_value
(IntPtr obj, IntPtr property);
+
+ [DllImport("moon")]
+ internal extern static IntPtr dependency_object_set_value
(IntPtr obj, IntPtr property, Value val);
+
+
+
#region Items
[DllImport("moon")]
internal extern static IntPtr item_get_surface (IntPtr item);
@@ -59,6 +73,11 @@
[DllImport("moon")]
internal extern static IntPtr panel_get_children_collection
(IntPtr panel);
#endregion
+
+#region Canvas
+ [DllImport("moon")]
+ internal extern static IntPtr canvas_new ();
+#endregion
#region Collections
[DllImport("moon")]
@@ -67,7 +86,7 @@
#region Shapes
[DllImport("moon")]
- internal extern static IntPtr rectangle_new (double x, double
y, double w, double h);
+ internal extern static IntPtr rectangle_new ();
#endregion
}
}
Modified: trunk/olive/class/agclr/System.Windows/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows/ChangeLog 2007-06-07 22:07:49 UTC
(rev 78899)
+++ trunk/olive/class/agclr/System.Windows/ChangeLog 2007-06-07 22:25:40 UTC
(rev 78900)
@@ -1,3 +1,19 @@
+2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * DependecyObject.cs: Partial implementation for GetValue.
+
+ Drop tons of dead code.
+
+ * DependencyProperty.cs: Rework to use the native dependency
+ objects instead of implementing a managed one.
+
+ Both DependencyObject and DependencyProperty are now wrappers to
+ the unmanaged version for now. We will need to extend this
+ later to support the managed components when we are ready.
+
+ * FrameworkElement.cs: Update to new DependencyProperty
+ framework.
+
2007-06-03 Sebastien Pouliot <[EMAIL PROTECTED]>
* ErrorEventArgs.cs: New.
Modified: trunk/olive/class/agclr/System.Windows/DependencyObject.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/DependencyObject.cs 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows/DependencyObject.cs 2007-06-07
22:25:40 UTC (rev 78900)
@@ -27,50 +27,146 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System.Collections.Generic;
+using System.Collections;
+using Mono;
+using System.Windows;
+using System.Windows.Controls;
+using System.Runtime.InteropServices;
namespace System.Windows {
public class DependencyObject {
- string name;
- private static
Dictionary<Type,Dictionary<string,DependencyProperty>> property_declarations =
- new
Dictionary<Type,Dictionary<string,DependencyProperty>>();
+ static Hashtable objects = new Hashtable ();
+ internal IntPtr native;
- public virtual object GetValue(DependencyProperty dp)
+ //
+ // This is mostly copied from Gtk#'s Object.GetObject
+ // we need to take into account in the future:
+ // WeakReferences
+ // ToggleReferences (talk to Mike)
+ //
+ //
+ internal static DependencyObject Lookup (Value.Kind k, IntPtr
ptr)
{
- throw new NotImplementedException ();
+ if (ptr == IntPtr.Zero)
+ return null;
+
+ object reference = objects [ptr];
+ if (reference != null)
+ return (DependencyObject) reference;
+
+ return (DependencyObject) CreateObject (k, ptr);
}
- public void SetValue<T>(DependencyProperty dp, T value)
+ static object CreateObject (Value.Kind k, IntPtr raw)
{
- throw new NotImplementedException ();
+ if (k <= Value.Kind.DEPENDENCY_OBJECT)
+ throw new Exception ("the kind has to be a
derived DependencyObject");
+
+ switch (k){
+ case Value.Kind.UIELEMENT:
+ return null;
+
+ case Value.Kind.PANEL:
+ return null;
+
+ case Value.Kind.CANVAS:
+ return new Canvas (raw);
+
+ case Value.Kind.TIMELINE: return null;
+ case Value.Kind.TRANSFORM: return null;
+ case Value.Kind.ROTATETRANSFORM: return null;
+ case Value.Kind.SCALETRANSFORM: return null;
+ case Value.Kind.TRANSLATETRANSFORM: return null;
+ case Value.Kind.MATRIXTRANSFORM: return null;
+ case Value.Kind.STORYBOARD: return null;
+ case Value.Kind.DOUBLEANIMATION: return null;
+ case Value.Kind.COLORANIMATION: return null;
+ case Value.Kind.POINTANIMATION: return null;
+ case Value.Kind.SHAPE: return null;
+ case Value.Kind.ELLIPSE: return null;
+ case Value.Kind.LINE: return null;
+ case Value.Kind.PATH: return null;
+ case Value.Kind.POLYGON: return null;
+ case Value.Kind.POLYLINE: return null;
+ case Value.Kind.RECTANGLE: return null;
+ case Value.Kind.GEOMETRY: return null;
+ case Value.Kind.GEOMETRYGROUP: return null;
+ case Value.Kind.ELLIPSEGEOMETRY: return null;
+ case Value.Kind.LINEGEOMETRY: return null;
+ case Value.Kind.PATHGEOMETRY: return null;
+ case Value.Kind.RECTANGLEGEOMETRY: return null;
+ case Value.Kind.FRAMEWORKELEMENT: return null;
+ case Value.Kind.NAMESCOPE: return null;
+ case Value.Kind.CLOCK: return null;
+ case Value.Kind.ANIMATIONCLOCK: return null;
+ case Value.Kind.CLOCKGROUP: return null;
+ case Value.Kind.BRUSH: return null;
+ case Value.Kind.SOLIDCOLORBRUSH: return null;
+ case Value.Kind.PATHFIGURE: return null;
+ case Value.Kind.ARCSEGMENT: return null;
+ case Value.Kind.BEZIERSEGMENT: return null;
+ case Value.Kind.LINESEGMENT: return null;
+ case Value.Kind.POLYBEZIERSEGMENT: return null;
+ case Value.Kind.POLYLINESEGMENT: return null;
+ case Value.Kind.POLYQUADRATICBEZIERSEGMENT: return null;
+ case Value.Kind.QUADRATICBEZIERSEGMENT: return null;
+ case Value.Kind.TRIGGERACTION: return null;
+ case Value.Kind.BEGINSTORYBOARD: return null;
+ case Value.Kind.EVENTTRIGGER: return null;
+ }
+
+ return null;
}
- public DependencyObject FindName (string name)
+ public virtual object GetValue (DependencyProperty property)
{
- throw new NotImplementedException ();
- }
+ IntPtr x = NativeMethods.dependency_object_get_value
(native, property.native);
- public string Name {
- get {
- return name;
+ if (x == IntPtr.Zero)
+ return null;
+
+ unsafe {
+ byte *px = (byte *) x;
+ Value.Kind k = (Value.Kind) (*((int *)px));
+
+ px += 4;
+
+ switch (k) {
+ case Value.Kind.INVALID:
+ return null;
+
+ case Value.Kind.BOOL:
+ throw new NotImplementedException ();
+
+ case Value.Kind.DOUBLE:
+ return *((double *) px);
+
+ case Value.Kind.INT64:
+ return *((long *) px);
+
+ case Value.Kind.INT32:
+ return *((int *) px);
+
+ case Value.Kind.STRING:
+ return Marshal.PtrToStringAuto
((IntPtr) px);
+ }
+
+ //
+ // If it is a dependency object
+ if (k > Value.Kind.DEPENDENCY_OBJECT){
+ IntPtr vptr = *((IntPtr *) px);
+ if (vptr == IntPtr.Zero)
+ return null;
+
+ return DependencyObject.Lookup (k,
vptr);
+ }
}
+
+ throw new NotImplementedException ();
}
- internal static void Register (Type t, DependencyProperty dp)
- {
- Dictionary<string,DependencyProperty> type_declarations;
-
- if (!property_declarations.TryGetValue (t, out
type_declarations)){
- property_declarations [t] = new
Dictionary<string,DependencyProperty>();
- }
-
- Console.WriteLine ("This code is not bound to unmanaged
code");
- return;
-
- if (!type_declarations.ContainsKey (dp.Name))
- type_declarations [dp.Name] = dp;
- else
- throw new Exception("A property named " +
dp.Name + " already exists on " + t.Name);
- }
+ public virtual void SetValue<T> (DependencyProperty property, T
obj)
+ {
+ }
}
}
Modified: trunk/olive/class/agclr/System.Windows/DependencyProperty.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/DependencyProperty.cs
2007-06-07 22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows/DependencyProperty.cs
2007-06-07 22:25:40 UTC (rev 78900)
@@ -28,43 +28,38 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using Mono;
namespace System.Windows {
public class DependencyProperty {
- readonly internal PropertyMetadata DefaultMetadata;
- readonly internal string Name;
- readonly internal Type OwnerType;
- readonly internal Type PropertyType;
- readonly internal bool IsAttached;
-
- private DependencyProperty (bool isAttached, string name, Type
propertyType, Type ownerType,
- PropertyMetadata defaultMetadata)
- {
- this.IsAttached = isAttached;
- this.DefaultMetadata = (defaultMetadata == null ? new
PropertyMetadata() : defaultMetadata);
-
- this.Name = name;
- this.OwnerType = ownerType;
- this.PropertyType = propertyType;
- }
-
+ internal IntPtr native;
+
public DependencyProperty ()
{
// useless constructor.
}
- internal static DependencyProperty Register (string name, Type
propertyType, Type ownerType)
+ internal DependencyProperty (IntPtr handle)
{
- return Register (name, propertyType, ownerType, null);
+ native = handle;
}
+
+ internal static DependencyProperty Lookup (Value.Kind type,
string name)
+ {
+ IntPtr handle =
NativeMethods.dependency_property_lookup (type, name);
- internal static DependencyProperty Register (string name, Type
propertyType, Type ownerType,
- PropertyMetadata
typeMetadata)
+ if (handle == IntPtr.Zero)
+ return null;
+
+ return new DependencyProperty (handle);
+ }
+
+ internal static DependencyProperty Register (string name, Type
propertyType, Type ownerType)
{
- DependencyProperty dp = new DependencyProperty (false,
name, propertyType, ownerType,
-
typeMetadata);
- DependencyObject.Register (ownerType, dp);
- return dp;
+ Console.WriteLine ("This way of registering properties
is no longer supported:");
+ Console.WriteLine ("owner={0} {1} of type {2}",
ownerType, name, propertyType);
+
+ return null;
}
}
}
Modified: trunk/olive/class/agclr/System.Windows/FrameworkElement.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/FrameworkElement.cs 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows/FrameworkElement.cs 2007-06-07
22:25:40 UTC (rev 78900)
@@ -25,6 +25,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using Mono;
namespace System.Windows {
public abstract class FrameworkElement : UIElement {
@@ -32,8 +33,8 @@
static FrameworkElement ()
{
- WidthProperty = DependencyProperty.Register ("Width",
typeof (double), typeof (FrameworkElement));
- HeightProperty = DependencyProperty.Register ("Height",
typeof (double), typeof (FrameworkElement));
+ WidthProperty = DependencyProperty.Lookup
(Value.Kind.FRAMEWORKELEMENT, "Width");
+ HeightProperty = DependencyProperty.Lookup
(Value.Kind.FRAMEWORKELEMENT, "Height");
}
public FrameworkElement ()
Modified: trunk/olive/class/agclr/System.Windows/XamlReader.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/XamlReader.cs 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows/XamlReader.cs 2007-06-07
22:25:40 UTC (rev 78900)
@@ -37,14 +37,7 @@
public static DependencyObject Load (string xaml)
{
- XmlTextReader tr = new XmlTextReader (new StringReader
(xaml));
-
- //
- // This uses the names from Ian McCoy's implementation
- // which has not yet been updated to the final API
- // and is even on a different namespace
- //
- return (DependencyObject)
System.Windows.Serialization.Parser.LoadXml (tr);
+ throw new NotImplementedException ();
}
public static DependencyObject Load (string xaml, bool
createNamescope)
Modified: trunk/olive/class/agclr/System.Windows.Controls/Canvas.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows.Controls/Canvas.cs 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows.Controls/Canvas.cs 2007-06-07
22:25:40 UTC (rev 78900)
@@ -26,25 +26,27 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Windows;
+using Mono;
namespace System.Windows.Controls {
public class Canvas : Panel {
+ public static readonly DependencyProperty LeftProperty;
+ public static readonly DependencyProperty TopProperty;
+
static Canvas ()
{
- LeftProperty = DependencyProperty.Register (
- "Left", typeof (double), typeof (Canvas));
+ LeftProperty = DependencyProperty.Lookup
(Value.Kind.CANVAS, "Left");
+ TopProperty = DependencyProperty.Lookup
(Value.Kind.CANVAS, "Top");
+ }
- TopProperty = DependencyProperty.Register (
- "Top", typeof (double), typeof (Canvas));
+ public Canvas ()
+ {
+ native = Mono.NativeMethods.canvas_new ();
}
- public static readonly DependencyProperty LeftProperty;
- public static readonly DependencyProperty TopProperty;
-
- // Temporarily public, for testing.
- public Canvas (IntPtr native_object)
+ internal Canvas (IntPtr raw)
{
- native = native_object;
+ native = raw;
}
}
}
Modified: trunk/olive/class/agclr/System.Windows.Controls/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows.Controls/ChangeLog 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows.Controls/ChangeLog 2007-06-07
22:25:40 UTC (rev 78900)
@@ -1,3 +1,8 @@
+2007-06-07 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * Canvas.cs, Panel.cs: Rework to use the dependency properties
+ registered in the unmanaged side, remove dead code.
+
2007-06-04 Miguel de Icaza <[EMAIL PROTECTED]>
* Canvas.cs: Add native IntPtr field that points to the native
Modified: trunk/olive/class/agclr/System.Windows.Controls/Panel.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows.Controls/Panel.cs 2007-06-07
22:07:49 UTC (rev 78899)
+++ trunk/olive/class/agclr/System.Windows.Controls/Panel.cs 2007-06-07
22:25:40 UTC (rev 78900)
@@ -32,18 +32,13 @@
namespace System.Windows.Controls {
public class Panel : FrameworkElement {
- internal IntPtr native;
-
public static readonly DependencyProperty ChildrenProperty;
public static readonly DependencyProperty BackgroundProperty;
static Panel ()
{
- ChildrenProperty = DependencyProperty.Register (
- "Children", typeof (VisualCollection), typeof
(Panel));
-
- BackgroundProperty = DependencyProperty.Register (
- "Background", typeof (Brush), typeof (Panel));
+ ChildrenProperty = DependencyProperty.Lookup
(Value.Kind.PANEL, "Children");
+ BackgroundProperty = DependencyProperty.Lookup
(Value.Kind.PANEL, "Background");
}
public Panel ()
@@ -62,22 +57,7 @@
public VisualCollection Children {
get {
- object v = GetValue (ChildrenProperty);
- if (v != null)
- return (VisualCollection) v;
-
- //
- // Should this be done really in some sort of
callback
- // in "GetValue"?
- //
- // Should it have been the "default" value?
- //
- VisualCollection value = new VisualCollection (
-
NativeMethods.panel_get_children_collection (native));
-
- SetValue (ChildrenProperty, value);
-
- return value;
+ return (VisualCollection) GetValue
(ChildrenProperty);
}
set {
Modified: trunk/olive/class/agclr/agclr.dll.sources
===================================================================
--- trunk/olive/class/agclr/agclr.dll.sources 2007-06-07 22:07:49 UTC (rev
78899)
+++ trunk/olive/class/agclr/agclr.dll.sources 2007-06-07 22:25:40 UTC (rev
78900)
@@ -2,29 +2,8 @@
Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/MonoTODOAttribute.cs
-../PresentationFramework/System.Windows.Serialization/IAddChild.cs
-../PresentationFramework/System.Windows.Serialization/BamlAttributeUsage.cs
-../PresentationFramework/System.Windows.Serialization/Mapper.cs
-../PresentationFramework/System.Windows.Serialization/NamespaceMapEntry.cs
-../PresentationFramework/System.Windows.Serialization/Parser.cs
-../PresentationFramework/System.Windows.Serialization/XamlClrEventNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlAttributeNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlElementEndNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlKeyElementStartNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlNodeType.cs
-../PresentationFramework/System.Windows.Serialization/XamlParseMode.cs
-../PresentationFramework/System.Windows.Serialization/XamlElementStartNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlTextNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlDocumentEndNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlLiteralContentNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlDocumentStartNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlPropertyNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlPropertyComplexEndNode.cs
-../PresentationFramework/System.Windows.Serialization/XamlPropertyComplexStartNode.cs
-../PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
-../PresentationFramework/Mono.Windows.Serialization/ParserConsumerBase.cs
Mono/NativeMethods.cs
+Mono/Value.cs
System.Windows/Downloader.cs
System.Windows/ErrorEventArgs.cs
System.Windows/ErrorEventHandler.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches