avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcrea...@apache.org
Subject svn commit: r1146935 - in /avro/trunk: ./ lang/c/docs/ lang/c/src/ lang/c/src/avro/ lang/c/tests/
Date Fri, 15 Jul 2011 00:54:03 GMT
Author: dcreager
Date: Fri Jul 15 00:54:01 2011
New Revision: 1146935

URL: http://svn.apache.org/viewvc?rev=1146935&view=rev
Log:
AVRO-861. C: Remove dependency on stdbool.h

Buildbot raised on error on Solaris, saying that the stdbool.h header is
only allowed in C99 code.  Bruce pointed out that it would be safer and
more portable to not rely on any C99 standards if we don't have to.  In
this case, it's easy enough to replace bool with int, true with 1, and
false with 0.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/docs/index.txt
    avro/trunk/lang/c/src/avro/data.h
    avro/trunk/lang/c/src/avro/generic.h
    avro/trunk/lang/c/src/avro/value.h
    avro/trunk/lang/c/src/datum_value.c
    avro/trunk/lang/c/src/generic-enum.c
    avro/trunk/lang/c/src/generic-map.c
    avro/trunk/lang/c/src/generic-primitives.c
    avro/trunk/lang/c/src/generic.c
    avro/trunk/lang/c/src/value-read.c
    avro/trunk/lang/c/src/value-sizeof.c
    avro/trunk/lang/c/src/value-write.c
    avro/trunk/lang/c/src/value.c
    avro/trunk/lang/c/tests/test_avro_values.c

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Jul 15 00:54:01 2011
@@ -29,6 +29,8 @@ Avro 1.6.0 (unreleased)
     AVRO-837. C: New Avro value interface. (dcreager)
     Documented in lang/c/docs/index.html.
 
+    AVRO-861. C: Remove dependency on stdbool.h. (dcreager)
+
   BUG FIXES
 
     AVRO-845. setup.py uses Python2.7+ specific code

Modified: avro/trunk/lang/c/docs/index.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/docs/index.txt?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/docs/index.txt (original)
+++ avro/trunk/lang/c/docs/index.txt Fri Jul 15 00:54:01 2011
@@ -128,14 +128,13 @@ regardless of which Avro schema it's an 
 
 [source,c]
 ----
-#include <stdbool.h>
 #include <avro.h>
 
 avro_type_t avro_value_get_type(const avro_value_t *value);
 avro_schema_t avro_value_get_schema(const avro_value_t *value);
 
-bool avro_value_equal(const avro_value_t *v1, const avro_value_t *v2);
-bool avro_value_equal_fast(const avro_value_t *v1, const avro_value_t *v2);
+int avro_value_equal(const avro_value_t *v1, const avro_value_t *v2);
+int avro_value_equal_fast(const avro_value_t *v1, const avro_value_t *v2);
 
 int avro_value_copy(avro_value_t *dest, const avro_value_t *src);
 int avro_value_copy_fast(avro_value_t *dest, const avro_value_t *src);
@@ -184,12 +183,11 @@ _getter_ methods:
 
 [source,c]
 ----
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <avro.h>
 
-int avro_value_get_boolean(const avro_value_t *value, bool *dest);
+int avro_value_get_boolean(const avro_value_t *value, int *dest);
 int avro_value_get_bytes(const avro_value_t *value,
                          const void **dest, size_t *size);
 int avro_value_get_double(const avro_value_t *value, double *dest);
@@ -228,12 +226,11 @@ methods:
 
 [source,c]
 ----
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <avro.h>
 
-int avro_value_set_boolean(avro_value_t *value, bool src);
+int avro_value_set_boolean(avro_value_t *value, int src);
 int avro_value_set_bytes(avro_value_t *value,
                          void *buf, size_t size);
 int avro_value_set_double(avro_value_t *value, double src);
