File: test-ird.c

package info (click to toggle)
orbit 0.5.0-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,604 kB
  • ctags: 4,626
  • sloc: ansic: 37,930; sh: 7,508; yacc: 1,750; makefile: 877; lex: 366
file content (110 lines) | stat: -rw-r--r-- 3,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <stdio.h>
#include <orb/orbit.h>

int main(int argc, char *argv[])
{
	CORBA_Environment ev;
	CORBA_ORB orb;
	CORBA_Repository ir;
	CORBA_PrimitiveDef prim_long;
	CORBA_ConstantDef constant;
	CORBA_StringDef str;
	CORBA_ContainedSeq *contained_seq;
	CORBA_Contained_Description *contained_desc;
	CORBA_ConstantDescription *constant_desc;
	CORBA_any any;
	CORBA_long fooval=1;
	int i;

	CORBA_exception_init(&ev);
	orb=CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

	ir=CORBA_ORB_resolve_initial_references(orb, "InterfaceRepository",
						&ev);
	if(CORBA_Object_is_nil(ir, &ev)) {
		g_print("No Interface Repo found.\n");
		exit(0);
	}

	any._type=(CORBA_TypeCode)TC_CORBA_long;
	any._value=&fooval;
	CORBA_any_set_release(&any, CORBA_FALSE);

	prim_long=CORBA_Repository_get_primitive(ir, CORBA_pk_long, &ev);
	
	constant=CORBA_Repository_create_constant(ir, "IDL:wibble:1.0", "wibble", "1.0", prim_long, &any, &ev);
	if(constant!=CORBA_OBJECT_NIL) {
		g_print("%s\n", CORBA_ConstantDef__get_id(constant, &ev));
		g_print("%s\n", CORBA_ConstantDef__get_absolute_name(constant, &ev));

#if 0
		contained_desc=CORBA_ConstantDef_describe(constant, &ev);
		if(contained_desc==NULL) {
			g_print("ConstantDef_describe returned NULL!\n");
		} else {
			constant_desc=contained_desc->value._value;
			
			g_print("Constant Description\n");
			g_print("--------------------\n");
			g_print("name: %s\n", constant_desc->name);
			g_print("id: %s\n", constant_desc->id);
			g_print("defined_in: %s\n", constant_desc->defined_in);
			g_print("version: %s\n", constant_desc->version);
		}
#endif
	}
	constant=CORBA_Repository_create_constant(ir, "IDL:wibble:1.1", "wibble", "1.1", prim_long, &any, &ev);
	constant=CORBA_Repository_create_constant(ir, "IDL:wobble:1.0", "wibble", "1.0", prim_long, &any, &ev);
	constant=CORBA_Repository_create_constant(ir, "IDL:wibble:1.0", "wobble", "1.0", prim_long, &any, &ev);

	str=CORBA_Repository_create_string(ir, 10, &ev);
	
	contained_seq=CORBA_Repository_contents(ir, CORBA_dk_all,
						CORBA_FALSE,
						&ev);
	
	g_print("%d items in repository\n", contained_seq->_length);

#ifdef THIS_SEEMS_TO_BE_BORKEN
	for(i=0;i<contained_seq->_length;i++) {
		g_print("%d\n", CORBA_Contained__get_def_kind(contained_seq->_buffer[i], &ev));
		
		switch(CORBA_Contained__get_def_kind(contained_seq->_buffer[i], &ev)) {
		case CORBA_dk_Constant:
			g_print("Item %d is constant called %s\n", i, CORBA_ConstantDef__get_id(contained_seq->_buffer[i], &ev));
			break;
		case CORBA_dk_String:
			g_print("Item %d is string of length %d\n", i, CORBA_StringDef__get_bound(contained_seq->_buffer[i], &ev));
			break;
		default:
			g_print("Item %d is of unknown type\n");
			break;
		}
	}
#endif
	
	contained_seq=CORBA_Repository_lookup_name(ir, "wibble", 1,
						   CORBA_dk_all,
						   CORBA_FALSE,
						   &ev);
	g_print("%d wibbles directly in repository\n", contained_seq->_length);
	
	contained_seq=CORBA_Repository_lookup_name(ir, "wibble", -1,
						   CORBA_dk_all,
						   CORBA_FALSE,
						   &ev);
	g_print("%d wibbles overall in repository\n", contained_seq->_length);

	CORBA_Repository_lookup(ir, "::wibble", &ev);
	CORBA_Repository_lookup(ir, "wibble", &ev);
	CORBA_Repository_lookup(ir, "::foo::bar::baz", &ev);
	
	CORBA_Repository_destroy(ir, &ev);
	
	CORBA_Object_release(constant, &ev);
	CORBA_Object_release(str, &ev);
	CORBA_Object_release(ir, &ev);
	CORBA_Object_release((CORBA_Object) orb, &ev);

	return 0;
}