[seed] Add validation of enum types to the GArgument conversion logic



commit f3dc26292d3ed4b877d15c345b4edd6678d72ba1
Author: Robert Carr <racarr mireia (none)>
Date:   Tue Mar 24 23:09:16 2009 -0400

    Add validation of enum types to the GArgument conversion logic
---
 libseed/seed-types.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index da61852..2a8a8f0 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -553,6 +553,19 @@ seed_gi_make_argument (JSContextRef ctx,
 		 interface_type == GI_INFO_TYPE_FLAGS)
 	  {
 	    arg->v_long = seed_value_to_long (ctx, value, exception);
+	    if (!seed_validate_enum ((GIEnumInfo *)interface, arg->v_long))
+	      {
+		gchar *message = 
+		  g_strdup_printf ("Enum value: %ld is out of range", 
+				   arg->v_long);
+		
+		seed_make_exception (ctx, exception, "EnumRange",
+				     message);
+		g_base_info_unref (interface);
+		
+		return FALSE;
+	      }
+				     
 	    g_base_info_unref (interface);
 	    break;
 	  }



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