Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[ManagedTypeInfo] Only store the Type::Kind, not the string name (again)

Implement the same fix as last time except this time round do not change the
value stored in Type::name. Instead just have an additional field which will
always store the full type name. This is the value that the parser should use
and fixes the regression where styles in the SL3 parser could not be found.
  • Loading branch information...
commit a4e14bf1f781ef060e4dd4a8596819f29e31d1d9 1 parent 4717f2a
@alanmcgovern alanmcgovern authored
View
1  .gitignore
@@ -48,3 +48,4 @@ xdb.*
/src/factory.h
/src/type-generated.cpp
/config.cache
+*.pidb
View
7 class/System.Windows/Mono/Types.cs
@@ -147,7 +147,12 @@ private ManagedType RegisterType (Type type, ManagedType parent, ManagedType[] i
else {
string cp = GetContentPropertyName (type);
- info.native_handle = NativeMethods.types_register_type (native, type.FullName, cp,
+ // We explicitly use type.FullName instead of type.Name for the second parameter there. This is
+ // because only built-in types can register type.Name as their 'name'. This allows builtins to be
+ // accessed in xaml by writing stuff like "Control.Width" whereas custom types must be explicitly
+ // namespaced and prefixed so you have to write: clrMyNs:MyControl.Foo in xaml instead of just
+ // MyControl.Foo.
+ info.native_handle = NativeMethods.types_register_type (native, type.FullName, type.FullName, cp,
GCHandle.ToIntPtr (info.gc_handle),
(parent != null ? parent.native_handle : Kind.INVALID),
type.IsEnum,
View
8 class/System.Windows/Mono/Value.cs
@@ -125,7 +125,6 @@ public VideoFormat ToVideoFormat ()
[StructLayout(LayoutKind.Sequential)]
internal struct ManagedTypeInfo {
- public IntPtr full_name;
public Kind Kind;
}
@@ -711,13 +710,8 @@ public static Value FromObject (object v, bool box_value_types)
}
else if (v is Type) {
Type t = v as Type;
- ManagedTypeInfo mti = new ManagedTypeInfo ();
- mti.full_name = StringToIntPtr (t.FullName);
- mti.Kind = Deployment.Current.Types.TypeToKind (t);
-
value.k = Kind.MANAGEDTYPEINFO;
- value.u.p = Marshal.AllocHGlobal (sizeof (ManagedTypeInfo));
- Marshal.StructureToPtr (mti, value.u.p, false);
+ value.u.p = NativeMethods.managed_type_info_new (Deployment.Current.Types.TypeToKind (t));
} else if (v is Value) {
throw new InvalidOperationException ("You can not create a Mono.Value from a Mono.Value.");
}
View
3  class/tuning/SecurityAttributes/automatic/System.Windows.auto.sc
@@ -638,6 +638,9 @@
+SC-M: System.IntPtr Mono.NativeMethods::log_ready_routed_event_args_get_log_(System.IntPtr)
# p/invoke declaration
++SC-M: System.IntPtr Mono.NativeMethods::managed_type_info_new(Mono.Kind)
+
+# p/invoke declaration
+SC-M: System.IntPtr Mono.NativeMethods::matrix_get_matrix_values(System.IntPtr)
# p/invoke declaration
View
11 generators/Generator.cs
@@ -2849,9 +2849,9 @@ static void GenerateTypeStaticCpp (GlobalInfo all)
text.AppendLine ("Types::RegisterNativeTypes ()");
text.AppendLine ("{");
text.AppendLine ("\tDeployment *deployment = Deployment::GetCurrent ();");
- text.AppendLine ("\ttypes [(int) Type::INVALID] = new Type (deployment, Type::INVALID, Type::INVALID, false, false, false, NULL, 0, 0, NULL, 0, NULL, false, NULL, NULL );");
- text.AppendLine ("\ttypes [(int) Type::ENUM] = new Type (deployment, Type::ENUM, Type::OBJECT, false, false, false, \"Enum\", 0, 0, NULL, 0, NULL, false, NULL, NULL );");
- text.AppendLine ("\ttypes [(int) Type::DATETIME] = new Type (deployment, Type::DATETIME, Type::OBJECT, false, false, false, \"DateTime\", 0, 0, NULL, 0, NULL, false, NULL, NULL );");
+ text.AppendLine ("\ttypes [(int) Type::INVALID] = new Type (deployment, Type::INVALID, Type::INVALID, false, false, false, NULL, NULL, 0, 0, NULL, 0, NULL, false, NULL, NULL );");
+ text.AppendLine ("\ttypes [(int) Type::ENUM] = new Type (deployment, Type::ENUM, Type::OBJECT, false, false, false, \"Enum\", \"System.Enum\", 0, 0, NULL, 0, NULL, false, NULL, NULL );");
+ text.AppendLine ("\ttypes [(int) Type::DATETIME] = new Type (deployment, Type::DATETIME, Type::OBJECT, false, false, false, \"DateTime\", \"System.DateTime\", 0, 0, NULL, 0, NULL, false, NULL, NULL );");
foreach (TypeInfo type in all.Children.SortedTypesByKind) {
MemberInfo member;
@@ -2883,13 +2883,14 @@ static void GenerateTypeStaticCpp (GlobalInfo all)
parentKind = "OBJECT";
}
- text.AppendLine (string.Format (@" types [(int) {0}] = new Type (deployment, {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13});",
+ text.AppendLine (string.Format (@" types [(int) {0}] = new Type (deployment, {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14});",
"Type::" + type.KindName,
"Type::" + parentKind,
type.IsEnum ? "true" : "false",
IsValueType (type) ? "true" : "false",
type.IsInterface ? "true" : "false",
"\"" + type.Name + "\"",
+ "\"" + type.ManagedFullName + "\"",
type.GetEventCount (),
type.GetTotalEventCount (),
events,
@@ -2906,7 +2907,7 @@ static void GenerateTypeStaticCpp (GlobalInfo all)
);
}
- text.AppendLine ("\ttypes [(int) Type::LASTTYPE] = new Type (deployment, Type::LASTTYPE, Type::INVALID, false, false, false, NULL, 0, 0, NULL, 0, NULL, false, NULL, NULL);");
+ text.AppendLine ("\ttypes [(int) Type::LASTTYPE] = new Type (deployment, Type::LASTTYPE, Type::INVALID, false, false, false, NULL, NULL, 0, 0, NULL, 0, NULL, false, NULL, NULL);");
text.AppendLine ("}");
View
2  generators/MemberInfo.cs
@@ -155,7 +155,7 @@ class MemberInfo {
if (managed_fullname == null) {
if (Parent != null && !string.IsNullOrEmpty (Parent.ManagedFullName)) {
managed_fullname = Parent.ManagedFullName + "." + Name;
- } else if (Namespace != null) {
+ } else if (Namespace != null && Namespace != "None") {
managed_fullname = Namespace + "." + FullName;
} else {
managed_fullname = FullName;
View
2  src/contentcontrol.cpp
@@ -24,7 +24,7 @@ ContentControl::ContentControl ()
SetContentSetsParent (true);
SetObjectType (Type::CONTENTCONTROL);
- ManagedTypeInfo type_info (GetObjectType (), "System.Windows.Controls.ContentControl");
+ ManagedTypeInfo type_info (GetObjectType ());
SetDefaultStyleKey (&type_info);
}
View
22 src/managedtypeinfo.cpp
@@ -16,32 +16,20 @@
namespace Moonlight {
-ManagedTypeInfo::ManagedTypeInfo (Type::Kind kind, const char *full_name)
+ManagedTypeInfo::ManagedTypeInfo (Type::Kind kind)
{
- Initialize (kind, full_name);
+ this->kind = kind;
}
ManagedTypeInfo::ManagedTypeInfo (const ManagedTypeInfo& v)
{
- Initialize (v.kind, v.full_name);
-}
-
-ManagedTypeInfo::~ManagedTypeInfo ()
-{
- g_free (full_name);
-}
-
-void
-ManagedTypeInfo::Initialize (Type::Kind kind, const char *full_name)
-{
- this->kind = kind;
- this->full_name = g_strdup (full_name);
+ this->kind = v.kind;
}
bool
ManagedTypeInfo::operator == (const ManagedTypeInfo &v) const
{
- return kind == v.kind && strcmp (full_name, v.full_name) == 0;
+ return kind == v.kind;
}
bool
@@ -54,9 +42,7 @@ ManagedTypeInfo&
ManagedTypeInfo::operator = (const ManagedTypeInfo &v)
{
if (this != &v) {
- g_free (this->full_name);
this->kind = v.kind;
- this->full_name = g_strdup (v.full_name);
}
return *this;
}
View
8 src/managedtypeinfo.h
@@ -18,14 +18,12 @@ namespace Moonlight {
/* @IncludeInKinds */
class ManagedTypeInfo {
public:
- char *full_name;
Type::Kind kind;
- ManagedTypeInfo (Type::Kind kind, const char *full_name);
+ /* @GeneratePInvoke */
+ ManagedTypeInfo (Type::Kind kind);
ManagedTypeInfo (const ManagedTypeInfo& v);
- ~ManagedTypeInfo ();
-
- void Initialize (Type::Kind kind, const char *full_name);
+ ~ManagedTypeInfo () { }
bool operator == (const ManagedTypeInfo &v) const;
bool operator != (const ManagedTypeInfo &v) const;
View
2  src/provider.cpp
@@ -1205,7 +1205,7 @@ AutoCreators::CreateBlackBrush (Type::Kind kind, DependencyProperty *property, D
Value *
AutoCreators::ControlTypeCreator (Type::Kind kind, DependencyProperty *property, DependencyObject *forObj)
{
- ManagedTypeInfo info (Type::CONTROL, "System.Windows.Controls.Control");
+ ManagedTypeInfo info (Type::CONTROL);
return new Value (&info);
}
View
2  src/richtextbox.cpp
@@ -576,7 +576,7 @@ RichTextBox::RichTextBox ()
{
SetObjectType (Type::RICHTEXTBOX);
- ManagedTypeInfo type_info (GetObjectType (), "System.Windows.Controls.RichTextBox");
+ ManagedTypeInfo type_info (GetObjectType ());
SetDefaultStyleKey (&type_info);
AddHandler (UIElement::MouseLeftButtonMultiClickEvent, RichTextBox::mouse_left_button_multi_click, this);
View
8 src/textbox.cpp
@@ -556,11 +556,11 @@ GetClipboard (TextBoxBase *textbox, MoonClipboardType clipboardType)
}
void
-TextBoxBase::Initialize (Type::Kind type, const char *type_name)
+TextBoxBase::Initialize (Type::Kind type)
{
SetObjectType (type);
- ManagedTypeInfo type_info (GetObjectType (), type_name);
+ ManagedTypeInfo type_info (GetObjectType ());
SetDefaultStyleKey (&type_info);
AddHandler (UIElement::MouseLeftButtonMultiClickEvent, TextBoxBase::mouse_left_button_multi_click, this);
@@ -2529,7 +2529,7 @@ TextBox::TextBox ()
delete providers.dynamicvalue;
providers.dynamicvalue = new TextBoxDynamicPropertyValueProvider (this, PropertyPrecedence_DynamicValue);
- Initialize (Type::TEXTBOX, "System.Windows.Controls.TextBox");
+ Initialize (Type::TEXTBOX);
events_mask = TEXT_CHANGED | SELECTION_CHANGED;
multiline = true;
}
@@ -2882,7 +2882,7 @@ PasswordBox::PasswordBox ()
delete providers.dynamicvalue;
providers.dynamicvalue = new PasswordBoxDynamicPropertyValueProvider (this, PropertyPrecedence_DynamicValue);
- Initialize (Type::PASSWORDBOX, "System.Windows.Controls.PasswordBox");
+ Initialize (Type::PASSWORDBOX);
events_mask = TEXT_CHANGED;
secret = true;
View
2  src/textbox.h
@@ -242,7 +242,7 @@ class TextBoxBase : public Control, public ITextAttributes {
//
// Initialization/Destruction
//
- void Initialize (Type::Kind type, const char *type_name);
+ void Initialize (Type::Kind type);
virtual ~TextBoxBase ();
public:
View
8 src/type.cpp
@@ -26,7 +26,7 @@ namespace Moonlight {
* Type implementation
*/
Type::Type (Deployment *deployment, Type::Kind type, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface,
- const char *name,
+ const char *name, const char *full_name,
int event_count, int total_event_count, const char **events,
int interface_count, const Type::Kind *interfaces, bool ctor_visible,
create_inst_func *create_inst, const char *content_property)
@@ -37,6 +37,7 @@ Type::Type (Deployment *deployment, Type::Kind type, Type::Kind parent, bool is_
this->is_value_type = is_value_type;
this->is_interface = is_interface;
this->name = g_strdup (name);
+ this->full_name = g_strdup (full_name);
this->event_count = event_count;
this->total_event_count = total_event_count;
this->events = events;
@@ -73,6 +74,7 @@ Types::SetFastPaths ()
Type::~Type ()
{
g_free (name);
+ g_free (full_name);
g_free (content_property);
if (properties) {
@@ -521,9 +523,9 @@ Types::Find (const char *name, bool ignore_case)
}
Type::Kind
-Types::RegisterType (const char *name, const char *content_property, void *gc_handle, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface, bool ctor_visible, Type::Kind* interfaces, int interface_count)
+Types::RegisterType (const char *name, const char *full_name, const char *content_property, void *gc_handle, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface, bool ctor_visible, Type::Kind* interfaces, int interface_count)
{
- Type *type = new Type (Deployment::GetCurrent (), Type::INVALID, parent, is_enum, is_value_type, is_interface, name, 0, Find (parent)->GetEventCount (), NULL, interface_count, interfaces, ctor_visible, NULL, content_property);
+ Type *type = new Type (Deployment::GetCurrent (), Type::INVALID, parent, is_enum, is_value_type, is_interface, name, full_name, 0, Find (parent)->GetEventCount (), NULL, interface_count, interfaces, ctor_visible, NULL, content_property);
// printf ("Types::RegisterType (%s, %p, %i (%s)). this: %p, size: %i, count: %i\n", name, gc_handle, parent, Type::Find (this, parent) ? Type::Find (this, parent)->name : NULL, this, size, count);
View
6 src/type.h.in
@@ -73,6 +73,7 @@ public:
bool IsInterface () { return is_interface; }
bool IsCustomType () { return type > LASTTYPE; }
const char *GetName () { return name; }
+ const char *GetFullName () { return full_name; }
int GetEventCount () { return total_event_count; }
int GetInterfaceCount () { return interface_count; }
Type::Kind GetInterface (int i) { return i >= 0 && i < interface_count ? interfaces[i] : Type::INVALID; }
@@ -81,7 +82,7 @@ public:
~Type ();
Type (Deployment *deployment, Type::Kind type, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface,
- const char *name,
+ const char *name, const char *full_name,
int event_count, int total_event_count, const char **events,
int interface_count, const Type::Kind *interfaces, bool ctor_visible,
create_inst_func *create_inst, const char *content_property);
@@ -109,6 +110,7 @@ private:
bool is_dependencyobject; // if this type is a value type
char *name; // The name as it appears in code.
+ char *full_name; // The namespace prefixed typename.
int interface_count;
Type::Kind *interfaces;
@@ -145,7 +147,7 @@ public:
~Types ();
/* @GeneratePInvoke */
- Type::Kind RegisterType (const char *name, const char *content_property, void *gc_handle, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface, bool ctor_visible, /* @MarshalAs=Kind[] */Type::Kind *interfaces, int interface_count);
+ Type::Kind RegisterType (const char *name, const char *full_name, const char *content_property, void *gc_handle, Type::Kind parent, bool is_enum, bool is_value_type, bool is_interface, bool ctor_visible, /* @MarshalAs=Kind[] */Type::Kind *interfaces, int interface_count);
/* @GeneratePInvoke */
void RegisterInterfaces (Type::Kind type, /* @MarshalAs=Kind[] */Type::Kind *interfaces, int interface_count);
View
2  src/xaml.cpp
@@ -4842,7 +4842,7 @@ get_key_from_child (XamlElementInstance *child)
if (Type::IsSubclassOf (c->GetDeployment (), Type::STYLE, child->info->GetKind ())) {
Value *v = c->GetValue (Style::TargetTypeProperty);
if (!Value::IsNull (v))
- key = v->AsManagedTypeInfo ()->full_name;
+ key = c->GetDeployment ()->GetTypes ()->Find (v->AsManagedTypeInfo ()->kind)->GetFullName ();
if (key)
return key;
Please sign in to comment.
Something went wrong with that request. Please try again.