[vala/dova: 2/2] Add support for decimal floating point types



commit 16a3400dc0e3abbb4567bf6aa42808b2c0f3e4f0
Author: Jürg Billeter <j bitron ch>
Date:   Sat Sep 5 17:38:51 2009 +0200

    Add support for decimal floating point types

 codegen/valadovastructmodule.vala |    6 +++++-
 vala/valastruct.vala              |   16 +++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valadovastructmodule.vala b/codegen/valadovastructmodule.vala
index 218634e..f52912a 100644
--- a/codegen/valadovastructmodule.vala
+++ b/codegen/valadovastructmodule.vala
@@ -42,8 +42,12 @@ internal class Vala.DovaStructModule : DovaBaseModule {
 			decl_space.add_include ("stdint.h");
 			st.set_cname ("%sint%d_t".printf (st.signed ? "" : "u", st.width));
 			return;
+		} else if (st.is_decimal_floating_type ()) {
+			// typedef for decimal floating types
+			st.set_cname ("_Decimal%d".printf (st.width));
+			return;
 		} else if (st.is_floating_type ()) {
-			// typedef for floating types
+			// typedef for generic floating types
 			st.set_cname (st.width == 64 ? "double" : "float");
 			return;
 		}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index b22893e..9ef933e 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -42,6 +42,7 @@ public class Vala.Struct : TypeSymbol {
 	private bool boolean_type;
 	private bool integer_type;
 	private bool floating_type;
+	private bool decimal_floating_type;
 	private int rank;
 	private string marshaller_type_name;
 	private string get_value_function;
@@ -385,7 +386,17 @@ public class Vala.Struct : TypeSymbol {
 		}
 		return floating_type;
 	}
-	
+
+	public bool is_decimal_floating_type () {
+		if (base_type != null) {
+			var st = base_struct;
+			if (st != null && st.is_decimal_floating_type ()) {
+				return true;
+			}
+		}
+		return decimal_floating_type;
+	}
+
 	/**
 	 * Returns the rank of this integer or floating point type.
 	 *
@@ -462,6 +473,9 @@ public class Vala.Struct : TypeSymbol {
 		if (a.has_argument ("rank")) {
 			rank = a.get_integer ("rank");
 		}
+		if (a.has_argument ("decimal")) {
+			decimal_floating_type = a.get_bool ("decimal");
+		}
 		if (a.has_argument ("width")) {
 			width = a.get_integer ("width");
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]