source: trunk/foundation/class_c/nomstring.c

Last change on this file was 283, checked in by cinc, 18 years ago

Fixed unitialized pointer crash. Use new IDL compiler.

File size: 6.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2006-2007
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34/*
35 * And remember, phase 3 is near...
36 */
37#ifndef NOM_NOMString_IMPLEMENTATION_FILE
38#define NOM_NOMString_IMPLEMENTATION_FILE
39#endif
40
41#define INCL_DOS
42#include <os2.h>
43
44#include <nom.h>
45#include <nomtk.h>
46
47#include <string.h>
48#include <glib.h>
49#include "nomfoundation.h"
50#include "nomstring.ih"
51
52
53NOM_Scope PNOMString NOMLINK impl_NOMString_assign(NOMString* nomSelf, const PNOMString nomString,
54 CORBA_Environment *ev)
55{
56 /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */
57
58 NOMString_assignCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
59 return nomSelf;
60}
61
62/* Assign a C string to this NOMString. An initially created NOMString object is empty. */
63NOM_Scope PNOMString NOMLINK impl_NOMString_assignCString(NOMString* nomSelf, const CORBA_char * chrString,
64 CORBA_Environment *ev)
65{
66 NOMStringData* nomThis=NOMStringGetData(nomSelf);
67
68 g_string_assign(_gString, chrString); /* This copies the input string */
69 return nomSelf;
70}
71
72/* Returns the C string held by this NOMString. */
73NOM_Scope CORBA_string NOMLINK impl_NOMString_queryCString(NOMString* nomSelf, CORBA_Environment *ev)
74{
75 NOMStringData* nomThis=NOMStringGetData(nomSelf);
76
77 return _gString->str;
78}
79
80/* Returns a copy of the C string held by this NOMString. */
81NOM_Scope CORBA_string NOMLINK impl_NOMString_copyCString(NOMString* nomSelf, CORBA_Environment *ev)
82{
83 NOMStringData* nomThis=NOMStringGetData(nomSelf);
84
85 return g_strdup(_gString->str);
86}
87
88NOM_Scope PNOMString NOMLINK impl_NOMString_appendCString(NOMString* nomSelf, const CORBA_char * chrString,
89 CORBA_Environment *ev)
90{
91 NOMStringData* nomThis=NOMStringGetData(nomSelf);
92
93 g_string_append(_gString, chrString);
94
95 return nomSelf;
96}
97
98NOM_Scope PNOMString NOMLINK impl_NOMString_append(NOMString* nomSelf, const PNOMString nomString,
99 CORBA_Environment *ev)
100{
101 return NOMString_appendCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
102}
103
104NOM_Scope PNOMString NOMLINK impl_NOMString_prepend(NOMString* nomSelf, const PNOMString nomString,
105 CORBA_Environment *ev)
106{
107 return NOMString_prependCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
108}
109
110NOM_Scope PNOMString NOMLINK impl_NOMString_prependCString(NOMString* nomSelf, const CORBA_char * chrString, CORBA_Environment *ev)
111{
112 NOMStringData* nomThis=NOMStringGetData(nomSelf);
113 g_string_prepend(_gString, chrString);
114
115 return nomSelf;
116}
117
118NOM_Scope CORBA_unsigned_long NOMLINK impl_NOMString_length(NOMString* nomSelf, CORBA_Environment *ev)
119{
120 NOMStringData* nomThis=NOMStringGetData(nomSelf);
121
122 //g_message("In %s %d %s", __FUNCTION__, _gString->len, _gString->str );
123
124 return _gString->len;
125}
126
127NOM_Scope PNOMString NOMLINK impl_NOMString_truncate(NOMString* nomSelf, const CORBA_unsigned_long ulNewLen,
128 CORBA_Environment *ev)
129{
130 NOMStringData* nomThis=NOMStringGetData(nomSelf);
131
132 g_string_truncate(_gString, ulNewLen);
133
134 return nomSelf;
135}
136
137NOM_Scope PNOMString NOMLINK impl_NOMString_copy(NOMString* nomSelf, CORBA_Environment *ev)
138{
139 /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */
140 PNOMString nomRetval;
141 NOMClass* nomCls;
142
143 /* We don't know which class we're actually. So we can't just create a new NOMString here.
144 It is possible that we are called by a subclass. So get the class object and let the
145 class object create the correct class. */
146 nomCls=NOMObject_nomGetClass((PNOMObject) nomSelf, NULLHANDLE);
147 nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE);
148
149 NOMString_assign(nomRetval, nomSelf, ev);
150
151 return nomRetval;
152}
153
154
155NOM_Scope void NOMLINK impl_NOMString_nomInit(NOMString* nomSelf, CORBA_Environment *ev)
156{
157 NOMStringData* nomThis=NOMStringGetData(nomSelf);
158
159 NOMString_nomInit_parent((NOMObject*)nomSelf, ev);
160
161 /* Alloc a zero length GString */
162 _gString=g_string_new("");
163}
164
165#if 0
166NOM_Scope void NOMLINK impl_NOMString_nomUnInit(NOMString* nomSelf, CORBA_Environment *ev)
167{
168 NOMStringData* nomThis=NOMStringGetData(nomSelf);
169
170 /* Free GString including the C string data */
171 g_string_free(_gString, TRUE);
172
173 NOMString_nomUnInit_parent((NOMObject*)nomSelf, ev);
174}
175#endif
Note: See TracBrowser for help on using the repository browser.