summaryrefslogtreecommitdiff
path: root/mono
diff options
context:
space:
mode:
authorOwen Fraser-Green <owen@discobabe.net>2004-03-25 14:04:43 +0000
committerOwen Fraser-Green <owen@discobabe.net>2004-03-25 14:04:43 +0000
commit2a46a2a319767a912df8d5bccdcc6959ce40f1bd (patch)
tree6b9ea31142e7d69a35165ffe0b29fb40bb304ee0 /mono
parent85d57636eb9e306a1740a55485ec89becaf6a015 (diff)
Added support for enumerations with marshalling to/from their underlying system type (Byte, Int32, UInt32, Int64, UInt64)
Diffstat (limited to 'mono')
-rw-r--r--mono/DBusType/Byte.cs8
-rw-r--r--mono/DBusType/Int32.cs11
-rw-r--r--mono/DBusType/Int64.cs8
-rw-r--r--mono/DBusType/UInt32.cs8
-rw-r--r--mono/DBusType/UInt64.cs8
5 files changed, 41 insertions, 2 deletions
diff --git a/mono/DBusType/Byte.cs b/mono/DBusType/Byte.cs
index f117559..08aabf5 100644
--- a/mono/DBusType/Byte.cs
+++ b/mono/DBusType/Byte.cs
@@ -41,6 +41,10 @@ namespace DBus.DBusType
public static bool Suits(System.Type type)
{
+ if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Byte)) {
+ return true;
+ }
+
switch (type.ToString()) {
case "System.Byte":
case "System.Byte&":
@@ -75,6 +79,10 @@ namespace DBus.DBusType
public object Get(System.Type type)
{
+ if (type.IsEnum) {
+ return Enum.ToObject(type, this.val);
+ }
+
switch (type.ToString()) {
case "System.Byte":
case "System.Byte&":
diff --git a/mono/DBusType/Int32.cs b/mono/DBusType/Int32.cs
index 91ffd62..5decf6e 100644
--- a/mono/DBusType/Int32.cs
+++ b/mono/DBusType/Int32.cs
@@ -36,11 +36,14 @@ namespace DBus.DBusType
public static bool Suits(System.Type type)
{
+ if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Int32)) {
+ return true;
+ }
+
switch (type.ToString()) {
case "System.Int32":
case "System.Int32&":
- return true;
- }
+ return true; }
return false;
}
@@ -68,6 +71,10 @@ namespace DBus.DBusType
public object Get(System.Type type)
{
+ if (type.IsEnum) {
+ return Enum.ToObject(type, this.val);
+ }
+
switch (type.ToString()) {
case "System.Int32":
case "System.Int32&":
diff --git a/mono/DBusType/Int64.cs b/mono/DBusType/Int64.cs
index 89447d9..368fdf6 100644
--- a/mono/DBusType/Int64.cs
+++ b/mono/DBusType/Int64.cs
@@ -36,6 +36,10 @@ namespace DBus.DBusType
public static bool Suits(System.Type type)
{
+ if (type.IsEnum && type.UnderlyingSystemType == typeof(System.Int64)) {
+ return true;
+ }
+
switch (type.ToString()) {
case "System.Int64":
case "System.Int64&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
public object Get(System.Type type)
{
+ if (type.IsEnum) {
+ return Enum.ToObject(type, this.val);
+ }
+
switch (type.ToString()) {
case "System.Int64":
case "System.Int64&":
diff --git a/mono/DBusType/UInt32.cs b/mono/DBusType/UInt32.cs
index 3301544..b09bafb 100644
--- a/mono/DBusType/UInt32.cs
+++ b/mono/DBusType/UInt32.cs
@@ -36,6 +36,10 @@ namespace DBus.DBusType
public static bool Suits(System.Type type)
{
+ if (type.IsEnum && type.UnderlyingSystemType == typeof(System.UInt32)) {
+ return true;
+ }
+
switch (type.ToString()) {
case "System.UInt32":
case "System.UInt32&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
public object Get(System.Type type)
{
+ if (type.IsEnum) {
+ return Enum.ToObject(type, this.val);
+ }
+
switch (type.ToString())
{
case "System.UInt32":
diff --git a/mono/DBusType/UInt64.cs b/mono/DBusType/UInt64.cs
index 4d3b875..e1d4dba 100644
--- a/mono/DBusType/UInt64.cs
+++ b/mono/DBusType/UInt64.cs
@@ -36,6 +36,10 @@ namespace DBus.DBusType
public static bool Suits(System.Type type)
{
+ if (type.IsEnum && type.UnderlyingSystemType == typeof(System.UInt64)) {
+ return true;
+ }
+
switch (type.ToString()) {
case "System.UInt64":
case "System.UInt64&":
@@ -68,6 +72,10 @@ namespace DBus.DBusType
public object Get(System.Type type)
{
+ if (type.IsEnum) {
+ return Enum.ToObject(type, this.val);
+ }
+
switch (type.ToString())
{
case "System.UInt64":