@@ -265,7 +262,6 @@ If you don't want to copy the contents o
 
 [source,c]
 ----
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <avro.h>
@@ -402,7 +398,7 @@ int avro_value_get_by_index(const avro_v
                             avro_value_t *element, const char **key);
 int avro_value_add(avro_value_t *map,
                    const char *key, avro_value_t *element,
-                   size_t *index, bool *is_new);
+                   size_t *index, int *is_new);
 ----
 
 The +get_size+ method returns the number of elements currently in the

Modified: avro/trunk/lang/c/src/avro/data.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/data.h?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/data.h (original)
+++ avro/trunk/lang/c/src/avro/data.h Fri Jul 15 00:54:01 2011
@@ -24,7 +24,6 @@ extern "C" {
 #define CLOSE_EXTERN
 #endif
 
-#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 

Modified: avro/trunk/lang/c/src/avro/generic.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/generic.h?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/generic.h (original)
+++ avro/trunk/lang/c/src/avro/generic.h Fri Jul 15 00:54:01 2011
@@ -24,7 +24,6 @@ extern "C" {
 #define CLOSE_EXTERN
 #endif
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 
@@ -66,7 +65,7 @@ avro_value_iface_t *avro_generic_fixed_c
  * These functions instantiate a new generic scalar value.
  */
 
-int avro_generic_boolean_new(avro_value_t *value, bool val);
+int avro_generic_boolean_new(avro_value_t *value, int val);
 int avro_generic_bytes_new(avro_value_t *value, void *buf, size_t size);
 int avro_generic_double_new(avro_value_t *value, double val);
 int avro_generic_float_new(avro_value_t *value, float val);
@@ -75,6 +74,7 @@ int avro_generic_long_new(avro_value_t *
 int avro_generic_null_new(avro_value_t *value);
 int avro_generic_string_new(avro_value_t *value, char *val);
 int avro_generic_string_new_length(avro_value_t *value, char *val, size_t size);
+int avro_generic_enum_new(avro_value_t *value, int val);
 
 
 /*

Modified: avro/trunk/lang/c/src/avro/value.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/value.h?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/value.h (original)
+++ avro/trunk/lang/c/src/avro/value.h Fri Jul 15 00:54:01 2011
@@ -25,7 +25,6 @@ extern "C" {
 #endif
 
 #include <errno.h>
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 
@@ -117,7 +116,7 @@ struct avro_value_iface {
 	 * Primitive value getters
 	 */
 	int (*get_boolean)(const avro_value_iface_t *iface,
-			   const void *self, bool *out);
+			   const void *self, int *out);
 	int (*get_bytes)(const avro_value_iface_t *iface,
 			 const void *self, const void **buf, size_t *size);
 	int (*grab_bytes)(const avro_value_iface_t *iface,
@@ -170,7 +169,7 @@ struct avro_value_iface {
 	 */
 
 	int (*set_boolean)(const avro_value_iface_t *iface,
-			   void *self, bool val);
+			   void *self, int val);
 	int (*set_bytes)(const avro_value_iface_t *iface,
 			 void *self, void *buf, size_t size);
 	int (*give_bytes)(const avro_value_iface_t *iface,
@@ -256,7 +255,7 @@ struct avro_value_iface {
 	/* Creates a new map element, or returns an existing one. */
 	int (*add)(const avro_value_iface_t *iface,
 		   void *self, const char *key,
-		   avro_value_t *child, size_t *index, bool *is_new);
+		   avro_value_t *child, size_t *index, int *is_new);
 
 	/* Select a union branch. */
 	int (*set_branch)(const avro_value_iface_t *iface,
@@ -287,7 +286,7 @@ avro_value_free(avro_value_t *val);
  * avro_value_equal_fast.
  */
 
-bool
+int
 avro_value_equal(avro_value_t *val1, avro_value_t *val2);
 
 /**
@@ -299,7 +298,7 @@ avro_value_equal(avro_value_t *val1, avr
  * values.
  */
 
-bool
+int
 avro_value_equal_fast(avro_value_t *val1, avro_value_t *val2);
 
 /**

Modified: avro/trunk/lang/c/src/datum_value.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_value.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_value.c (original)
+++ avro/trunk/lang/c/src/datum_value.c Fri Jul 15 00:54:01 2011
@@ -15,7 +15,6 @@
  * permissions and limitations under the License.
  */
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -67,7 +66,7 @@ avro_datum_value_get_schema(const avro_v
 
 static int
 avro_datum_value_get_boolean(const avro_value_iface_t *iface,
-			     const void *vself, bool *out)
+			     const void *vself, int *out)
 {
 	AVRO_UNUSED(iface);
 	const avro_datum_t  self = (const avro_datum_t) vself;
@@ -279,7 +278,7 @@ avro_datum_value_grab_fixed(const avro_v
 
 static int
 avro_datum_value_set_boolean(const avro_value_iface_t *iface,
-			     void *vself, bool val)
+			     void *vself, int val)
 {
 	AVRO_UNUSED(iface);
 	avro_datum_t  self = vself;
@@ -614,7 +613,7 @@ avro_datum_value_append(const avro_value
 static int
 avro_datum_value_add(const avro_value_iface_t *iface,
 		     void *vself, const char *key,
-		     avro_value_t *child, size_t *index, bool *is_new)
+		     avro_value_t *child, size_t *index, int *is_new)
 {
 	AVRO_UNUSED(iface);
 	avro_datum_t  self = vself;
@@ -631,7 +630,7 @@ avro_datum_value_add(const avro_value_if
 	if (avro_map_get(self, key, &child_datum) == 0) {
 		/* key already exists */
 		if (is_new != NULL) {
-			*is_new = false;
+			*is_new = 0;
 		}
 		if (index != NULL) {
 			int  real_index;
@@ -652,7 +651,7 @@ avro_datum_value_add(const avro_value_if
 
 	check(rval, avro_map_set(self, key, child_datum));
 	if (is_new != NULL) {
-		*is_new = true;
+		*is_new = 0;
 	}
 	if (index != NULL) {
 		*index = avro_map_size(self) - 1;

Modified: avro/trunk/lang/c/src/generic-enum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/generic-enum.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/generic-enum.c (original)
+++ avro/trunk/lang/c/src/generic-enum.c Fri Jul 15 00:54:01 2011
@@ -202,7 +202,7 @@ avro_value_iface_t *avro_generic_enum_cl
 	return &iface->iface;
 }
 
-int avro_generic_enum_new(avro_value_t *value, bool val)
+int avro_generic_enum_new(avro_value_t *value, int val)
 {
 	int  rval;
 	check(rval, avro_value_new(&AVRO_GENERIC_ENUM_CLASS, value));

Modified: avro/trunk/lang/c/src/generic-map.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/generic-map.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/generic-map.c (original)
+++ avro/trunk/lang/c/src/generic-map.c Fri Jul 15 00:54:01 2011
@@ -185,7 +185,7 @@ avro_generic_map_get_by_name(const avro_
 static int
 avro_generic_map_add(const avro_value_iface_t *viface,
 		     void *vself, const char *key,
-		     avro_value_t *child, size_t *index, bool *is_new)
+		     avro_value_t *child, size_t *index, int *is_new)
 {
 	const avro_generic_map_value_iface_t  *iface =
 	    (const avro_generic_map_value_iface_t *) viface;

Modified: avro/trunk/lang/c/src/generic-primitives.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/generic-primitives.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/generic-primitives.c (original)
+++ avro/trunk/lang/c/src/generic-primitives.c Fri Jul 15 00:54:01 2011
@@ -16,7 +16,6 @@
  */
 
 #include <errno.h>
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 
@@ -82,7 +81,7 @@ avro_generic_boolean_get_schema(const av
 
 static int
 avro_generic_boolean_get(const avro_value_iface_t *iface,
-			 const void *vself, bool *out)
+			 const void *vself, int *out)
 {
 	AVRO_UNUSED(iface);
 	const int  *self = vself;
@@ -92,7 +91,7 @@ avro_generic_boolean_get(const avro_valu
 
 static int
 avro_generic_boolean_set(const avro_value_iface_t *iface,
-			 void *vself, bool val)
+			 void *vself, int val)
 {
 	AVRO_UNUSED(iface);
 	int  *self = vself;
@@ -158,7 +157,7 @@ avro_value_iface_t *avro_generic_boolean
 	return &AVRO_GENERIC_BOOLEAN_CLASS;
 }
 
-int avro_generic_boolean_new(avro_value_t *value, bool val)
+int avro_generic_boolean_new(avro_value_t *value, int val)
 {
 	int  rval;
 	check(rval, avro_value_new(&AVRO_GENERIC_BOOLEAN_CLASS, value));

Modified: avro/trunk/lang/c/src/generic.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/generic.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/generic.c (original)
+++ avro/trunk/lang/c/src/generic.c Fri Jul 15 00:54:01 2011
@@ -15,7 +15,6 @@
  * permissions and limitations under the License.
  */
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -138,7 +137,7 @@ avro_generic_link_get_schema(const avro_
 
 static int
 avro_generic_link_get_boolean(const avro_value_iface_t *iface,
-			      const void *vself, bool *out)
+			      const void *vself, int *out)
 {
 	AVRO_UNUSED(iface);
 	const avro_value_t  *self = vself;
@@ -254,7 +253,7 @@ avro_generic_link_grab_fixed(const avro_
 
 static int
 avro_generic_link_set_boolean(const avro_value_iface_t *iface,
-			      void *vself, bool val)
+			      void *vself, int val)
 {
 	AVRO_UNUSED(iface);
 	avro_value_t  *self = vself;
@@ -437,7 +436,7 @@ avro_generic_link_append(const avro_valu
 static int
 avro_generic_link_add(const avro_value_iface_t *iface,
 		      void *vself, const char *key,
-		      avro_value_t *child, size_t *index, bool *is_new)
+		      avro_value_t *child, size_t *index, int *is_new)
 {
 	AVRO_UNUSED(iface);
 	avro_value_t  *self = vself;

Modified: avro/trunk/lang/c/src/value-read.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/value-read.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/value-read.c (original)
+++ avro/trunk/lang/c/src/value-read.c Fri Jul 15 00:54:01 2011
@@ -15,7 +15,6 @@
  * permissions and limitations under the License.
  */
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>

Modified: avro/trunk/lang/c/src/value-sizeof.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/value-sizeof.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/value-sizeof.c (original)
+++ avro/trunk/lang/c/src/value-sizeof.c Fri Jul 15 00:54:01 2011
@@ -15,7 +15,6 @@
  * permissions and limitations under the License.
  */
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 
@@ -121,7 +120,7 @@ sizeof_value(avro_value_t *src, size_t *
 	switch (avro_value_get_type(src)) {
 		case AVRO_BOOLEAN:
 		{
-			bool  val;
+			int  val;
 			check(rval, avro_value_get_boolean(src, &val));
 			*size += avro_binary_encoding.size_boolean(NULL, val);
 			return 0;

Modified: avro/trunk/lang/c/src/value-write.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/value-write.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/value-write.c (original)
+++ avro/trunk/lang/c/src/value-write.c Fri Jul 15 00:54:01 2011
@@ -15,7 +15,6 @@
  * permissions and limitations under the License.
  */
 
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 
@@ -117,7 +116,7 @@ avro_value_write(avro_writer_t writer, a
 	switch (avro_value_get_type(src)) {
 		case AVRO_BOOLEAN:
 		{
-			bool  val;
+			int  val;
 			check(rval, avro_value_get_boolean(src, &val));
 			return avro_binary_encoding.write_boolean(writer, val);
 		}

Modified: avro/trunk/lang/c/src/value.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/value.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/src/value.c (original)
+++ avro/trunk/lang/c/src/value.c Fri Jul 15 00:54:01 2011
@@ -70,22 +70,22 @@ avro_value_free(avro_value_t *val)
 		if (rval != 0) { return (retval); } \
 	} while (0)
 
-bool
+int
 avro_value_equal_fast(avro_value_t *val1, avro_value_t *val2)
 {
 	avro_type_t  type1 = avro_value_get_type(val1);
 	avro_type_t  type2 = avro_value_get_type(val2);
 	if (type1 != type2) {
-		return false;
+		return 0;
 	}
 
 	switch (type1) {
 		case AVRO_BOOLEAN:
 		{
-			bool  v1;
-			bool  v2;
-			check_return(false, avro_value_get_boolean(val1, &v1));
-			check_return(false, avro_value_get_boolean(val2, &v2));
+			int  v1;
+			int  v2;
+			check_return(0, avro_value_get_boolean(val1, &v1));
+			check_return(0, avro_value_get_boolean(val2, &v2));
 			return (v1 == v2);
 		}
 
@@ -95,10 +95,10 @@ avro_value_equal_fast(avro_value_t *val1
 			const void  *buf2;
 			size_t  size1;
 			size_t  size2;
-			check_return(false, avro_value_get_bytes(val1, &buf1, &size1));
-			check_return(false, avro_value_get_bytes(val2, &buf2, &size2));
+			check_return(0, avro_value_get_bytes(val1, &buf1, &size1));
+			check_return(0, avro_value_get_bytes(val2, &buf2, &size2));
 			if (size1 != size2) {
-				return false;
+				return 0;
 			}
 			return (memcmp(buf1, buf2, size1) == 0);
 		}
@@ -107,8 +107,8 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			double  v1;
 			double  v2;
-			check_return(false, avro_value_get_double(val1, &v1));
-			check_return(false, avro_value_get_double(val2, &v2));
+			check_return(0, avro_value_get_double(val1, &v1));
+			check_return(0, avro_value_get_double(val2, &v2));
 			return (v1 == v2);
 		}
 
@@ -116,8 +116,8 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			float  v1;
 			float  v2;
-			check_return(false, avro_value_get_float(val1, &v1));
-			check_return(false, avro_value_get_float(val2, &v2));
+			check_return(0, avro_value_get_float(val1, &v1));
+			check_return(0, avro_value_get_float(val2, &v2));
 			return (v1 == v2);
 		}
 
@@ -125,8 +125,8 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			int32_t  v1;
 			int32_t  v2;
-			check_return(false, avro_value_get_int(val1, &v1));
-			check_return(false, avro_value_get_int(val2, &v2));
+			check_return(0, avro_value_get_int(val1, &v1));
+			check_return(0, avro_value_get_int(val2, &v2));
 			return (v1 == v2);
 		}
 
@@ -134,16 +134,16 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			int64_t  v1;
 			int64_t  v2;
-			check_return(false, avro_value_get_long(val1, &v1));
-			check_return(false, avro_value_get_long(val2, &v2));
+			check_return(0, avro_value_get_long(val1, &v1));
+			check_return(0, avro_value_get_long(val2, &v2));
 			return (v1 == v2);
 		}
 
 		case AVRO_NULL:
 		{
-			check_return(false, avro_value_get_null(val1));
-			check_return(false, avro_value_get_null(val2));
-			return true;
+			check_return(0, avro_value_get_null(val1));
+			check_return(0, avro_value_get_null(val2));
+			return 1;
 		}
 
 		case AVRO_STRING:
@@ -152,10 +152,10 @@ avro_value_equal_fast(avro_value_t *val1
 			const char  *buf2;
 			size_t  size1;
 			size_t  size2;
-			check_return(false, avro_value_get_string(val1, &buf1, &size1));
-			check_return(false, avro_value_get_string(val2, &buf2, &size2));
+			check_return(0, avro_value_get_string(val1, &buf1, &size1));
+			check_return(0, avro_value_get_string(val2, &buf2, &size2));
 			if (size1 != size2) {
-				return false;
+				return 0;
 			}
 			return (memcmp(buf1, buf2, size1) == 0);
 		}
@@ -164,34 +164,34 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			size_t  count1;
 			size_t  count2;
-			check_return(false, avro_value_get_size(val1, &count1));
-			check_return(false, avro_value_get_size(val2, &count2));
+			check_return(0, avro_value_get_size(val1, &count1));
+			check_return(0, avro_value_get_size(val2, &count2));
 			if (count1 != count2) {
-				return false;
+				return 0;
 			}
 
 			size_t  i;
 			for (i = 0; i < count1; i++) {
 				avro_value_t  child1;
 				avro_value_t  child2;
-				check_return(false, avro_value_get_by_index
+				check_return(0, avro_value_get_by_index
 					     (val1, i, &child1, NULL));
-				check_return(false, avro_value_get_by_index
+				check_return(0, avro_value_get_by_index
 					     (val2, i, &child2, NULL));
 				if (!avro_value_equal_fast(&child1, &child2)) {
-					return false;
+					return 0;
 				}
 			}
 
-			return true;
+			return 1;
 		}
 
 		case AVRO_ENUM:
 		{
 			int  v1;
 			int  v2;
-			check_return(false, avro_value_get_enum(val1, &v1));
-			check_return(false, avro_value_get_enum(val2, &v2));
+			check_return(0, avro_value_get_enum(val1, &v1));
+			check_return(0, avro_value_get_enum(val2, &v2));
 			return (v1 == v2);
 		}
 
@@ -201,10 +201,10 @@ avro_value_equal_fast(avro_value_t *val1
 			const void  *buf2;
 			size_t  size1;
 			size_t  size2;
-			check_return(false, avro_value_get_fixed(val1, &buf1, &size1));
-			check_return(false, avro_value_get_fixed(val2, &buf2, &size2));
+			check_return(0, avro_value_get_fixed(val1, &buf1, &size1));
+			check_return(0, avro_value_get_fixed(val2, &buf2, &size2));
 			if (size1 != size2) {
-				return false;
+				return 0;
 			}
 			return (memcmp(buf1, buf2, size1) == 0);
 		}
@@ -213,10 +213,10 @@ avro_value_equal_fast(avro_value_t *val1
 		{
 			size_t  count1;
 			size_t  count2;
-			check_return(false, avro_value_get_size(val1, &count1));
-			check_return(false, avro_value_get_size(val2, &count2));
+			check_return(0, avro_value_get_size(val1, &count1));
+			check_return(0, avro_value_get_size(val2, &count2));
 			if (count1 != count2) {
-				return false;
+				return 0;
 			}
 
 			size_t  i;
@@ -224,68 +224,68 @@ avro_value_equal_fast(avro_value_t *val1
 				avro_value_t  child1;
 				avro_value_t  child2;
 				const char  *key1;
-				check_return(false, avro_value_get_by_index
+				check_return(0, avro_value_get_by_index
 					     (val1, i, &child1, &key1));
-				check_return(false, avro_value_get_by_name
+				check_return(0, avro_value_get_by_name
 					     (val2, key1, &child2, NULL));
 				if (!avro_value_equal_fast(&child1, &child2)) {
-					return false;
+					return 0;
 				}
 			}
 
-			return true;
+			return 1;
 		}
 
 		case AVRO_RECORD:
 		{
 			size_t  count1;
-			check_return(false, avro_value_get_size(val1, &count1));
+			check_return(0, avro_value_get_size(val1, &count1));
 
 			size_t  i;
 			for (i = 0; i < count1; i++) {
 				avro_value_t  child1;
 				avro_value_t  child2;
-				check_return(false, avro_value_get_by_index
+				check_return(0, avro_value_get_by_index
 					     (val1, i, &child1, NULL));
-				check_return(false, avro_value_get_by_index
+				check_return(0, avro_value_get_by_index
 					     (val2, i, &child2, NULL));
 				if (!avro_value_equal_fast(&child1, &child2)) {
-					return false;
+					return 0;
 				}
 			}
 
-			return true;
+			return 1;
 		}
 
 		case AVRO_UNION:
 		{
 			int  disc1;
 			int  disc2;
-			check_return(false, avro_value_get_discriminant(val1, &disc1));
-			check_return(false, avro_value_get_discriminant(val2, &disc2));
+			check_return(0, avro_value_get_discriminant(val1, &disc1));
+			check_return(0, avro_value_get_discriminant(val2, &disc2));
 			if (disc1 != disc2) {
-				return false;
+				return 0;
 			}
 
 			avro_value_t  branch1;
 			avro_value_t  branch2;
-			check_return(false, avro_value_get_current_branch(val1, &branch1));
-			check_return(false, avro_value_get_current_branch(val2, &branch2));
+			check_return(0, avro_value_get_current_branch(val1, &branch1));
+			check_return(0, avro_value_get_current_branch(val2, &branch2));
 			return avro_value_equal_fast(&branch1, &branch2);
 		}
 
 		default:
-			return false;
+			return 0;
 	}
 }
 
-bool
+int
 avro_value_equal(avro_value_t *val1, avro_value_t *val2)
 {
 	avro_schema_t  schema1 = avro_value_get_schema(val1);
 	avro_schema_t  schema2 = avro_value_get_schema(val2);
 	if (!avro_schema_equal(schema1, schema2)) {
-		return false;
+		return 0;
 	}
 
 	return avro_value_equal_fast(val1, val2);
@@ -298,7 +298,7 @@ avro_value_copy_fast(avro_value_t *dest,
 	avro_type_t  dest_type = avro_value_get_type(dest);
 	avro_type_t  src_type = avro_value_get_type(src);
 	if (dest_type != src_type) {
-		return false;
+		return 0;
 	}
 
 	int  rval;
@@ -307,7 +307,7 @@ avro_value_copy_fast(avro_value_t *dest,
 	switch (dest_type) {
 		case AVRO_BOOLEAN:
 		{
-			bool  val;
+			int  val;
 			check(rval, avro_value_get_boolean(src, &val));
 			return avro_value_set_boolean(dest, val);
 		}

Modified: avro/trunk/lang/c/tests/test_avro_values.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_avro_values.c?rev=1146935&r1=1146934&r2=1146935&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/test_avro_values.c (original)
+++ avro/trunk/lang/c/tests/test_avro_values.c Fri Jul 15 00:54:01 2011
@@ -140,7 +140,7 @@ _check_invalid_methods(const char *name,
 	} while (0)
 
 	if (type != AVRO_BOOLEAN) {
-		bool  dummy = 0;
+		int  dummy = 0;
 		check_bad(get_boolean, val, &dummy);
 		check_bad(set_boolean, val, dummy);
 	}
@@ -232,7 +232,7 @@ _check_invalid_methods(const char *name,
 		const char  *key = NULL;
 		avro_value_t  child;
 		size_t  index = 0;
-		bool  is_new = false;
+		int  is_new = 0;
 		check_bad(add, val, key, &child, &index, &is_new);
 	}
 
@@ -391,7 +391,7 @@ test_boolean(void)
 
 		/* Start with the wrong value to make sure _get does
 		 * something. */
-		bool  actual = (bool) 23;
+		int  actual = (int) 23;
 		try(avro_value_get_boolean(&val, &actual),
 		    "Cannot get boolean value");
 
@@ -988,7 +988,7 @@ test_map(void)
 		for (j = 0; j < count; j++) {
 			avro_value_t  element;
 			size_t  new_index;
-			bool  is_new = false;
+			int  is_new = 0;
 
 			char  key[64];
 			snprintf(key, 64, "%zu", j);
@@ -1137,7 +1137,7 @@ test_record(void)
 
 	try(avro_value_get_by_index(&val, 0, &field, NULL),
 	    "Cannot get field 0");
-	try(avro_value_set_boolean(&field, true),
+	try(avro_value_set_boolean(&field, 1),
 	    "Cannot set field 0");
 
 	try(avro_value_get_by_index(&val, 1, &field, &name),
@@ -1193,7 +1193,7 @@ test_record(void)
 	try(avro_value_reset(&val),
 	    "Cannot reset record");
 
-	bool  bval;
+	int  bval;
 	try(avro_value_get_by_index(&val, 0, &field, NULL),
 	    "Cannot get field 0");
 	try(avro_value_get_boolean(&field, &bval),



Mime
View raw message