Re: orbit-idl-2 generating declarations without definitions?
- From: Sam Couter <scouter bigpond net au>
- To: orbit-list <orbit-list gnome org>
- Subject: Re: orbit-idl-2 generating declarations without definitions?
- Date: Wed, 19 Jun 2002 00:33:20 +1000
Murray Cumming <murrayc@usa.net> wrote:
> Do you have a patch for this that I can reapply?
Try the attached patches. The first is the TypeCode method
implementations and the second is the tests for them.
--
Sam "Eddie" Couter | mailto:scouter@bigpond.net.au
Debian Developer | mailto:eddie@debian.org
| jabber:sam@jabber.topic.com.au
OpenPGP fingerprint: A46B 9BB5 3148 7BEA 1F05 5BD5 8530 03AE DE89 C75C
Index: src/orb/orb-core/corba-typecode.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/corba-typecode.c,v
retrieving revision 1.30.2.1
retrieving revision 1.30.2.2
diff -u -r1.30.2.1 -r1.30.2.2
--- src/orb/orb-core/corba-typecode.c 22 Feb 2002 10:16:29 -0000 1.30.2.1
+++ src/orb/orb-core/corba-typecode.c 28 Feb 2002 11:24:32 -0000 1.30.2.2
@@ -702,6 +702,185 @@
return typecode_equiv_internal (obj, tc, FALSE, ev);
}
+CORBA_TCKind CORBA_TypeCode_kind(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ return obj->kind;
+}
+
+static void bad_kind (CORBA_Environment *ev)
+{
+ CORBA_TypeCode_BadKind *err;
+ err = g_new (CORBA_TypeCode_BadKind, 1);
+ if (err == NULL) {
+ CORBA_exception_set_system (ev, ex_CORBA_NO_MEMORY,
+ CORBA_COMPLETED_NO);
+ } else {
+ err->dummy = 23;
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ "IDL:omg.org/CORBA/TypeCode/BadKind/1.0",
+ err);
+ }
+}
+
+CORBA_RepositoryId CORBA_TypeCode_id(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_objref || obj->kind == CORBA_tk_struct
+ || obj->kind == CORBA_tk_union || obj->kind == CORBA_tk_enum
+ || obj->kind == CORBA_tk_alias || obj->kind == CORBA_tk_except)) {
+ bad_kind (ev);
+ return NULL;
+ }
+ return (CORBA_RepositoryId)obj->repo_id;
+}
+
+CORBA_Identifier CORBA_TypeCode_name(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_objref || obj->kind == CORBA_tk_struct
+ || obj->kind == CORBA_tk_union || obj->kind == CORBA_tk_enum
+ || obj->kind == CORBA_tk_alias || obj->kind == CORBA_tk_except)) {
+ bad_kind (ev);
+ return NULL;
+ }
+
+ return (CORBA_Identifier)obj->name;
+}
+
+CORBA_unsigned_long CORBA_TypeCode_member_count(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_struct || obj->kind == CORBA_tk_union
+ || obj->kind == CORBA_tk_except || obj->kind == CORBA_tk_enum)) {
+ bad_kind (ev);
+ return 0;
+ }
+ return obj->sub_parts;
+}
+
+static void bounds_error (CORBA_Environment *ev)
+{
+ CORBA_TypeCode_Bounds *err;
+ err = g_new (CORBA_TypeCode_Bounds, 1);
+ if (err == NULL) {
+ CORBA_exception_set_system (ev, ex_CORBA_NO_MEMORY,
+ CORBA_COMPLETED_NO);
+ } else {
+ err->dummy = 23;
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ "IDL:omg.org/CORBA/TypeCode/Bounds/1.0",
+ err);
+ }
+}
+
+CORBA_Identifier CORBA_TypeCode_member_name(CORBA_TypeCode obj, CORBA_unsigned_long index, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_struct || obj->kind == CORBA_tk_union
+ || obj->kind == CORBA_tk_except || obj->kind == CORBA_tk_enum)) {
+ bad_kind (ev);
+ return NULL;
+ }
+ if (index > obj->sub_parts) {
+ bounds_error (ev);
+ return NULL;
+ }
+ return (CORBA_Identifier)obj->subnames[index];
+}
+
+CORBA_TypeCode CORBA_TypeCode_member_type(CORBA_TypeCode obj, CORBA_unsigned_long index, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_struct || obj->kind == CORBA_tk_union
+ || obj->kind == CORBA_tk_except)) {
+ bad_kind (ev);
+ return NULL;
+ }
+ if (index > obj->sub_parts) {
+ bounds_error (ev);
+ return NULL;
+ }
+ return obj->subtypes[index];
+}
+
+CORBA_any *CORBA_TypeCode_member_label(CORBA_TypeCode obj, CORBA_unsigned_long index, CORBA_Environment *ev)
+{
+ CORBA_any *retval = NULL;
+
+ if (obj->kind != CORBA_tk_union) {
+ bad_kind (ev);
+ return NULL;
+ }
+ if (index > obj->sub_parts) {
+ bounds_error (ev);
+ return NULL;
+ }
+ retval = CORBA_any__alloc();
+ if (retval == NULL) {
+ CORBA_exception_set_system (ev, ex_CORBA_NO_MEMORY,
+ CORBA_COMPLETED_NO);
+ } else {
+ retval->_type = ORBit_RootObject_duplicate(obj->discriminator);
+ retval->_value =
+ ORBit_copy_value(&obj->sublabels[index], retval->_type);
+ retval->_release = CORBA_TRUE;
+ }
+
+ return retval;
+}
+
+CORBA_TypeCode CORBA_TypeCode_discriminator_type(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (obj->kind != CORBA_tk_union) {
+ bad_kind (ev);
+ return NULL;
+ }
+ return obj->discriminator;
+}
+
+CORBA_long CORBA_TypeCode_default_index(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (obj->kind != CORBA_tk_union) {
+ bad_kind (ev);
+ return 0;
+ }
+ return obj->default_index;
+}
+
+CORBA_unsigned_long CORBA_TypeCode_length(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_string || obj->kind == CORBA_tk_wstring
+ || obj->kind == CORBA_tk_sequence || obj->kind == CORBA_tk_array)) {
+ bad_kind (ev);
+ return 0;
+ }
+ return obj->length;
+}
+
+CORBA_TypeCode CORBA_TypeCode_content_type(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (! (obj->kind == CORBA_tk_sequence || obj->kind == CORBA_tk_array
+ || obj->kind == CORBA_tk_alias)) {
+ bad_kind (ev);
+ return NULL;
+ }
+ g_assert (obj->sub_parts == 1);
+ return obj->subtypes[0];
+}
+
+CORBA_unsigned_short CORBA_TypeCode_fixed_digits(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (obj->kind != CORBA_tk_fixed) {
+ bad_kind (ev);
+ return 0;
+ }
+ return obj->digits;
+}
+
+CORBA_short CORBA_TypeCode_fixed_scale(CORBA_TypeCode obj, CORBA_Environment *ev)
+{
+ if (obj->kind != CORBA_tk_fixed) {
+ bad_kind (ev);
+ return 0;
+ }
+ return obj->scale;
+}
+
const char *
ORBit_tk_to_name (CORBA_unsigned_long tk)
{
Index: test/everything/client.c
===================================================================
RCS file: /cvs/gnome/ORBit2/test/everything/client.c,v
retrieving revision 1.58.2.1
retrieving revision 1.58.2.2
diff -u -r1.58.2.1 -r1.58.2.2
--- test/everything/client.c 22 Feb 2002 10:16:35 -0000 1.58.2.1
+++ test/everything/client.c 28 Feb 2002 11:24:33 -0000 1.58.2.2
@@ -1139,7 +1139,11 @@
CORBA_Environment *ev)
{
test_AnyServer objref;
- CORBA_TypeCode inArg, inoutArg, outArg, retn;
+ CORBA_TypeCode inArg, inoutArg, outArg, retn, tc;
+ char *str;
+ CORBA_any *any;
+ CORBA_long l;
+ CORBA_unsigned_long ul;
d_print ("Testing TypeCodes...\n");
objref = test_TestFactory_getAnyServer (factory, ev);
@@ -1155,6 +1159,159 @@
g_assert (CORBA_TypeCode_equal (inoutArg, TC_test_TestException, ev));
g_assert (CORBA_TypeCode_equal (outArg, TC_test_AnEnum, ev));
g_assert (CORBA_TypeCode_equal (retn, TC_test_VariableLengthStruct, ev));
+
+ g_assert (CORBA_TypeCode_kind(inArg, ev) == CORBA_tk_union);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_kind(inoutArg, ev) == CORBA_tk_except);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_kind(outArg, ev) == CORBA_tk_enum);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_kind(retn, ev) == CORBA_tk_struct);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+ str = CORBA_TypeCode_id(inArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "IDL:orbit/test/ArrayUnion:1.0") == 0);
+ str = CORBA_TypeCode_id(inoutArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "IDL:orbit/test/TestException:1.0") == 0);
+ str = CORBA_TypeCode_id(outArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "IDL:orbit/test/AnEnum:1.0") == 0);
+ str = CORBA_TypeCode_id(retn, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "IDL:orbit/test/VariableLengthStruct:1.0") == 0);
+
+ str = CORBA_TypeCode_name(inArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ArrayUnion") == 0);
+ str = CORBA_TypeCode_name(inoutArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "TestException") == 0);
+ str = CORBA_TypeCode_name(outArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "AnEnum") == 0);
+ str = CORBA_TypeCode_name(retn, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "VariableLengthStruct") == 0);
+
+ g_assert (CORBA_TypeCode_member_count(inArg, ev) == 1);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_member_count(inoutArg, ev) == 4);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_member_count(outArg, ev) == 5);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_member_count(retn, ev) == 1);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+ str = CORBA_TypeCode_member_name(inArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "d") == 0);
+ str = CORBA_TypeCode_member_name(inoutArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "reason") == 0);
+ str = CORBA_TypeCode_member_name(inoutArg, 1, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "number") == 0);
+ str = CORBA_TypeCode_member_name(inoutArg, 2, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "aseq") == 0);
+ str = CORBA_TypeCode_member_name(inoutArg, 3, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "factory") == 0);
+ str = CORBA_TypeCode_member_name(outArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ENUM_IN") == 0);
+ str = CORBA_TypeCode_member_name(outArg, 1, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ENUM_INOUT_IN") == 0);
+ str = CORBA_TypeCode_member_name(outArg, 2, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ENUM_INOUT_OUT") == 0);
+ str = CORBA_TypeCode_member_name(outArg, 3, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ENUM_OUT") == 0);
+ str = CORBA_TypeCode_member_name(outArg, 4, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "ENUM_RETN") == 0);
+ str = CORBA_TypeCode_member_name(retn, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (strcmp(str, "a") == 0);
+
+ tc = CORBA_TypeCode_member_type(inArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_test_StrArray2, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_member_type(inoutArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_string, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_member_type(inoutArg, 1, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_long, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_member_type(inoutArg, 2, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_test_LongSeq, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_member_type(inoutArg, 3, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_test_TestFactory, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_member_type(retn, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_string, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+ any = CORBA_TypeCode_member_label(inArg, 0, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(any->_type, TC_CORBA_unsigned_short, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (*(CORBA_unsigned_short*)any->_value == 22);
+
+ tc = CORBA_TypeCode_discriminator_type(inArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_unsigned_short, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+ l = CORBA_TypeCode_default_index(inArg, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (l == -1);
+
+ /* The next two tests are out of order because the length() test relies
+ * on content_type(). So I should test content_type() first.
+ */
+ tc = CORBA_TypeCode_content_type(TC_test_StrSeq, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_sequence_CORBA_string, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ tc = CORBA_TypeCode_content_type(tc, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (CORBA_TypeCode_equal(tc, TC_CORBA_string, ev));
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+
+ /* I just happen to know that these two sequences are created as alias
+ * types. So I want the real type.
+ */
+ tc = CORBA_TypeCode_content_type(TC_test_StrSeq, ev);
+ ul = CORBA_TypeCode_length(tc, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (ul == 0);
+ tc = CORBA_TypeCode_content_type(TC_test_BoundedStructSeq, ev);
+ ul = CORBA_TypeCode_length(tc, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (ul == 2);
+
+#if 0
+ /* I don't have any fixed TypeCodes to test this on. */
+ us = CORBA_TypeCode_fixed_digits(xxx, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (us == xxx);
+
+ s = CORBA_TypeCode_fixed_scale(xxx, ev);
+ g_assert (ev->_major == CORBA_NO_EXCEPTION);
+ g_assert (s == xxx);
+#endif
CORBA_Object_release ((CORBA_Object)inArg, ev);
CORBA_Object_release ((CORBA_Object)inoutArg, ev);
PGP signature
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]