xref: /AOO41X/main/idlc/source/astunion.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_idlc.hxx"
30*cdf0e10cSrcweir #include <idlc/astunion.hxx>
31*cdf0e10cSrcweir #include <idlc/astbasetype.hxx>
32*cdf0e10cSrcweir #include <idlc/errorhandler.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "registry/version.h"
35*cdf0e10cSrcweir #include "registry/writer.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir using namespace ::rtl;
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir AstUnion::AstUnion(const ::rtl::OString& name, AstType* pDiscType, AstScope* pScope)
40*cdf0e10cSrcweir 	: AstStruct(NT_union, name, NULL, pScope)
41*cdf0e10cSrcweir 	, m_pDiscriminantType(pDiscType)
42*cdf0e10cSrcweir 	, m_discExprType(ET_long)
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir 	AstBaseType* pBaseType;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 	if ( !pDiscType )
47*cdf0e10cSrcweir 	{
48*cdf0e10cSrcweir 		m_pDiscriminantType = NULL;
49*cdf0e10cSrcweir 		m_discExprType = ET_none;
50*cdf0e10cSrcweir 		return;
51*cdf0e10cSrcweir 	}
52*cdf0e10cSrcweir 	/*
53*cdf0e10cSrcweir 	 * If the discriminator type is a predefined type
54*cdf0e10cSrcweir 	 * then install the equivalent coercion target type in
55*cdf0e10cSrcweir 	 * the pd_udisc_type field.
56*cdf0e10cSrcweir 	 */
57*cdf0e10cSrcweir 	if ( pDiscType->getNodeType() == NT_predefined )
58*cdf0e10cSrcweir 	{
59*cdf0e10cSrcweir 		pBaseType = (AstBaseType*)pDiscType;
60*cdf0e10cSrcweir 		if ( !pBaseType )
61*cdf0e10cSrcweir 		{
62*cdf0e10cSrcweir 			m_pDiscriminantType = NULL;
63*cdf0e10cSrcweir 			m_discExprType = ET_none;
64*cdf0e10cSrcweir 			return;
65*cdf0e10cSrcweir 		}
66*cdf0e10cSrcweir 		m_pDiscriminantType = pDiscType;
67*cdf0e10cSrcweir 		switch (pBaseType->getExprType())
68*cdf0e10cSrcweir 		{
69*cdf0e10cSrcweir 			case ET_long:
70*cdf0e10cSrcweir 			case ET_ulong:
71*cdf0e10cSrcweir 			case ET_short:
72*cdf0e10cSrcweir 			case ET_ushort:
73*cdf0e10cSrcweir 			case ET_char:
74*cdf0e10cSrcweir 			case ET_boolean:
75*cdf0e10cSrcweir 				m_discExprType = pBaseType->getExprType();
76*cdf0e10cSrcweir 				break;
77*cdf0e10cSrcweir 			default:
78*cdf0e10cSrcweir 				m_discExprType = ET_none;
79*cdf0e10cSrcweir 				m_pDiscriminantType = NULL;
80*cdf0e10cSrcweir 				break;
81*cdf0e10cSrcweir 		}
82*cdf0e10cSrcweir 	} else
83*cdf0e10cSrcweir 		if (pDiscType->getNodeType() == NT_enum)
84*cdf0e10cSrcweir 		{
85*cdf0e10cSrcweir 			m_discExprType = ET_any;
86*cdf0e10cSrcweir 			m_pDiscriminantType = pDiscType;
87*cdf0e10cSrcweir 		} else
88*cdf0e10cSrcweir 		{
89*cdf0e10cSrcweir 			m_discExprType = ET_none;
90*cdf0e10cSrcweir 			m_pDiscriminantType = NULL;
91*cdf0e10cSrcweir 		}
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	if ( !m_pDiscriminantType )
94*cdf0e10cSrcweir 		idlc()->error()->error2(EIDL_DISC_TYPE, this, pDiscType);
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir AstUnion::~AstUnion()
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir AstDeclaration* AstUnion::addDeclaration(AstDeclaration* pDecl)
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	if ( pDecl->getNodeType() == NT_union_branch )
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		AstUnionBranch* pBranch = (AstUnionBranch*)pDecl;
106*cdf0e10cSrcweir 		if ( lookupBranch(pBranch) )
107*cdf0e10cSrcweir 		{
108*cdf0e10cSrcweir 			idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pDecl);
109*cdf0e10cSrcweir 			return NULL;
110*cdf0e10cSrcweir 		}
111*cdf0e10cSrcweir 	}
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	return AstScope::addDeclaration(pDecl);
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupBranch(AstUnionBranch* pBranch)
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 	AstUnionLabel* pLabel = NULL;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	if ( pBranch )
121*cdf0e10cSrcweir 		pLabel = pBranch->getLabel();
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	if ( pLabel )
124*cdf0e10cSrcweir 	{
125*cdf0e10cSrcweir 		if (pLabel->getLabelKind() == UL_default)
126*cdf0e10cSrcweir 			return lookupDefault();
127*cdf0e10cSrcweir 		if (m_discExprType == ET_any)
128*cdf0e10cSrcweir 			/* CONVENTION: indicates enum discr */
129*cdf0e10cSrcweir 			return lookupEnum(pBranch);
130*cdf0e10cSrcweir 		return lookupLabel(pBranch);
131*cdf0e10cSrcweir 	}
132*cdf0e10cSrcweir 	return NULL;
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupDefault(sal_Bool bReportError)
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	DeclList::const_iterator iter = getIteratorBegin();
138*cdf0e10cSrcweir 	DeclList::const_iterator end = getIteratorEnd();
139*cdf0e10cSrcweir 	AstUnionBranch	    *pBranch = NULL;
140*cdf0e10cSrcweir 	AstDeclaration	    *pDecl = NULL;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	while ( iter != end )
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		pDecl = *iter;
145*cdf0e10cSrcweir 		if ( pDecl->getNodeType() == NT_union_branch )
146*cdf0e10cSrcweir 		{
147*cdf0e10cSrcweir 			pBranch = (AstUnionBranch*)pDecl;
148*cdf0e10cSrcweir 			if (pBranch == NULL)
149*cdf0e10cSrcweir 			{
150*cdf0e10cSrcweir 				++iter;
151*cdf0e10cSrcweir 				continue;
152*cdf0e10cSrcweir 			}
153*cdf0e10cSrcweir 			if ( pBranch->getLabel() != NULL &&
154*cdf0e10cSrcweir 				 pBranch->getLabel()->getLabelKind() == UL_default)
155*cdf0e10cSrcweir 			{
156*cdf0e10cSrcweir 				if ( bReportError )
157*cdf0e10cSrcweir 					idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
158*cdf0e10cSrcweir 				return pBranch;
159*cdf0e10cSrcweir 			}
160*cdf0e10cSrcweir 		}
161*cdf0e10cSrcweir 	    ++iter;
162*cdf0e10cSrcweir 	}
163*cdf0e10cSrcweir 	return NULL;
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupLabel(AstUnionBranch* pBranch)
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 	AstUnionLabel* pLabel = pBranch->getLabel();
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	if ( !pLabel->getLabelValue() )
171*cdf0e10cSrcweir 		return pBranch;
172*cdf0e10cSrcweir //	pLabel->getLabelValue()->setExprValue(pLabel->getLabelValue()->coerce(m_discExprType, sal_False));
173*cdf0e10cSrcweir 	AstExprValue* pLabelValue = pLabel->getLabelValue()->coerce(
174*cdf0e10cSrcweir         m_discExprType, sal_False);
175*cdf0e10cSrcweir 	if ( !pLabelValue )
176*cdf0e10cSrcweir 	{
177*cdf0e10cSrcweir 		idlc()->error()->evalError(pLabel->getLabelValue());
178*cdf0e10cSrcweir 		return pBranch;
179*cdf0e10cSrcweir 	} else
180*cdf0e10cSrcweir 	{
181*cdf0e10cSrcweir 		pLabel->getLabelValue()->setExprValue(pLabelValue);
182*cdf0e10cSrcweir 	}
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	DeclList::const_iterator iter = getIteratorBegin();
185*cdf0e10cSrcweir 	DeclList::const_iterator end = getIteratorEnd();
186*cdf0e10cSrcweir 	AstUnionBranch*	pB = NULL;
187*cdf0e10cSrcweir 	AstDeclaration*	pDecl = NULL;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	while ( iter != end )
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		pDecl = *iter;
192*cdf0e10cSrcweir 		if ( pDecl->getNodeType() == NT_union_branch )
193*cdf0e10cSrcweir 		{
194*cdf0e10cSrcweir 			pB = (AstUnionBranch*)pDecl;
195*cdf0e10cSrcweir 			if ( !pB )
196*cdf0e10cSrcweir 			{
197*cdf0e10cSrcweir 				++iter;
198*cdf0e10cSrcweir 				continue;
199*cdf0e10cSrcweir 			}
200*cdf0e10cSrcweir 			if ( pB->getLabel() != NULL &&
201*cdf0e10cSrcweir 				 pB->getLabel()->getLabelKind() == UL_label &&
202*cdf0e10cSrcweir 				 pB->getLabel()->getLabelValue()->compare(pLabel->getLabelValue()) )
203*cdf0e10cSrcweir 			{
204*cdf0e10cSrcweir 				idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
205*cdf0e10cSrcweir 				return pBranch;
206*cdf0e10cSrcweir 			}
207*cdf0e10cSrcweir 		}
208*cdf0e10cSrcweir 	    ++iter;
209*cdf0e10cSrcweir 	}
210*cdf0e10cSrcweir 	return NULL;
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir AstUnionBranch* AstUnion::lookupEnum(AstUnionBranch* pBranch)
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir 	AstDeclaration const * pType = resolveTypedefs(m_pDiscriminantType);
216*cdf0e10cSrcweir 	if ( pType->getNodeType() != NT_enum )
217*cdf0e10cSrcweir 		return NULL;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	AstUnionLabel* pLabel = pBranch->getLabel();
220*cdf0e10cSrcweir 	AstExpression* pExpr = pLabel->getLabelValue();
221*cdf0e10cSrcweir 	if ( !pExpr )
222*cdf0e10cSrcweir 		return pBranch;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	/*
225*cdf0e10cSrcweir 	 * Expecting a symbol label
226*cdf0e10cSrcweir 	 */
227*cdf0e10cSrcweir 	if ( pExpr->getCombOperator() != EC_symbol)
228*cdf0e10cSrcweir 	{
229*cdf0e10cSrcweir 		idlc()->error()->enumValExpected(this);
230*cdf0e10cSrcweir 		return pBranch;
231*cdf0e10cSrcweir 	}
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	/*
234*cdf0e10cSrcweir 	 * See if the symbol defines a constant in the discriminator enum
235*cdf0e10cSrcweir 	 */
236*cdf0e10cSrcweir 	AstEnum* pEnum = (AstEnum*)pType;
237*cdf0e10cSrcweir 	AstDeclaration* pDecl = pEnum->lookupByName(*pExpr->getSymbolicName());
238*cdf0e10cSrcweir 	if ( pDecl == NULL || pDecl->getScope() != pEnum)
239*cdf0e10cSrcweir 	{
240*cdf0e10cSrcweir 		idlc()->error()->enumValLookupFailure(this, pEnum, *pExpr->getSymbolicName());
241*cdf0e10cSrcweir 		return pBranch;
242*cdf0e10cSrcweir 	}
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	DeclList::const_iterator iter = getIteratorBegin();
246*cdf0e10cSrcweir 	DeclList::const_iterator end = getIteratorEnd();
247*cdf0e10cSrcweir 	AstUnionBranch*	pB = NULL;
248*cdf0e10cSrcweir 	pDecl = NULL;
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 	while ( iter != end )
251*cdf0e10cSrcweir 	{
252*cdf0e10cSrcweir 		pDecl = *iter;
253*cdf0e10cSrcweir 		if ( pDecl->getNodeType() == NT_union_branch )
254*cdf0e10cSrcweir 		{
255*cdf0e10cSrcweir 			pB = (AstUnionBranch*)pDecl;
256*cdf0e10cSrcweir 			if ( !pB )
257*cdf0e10cSrcweir 			{
258*cdf0e10cSrcweir 				++iter;
259*cdf0e10cSrcweir 				continue;
260*cdf0e10cSrcweir 			}
261*cdf0e10cSrcweir 			if ( pB->getLabel() != NULL &&
262*cdf0e10cSrcweir 				 pB->getLabel()->getLabelKind() == UL_label &&
263*cdf0e10cSrcweir 				 pB->getLabel()->getLabelValue()->compare(pLabel->getLabelValue()) )
264*cdf0e10cSrcweir 			{
265*cdf0e10cSrcweir 				idlc()->error()->error2(EIDL_MULTIPLE_BRANCH, this, pBranch);
266*cdf0e10cSrcweir 				return pBranch;
267*cdf0e10cSrcweir 			}
268*cdf0e10cSrcweir 		}
269*cdf0e10cSrcweir 	    ++iter;
270*cdf0e10cSrcweir 	}
271*cdf0e10cSrcweir 	return NULL;
272*cdf0e10cSrcweir }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir sal_Bool AstUnion::dump(RegistryKey& rKey)
275*cdf0e10cSrcweir {
276*cdf0e10cSrcweir 	RegistryKey localKey;
277*cdf0e10cSrcweir 	if (rKey.createKey( OStringToOUString(getFullName(), RTL_TEXTENCODING_UTF8 ), localKey))
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		fprintf(stderr, "%s: warning, could	not create key '%s' in '%s'\n",
280*cdf0e10cSrcweir 			    idlc()->getOptions()->getProgramName().getStr(),
281*cdf0e10cSrcweir 			    getFullName().getStr(), OUStringToOString(rKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
282*cdf0e10cSrcweir 		return sal_False;
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 	sal_uInt16 nMember = getNodeCount(NT_union_branch);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     OUString emptyStr;
288*cdf0e10cSrcweir     typereg::Writer aBlob(
289*cdf0e10cSrcweir         TYPEREG_VERSION_0, getDocumentation(), emptyStr, RT_TYPE_UNION,
290*cdf0e10cSrcweir         false, OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8), 1,
291*cdf0e10cSrcweir         nMember, 0, 0);
292*cdf0e10cSrcweir     aBlob.setSuperTypeName(
293*cdf0e10cSrcweir         0,
294*cdf0e10cSrcweir         OStringToOUString(
295*cdf0e10cSrcweir             getDiscrimantType()->getScopedName(), RTL_TEXTENCODING_UTF8));
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 	if ( nMember > 0 )
298*cdf0e10cSrcweir 	{
299*cdf0e10cSrcweir 		DeclList::const_iterator iter = getIteratorBegin();
300*cdf0e10cSrcweir 		DeclList::const_iterator end = getIteratorEnd();
301*cdf0e10cSrcweir 		AstDeclaration* pDecl = NULL;
302*cdf0e10cSrcweir 		AstUnionBranch* pBranch = NULL;
303*cdf0e10cSrcweir 		AstUnionBranch* pDefault = lookupDefault(sal_False);
304*cdf0e10cSrcweir 		AstUnionLabel* 	pLabel = NULL;
305*cdf0e10cSrcweir 		AstExprValue*	pExprValue = NULL;
306*cdf0e10cSrcweir 		RTConstValue 	aConst;
307*cdf0e10cSrcweir 		RTFieldAccess	access = RT_ACCESS_READWRITE;
308*cdf0e10cSrcweir 		OUString 	docu;
309*cdf0e10cSrcweir 		sal_uInt16 	index = 0;
310*cdf0e10cSrcweir 		if ( pDefault )
311*cdf0e10cSrcweir 			index = 1;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 		sal_Int64	disc = 0;
314*cdf0e10cSrcweir 		while ( iter != end )
315*cdf0e10cSrcweir 		{
316*cdf0e10cSrcweir 			pDecl = *iter;
317*cdf0e10cSrcweir 			if ( pDecl->getNodeType() == NT_union_branch )
318*cdf0e10cSrcweir 			{
319*cdf0e10cSrcweir 				pBranch = (AstUnionBranch*)pDecl;
320*cdf0e10cSrcweir 				if (pBranch == pDefault)
321*cdf0e10cSrcweir 				{
322*cdf0e10cSrcweir 					++iter;
323*cdf0e10cSrcweir 					continue;
324*cdf0e10cSrcweir 				}
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 				pLabel = pBranch->getLabel();
327*cdf0e10cSrcweir 				pExprValue = pLabel->getLabelValue()->coerce(ET_hyper, sal_False);
328*cdf0e10cSrcweir 				aConst.m_type = RT_TYPE_INT64;
329*cdf0e10cSrcweir 				aConst.m_value.aHyper = pExprValue->u.hval;
330*cdf0e10cSrcweir 				if ( aConst.m_value.aHyper > disc )
331*cdf0e10cSrcweir 					disc = aConst.m_value.aHyper;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 				aBlob.setFieldData(
334*cdf0e10cSrcweir                     index++, pBranch->getDocumentation(), emptyStr, RT_ACCESS_READWRITE,
335*cdf0e10cSrcweir                     OStringToOUString(
336*cdf0e10cSrcweir                         pBranch->getLocalName(), RTL_TEXTENCODING_UTF8),
337*cdf0e10cSrcweir                     OStringToOUString(
338*cdf0e10cSrcweir                         pBranch->getType()->getRelativName(),
339*cdf0e10cSrcweir                         RTL_TEXTENCODING_UTF8),
340*cdf0e10cSrcweir                     aConst);
341*cdf0e10cSrcweir 			}
342*cdf0e10cSrcweir 			++iter;
343*cdf0e10cSrcweir 		}
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 		if ( pDefault )
346*cdf0e10cSrcweir 		{
347*cdf0e10cSrcweir 			access = RT_ACCESS_DEFAULT;
348*cdf0e10cSrcweir 			aConst.m_type = RT_TYPE_INT64;
349*cdf0e10cSrcweir 			aConst.m_value.aHyper = disc + 1;
350*cdf0e10cSrcweir 			aBlob.setFieldData(
351*cdf0e10cSrcweir                 0, pDefault->getDocumentation(), emptyStr, RT_ACCESS_DEFAULT,
352*cdf0e10cSrcweir                 OStringToOUString(
353*cdf0e10cSrcweir                     pDefault->getLocalName(), RTL_TEXTENCODING_UTF8),
354*cdf0e10cSrcweir                 OStringToOUString(
355*cdf0e10cSrcweir                     pDefault->getType()->getRelativName(),
356*cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8),
357*cdf0e10cSrcweir                 aConst);
358*cdf0e10cSrcweir 		}
359*cdf0e10cSrcweir 	}
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     sal_uInt32 aBlobSize;
362*cdf0e10cSrcweir     void const * pBlob = aBlob.getBlob(&aBlobSize);
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	if (localKey.setValue(OUString(), RG_VALUETYPE_BINARY,
365*cdf0e10cSrcweir 					  	  (RegValue)pBlob, aBlobSize))
366*cdf0e10cSrcweir 	{
367*cdf0e10cSrcweir 		fprintf(stderr, "%s: warning, could	not set value of key \"%s\" in %s\n",
368*cdf0e10cSrcweir 			    idlc()->getOptions()->getProgramName().getStr(),
369*cdf0e10cSrcweir 				getFullName().getStr(), OUStringToOString(localKey.getRegistryName(), RTL_TEXTENCODING_UTF8).getStr());
370*cdf0e10cSrcweir 		return sal_False;
371*cdf0e10cSrcweir 	}
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 	return sal_True;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir AstUnionBranch::AstUnionBranch(AstUnionLabel* pLabel, AstType const * pType, const ::rtl::OString& name, AstScope* pScope)
377*cdf0e10cSrcweir 	: AstMember(NT_union_branch, pType, name, pScope)
378*cdf0e10cSrcweir 	, m_pLabel(pLabel)
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir AstUnionBranch::~AstUnionBranch()
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir 	if ( m_pLabel )
385*cdf0e10cSrcweir 		delete m_pLabel;
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir AstUnionLabel::AstUnionLabel(UnionLabel labelKind, AstExpression* pExpr)
389*cdf0e10cSrcweir 	: m_label(labelKind)
390*cdf0e10cSrcweir 	, m_pLabelValue(pExpr)
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir 	if ( m_pLabelValue )
393*cdf0e10cSrcweir 		m_pLabelValue->evaluate(EK_const);
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir AstUnionLabel::~AstUnionLabel()
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir 	if ( m_pLabelValue )
399*cdf0e10cSrcweir 		delete m_pLabelValue;
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402