[RFC] Patch that makes CORBA_wchar a wchar_t



Hi,

The following patch will make a CORBA_wchar a wchar_t. I'll really like
some comments on this one...

Best regards,
  jules


diff -urpN ORBit2.orig/ChangeLog ORBit2/ChangeLog
--- ORBit2.orig/ChangeLog	2005-01-01 10:28:13.000000000 +0100
+++ ORBit2/ChangeLog	2005-01-07 13:21:12.656881789 +0100
@@ -1,3 +1,12 @@
+2005-01-07  Jules Colding  <colding omesc com>
+
+	* include/orbit/util/basic_types.h: Made CORBA_wchar a wchar_t type.
+
+	* src/orb/orb-core/corba-string.c (CORBA_string_dup): Fix handling of wide 
+	characters and wide strings.
+
+	* src/orb/orb-core/corba-any.c (ORBit_marshal_value): Fix handling of CORBA_wchar.
+
 2005-01-01  Jules Colding  <colding omesc com>
 
 	* src/idl-compiler/orbit-idl-c-skelimpl.c (cbe_ski_do_list): Fix the former 
diff -urpN ORBit2.orig/include/orbit/util/basic_types.h ORBit2/include/orbit/util/basic_types.h
--- ORBit2.orig/include/orbit/util/basic_types.h	2002-02-24 08:52:11.000000000 +0100
+++ ORBit2/include/orbit/util/basic_types.h	2005-01-07 13:08:38.066733356 +0100
@@ -2,7 +2,6 @@
 #define BASIC_TYPES_H 1
 
 #include <glib.h>
-#include <glib/gunicode.h>
 
 G_BEGIN_DECLS
 
@@ -18,7 +17,7 @@ typedef guint32   CORBA_unsigned_long;
 typedef gfloat    CORBA_float;
 typedef gdouble   CORBA_double;
 typedef char      CORBA_char;
-typedef gunichar2 CORBA_wchar;
+typedef wchar_t   CORBA_wchar;
 typedef guchar    CORBA_boolean;
 typedef guchar    CORBA_octet;
 typedef gdouble   CORBA_long_double;
diff -urpN ORBit2.orig/src/orb/orb-core/corba-any.c ORBit2/src/orb/orb-core/corba-any.c
--- ORBit2.orig/src/orb/orb-core/corba-any.c	2004-12-17 13:39:42.000000000 +0100
+++ ORBit2/src/orb/orb-core/corba-any.c	2005-01-07 13:15:06.513495211 +0100
@@ -110,6 +110,10 @@ ORBit_marshal_value (GIOPSendBuffer *buf
 
 	switch (tc->kind) {
 	case CORBA_tk_wchar:
+		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_WCHAR);
+		giop_send_buffer_append_aligned (buf, *val, sizeof (CORBA_wchar));
+		*val = ((guchar *)*val) + sizeof (CORBA_wchar);
+		break;
 	case CORBA_tk_ushort:
 	case CORBA_tk_short:
 		*val = ALIGN_ADDRESS (*val, ORBIT_ALIGNOF_CORBA_SHORT);
diff -urpN ORBit2.orig/src/orb/orb-core/corba-string.c ORBit2/src/orb/orb-core/corba-string.c
--- ORBit2.orig/src/orb/orb-core/corba-string.c	2001-11-20 11:25:11.000000000 +0100
+++ ORBit2/src/orb/orb-core/corba-string.c	2005-01-07 13:05:20.474762798 +0100
@@ -1,5 +1,6 @@
 #include "config.h"
 #include <string.h>
+#include <wchar.h>
 #include <orbit/orbit.h>
 
 CORBA_char *
@@ -28,16 +29,11 @@ CORBA_string_dup (const CORBA_char *str)
 CORBA_wchar *
 CORBA_wstring_alloc (CORBA_unsigned_long len)
 {
-	return ORBit_alloc_simple ((len + 1) * 2);
+	return ORBit_alloc_simple ((len + 1) * sizeof(CORBA_wchar));
 }
 
 CORBA_unsigned_long
 CORBA_wstring_len (CORBA_wchar *ws)
 {
-	int i;
-
-	for (i = 0; ws [i]; i++)
-		; /**/
-
-	return i;
+	return wcslen (ws);
 }




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