merge the formfield patch from ooo-build
[ooovba.git] / idl / source / objects / types.cxx
blobcf84ba229b071d31af3a0bdbf35c2b65c4fceb48
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: types.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_idl.hxx"
34 #include <ctype.h>
35 #include <stdio.h>
37 #include <tools/debug.hxx>
39 #include <attrib.hxx>
40 #include <types.hxx>
41 #include <globals.hxx>
42 #include <database.hxx>
44 /****************** SvMetaAttribute *************************************/
45 /************************************************************************/
46 SV_IMPL_META_FACTORY1( SvMetaAttribute, SvMetaReference );
47 /*************************************************************************
48 |* SvMetaAttribute::SvMetaAttribute()
50 |* Beschreibung
51 *************************************************************************/
52 SvMetaAttribute::SvMetaAttribute()
53 : aAutomation( TRUE, FALSE )
54 , aExport( TRUE, FALSE )
55 , aIsCollection ( FALSE, FALSE )
56 , aReadOnlyDoc ( TRUE, FALSE )
57 , aHidden( FALSE, FALSE )
58 , bNewAttr( FALSE )
62 SvMetaAttribute::SvMetaAttribute( SvMetaType * pType )
63 : aType( pType )
64 , aAutomation( TRUE, FALSE )
65 , aExport( TRUE, FALSE )
66 , aIsCollection ( FALSE, FALSE)
67 , aReadOnlyDoc ( TRUE, FALSE)
68 , aHidden( FALSE, FALSE )
69 , bNewAttr( FALSE )
73 /*************************************************************************
74 |* SvMetaAttribute::Load()
75 |* SvMetaAttribute::Save()
77 |* Beschreibung
78 *************************************************************************/
79 void SvMetaAttribute::Load( SvPersistStream & rStm )
81 SvMetaReference::Load( rStm );
83 BYTE nMask;
84 rStm >> nMask;
85 if( nMask & 0x01 )
87 SvMetaType * pType;
88 rStm >> pType;
89 aType = pType;
91 if( nMask & 0x02 ) rStm >> aSlotId;
92 if( nMask & 0x04 ) rStm >> aExport;
93 if( nMask & 0x08 ) rStm >> aReadonly;
94 if( nMask & 0x10 ) rStm >> aAutomation;
95 if( nMask & 0x20 ) rStm >> aIsCollection;
96 if( nMask & 0x40 ) rStm >> aReadOnlyDoc;
97 if( nMask & 0x80 ) rStm >> aHidden;
100 void SvMetaAttribute::Save( SvPersistStream & rStm )
102 SvMetaReference::Save( rStm );
104 // Maske erstellen
105 BYTE nMask = 0;
106 if( aType.Is() ) nMask |= 0x1;
107 if( aSlotId.IsSet() ) nMask |= 0x2;
108 if( aExport.IsSet() ) nMask |= 0x4;
109 if( aReadonly.IsSet() ) nMask |= 0x8;
110 if( aAutomation.IsSet() ) nMask |= 0x10;
111 if( aIsCollection.IsSet() ) nMask |= 0x20;
112 if( aReadOnlyDoc.IsSet() ) nMask |= 0x40;
113 if( aHidden.IsSet() ) nMask |= 0x80;
115 // Daten schreiben
116 rStm << nMask;
117 if( nMask & 0x1 ) rStm << aType;
118 if( nMask & 0x2 ) rStm << aSlotId;
119 if( nMask & 0x4 ) rStm << aExport;
120 if( nMask & 0x8 ) rStm << aReadonly;
121 if( nMask & 0x10 ) rStm << aAutomation;
122 if( nMask & 0x20 ) rStm << aIsCollection;
123 if( nMask & 0x40 ) rStm << aReadOnlyDoc;
124 if( nMask & 0x80 ) rStm << aHidden;
127 /*************************************************************************
128 |* SvMetaAttribute::GetType()
130 |* Beschreibung
131 *************************************************************************/
132 SvMetaType * SvMetaAttribute::GetType() const
134 if( aType.Is() || !GetRef() ) return aType;
135 return ((SvMetaAttribute *)GetRef())->GetType();
138 /*************************************************************************
139 |* SvMetaAttribute::GetSlotId()
141 |* Beschreibung
142 *************************************************************************/
143 const SvNumberIdentifier & SvMetaAttribute::GetSlotId() const
145 if( aSlotId.IsSet() || !GetRef() ) return aSlotId;
146 return ((SvMetaAttribute *)GetRef())->GetSlotId();
149 /*************************************************************************
150 |* SvMetaAttribute::GetReadonly()
152 |* Beschreibung
153 *************************************************************************/
154 BOOL SvMetaAttribute::GetReadonly() const
156 if( aReadonly.IsSet() || !GetRef() ) return aReadonly;
157 return ((SvMetaAttribute *)GetRef())->GetReadonly();
160 /*************************************************************************
161 |* SvMetaAttribute::GetExport()
163 |* Beschreibung
164 *************************************************************************/
165 BOOL SvMetaAttribute::GetExport() const
167 if( aExport.IsSet() || !GetRef() ) return aExport;
168 return ((SvMetaAttribute *)GetRef())->GetExport();
171 /*************************************************************************
172 |* SvMetaAttribute::GetHidden()
174 |* Beschreibung
175 *************************************************************************/
176 BOOL SvMetaAttribute::GetHidden() const
178 // Wenn Export gesetzt wurde, aber Hidden nicht, gilt der Default
179 // aHidden = !aExport
180 if ( aExport.IsSet() && !aHidden.IsSet() )
181 return !aExport;
182 else if( aHidden.IsSet() || !GetRef() )
183 return aHidden;
184 else
185 return ((SvMetaAttribute *)GetRef())->GetHidden();
188 /*************************************************************************
189 |* SvMetaAttribute::GetAutomation()
191 |* Beschreibung
192 *************************************************************************/
193 BOOL SvMetaAttribute::GetAutomation() const
195 if( aAutomation.IsSet() || !GetRef() ) return aAutomation;
196 return ((SvMetaAttribute *)GetRef())->GetAutomation();
199 BOOL SvMetaAttribute::GetIsCollection() const
201 BOOL bRet;
202 if( aIsCollection.IsSet() || !GetRef() )
204 if ( aIsCollection.IsSet() )
206 bRet = aIsCollection;
207 return bRet;
210 return aIsCollection;
213 return ((SvMetaSlot *)GetRef())->GetIsCollection();
216 BOOL SvMetaAttribute::GetReadOnlyDoc() const
218 if( aReadOnlyDoc.IsSet() || !GetRef() ) return aReadOnlyDoc;
219 return ((SvMetaSlot *)GetRef())->GetReadOnlyDoc();
222 /*************************************************************************
223 |* SvMetaAttribute::IsMethod()
224 |* SvMetaAttribute::IsVariable()
225 |* SvMetaAttribute::GetMangleName()
227 |* Beschreibung
228 *************************************************************************/
229 BOOL SvMetaAttribute::IsMethod() const
231 SvMetaType * pType = GetType();
232 DBG_ASSERT( pType, "no type for attribute" );
233 return pType->GetType() == TYPE_METHOD;
236 BOOL SvMetaAttribute::IsVariable() const
238 SvMetaType * pType = GetType();
239 return pType->GetType() != TYPE_METHOD;
242 ByteString SvMetaAttribute::GetMangleName( BOOL ) const
244 return GetName();
247 /*************************************************************************
248 |* SvMetaAttribute::FillSbxObject()
250 |* Beschreibung
251 *************************************************************************/
253 void SvMetaAttribute::FillSbxObject( SbxInfo * pInfo, USHORT nSbxFlags )
255 SvMetaType * pType = GetType();
256 DBG_ASSERT( pType, "no type for attribute" );
257 if( !nSbxFlags )
258 { // Flags koennen vom Aufrufer ueberschrieben werden
259 if( pType->GetOut() )
261 nSbxFlags |= SBX_WRITE;
262 if( pType->GetIn() )
263 nSbxFlags |= SBX_READ;
265 else
266 nSbxFlags |= SBX_READ;
268 SvMetaType * pBaseType = pType->GetBaseType();
269 DBG_ASSERT( pBaseType, "no base type for attribute" );
270 if( pBaseType->GetType() == TYPE_STRUCT )
272 const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
273 ULONG nCount = rList.Count();
274 for( ULONG i = 0; i < nCount; i++ )
275 rList.GetObject( i )->FillSbxObject( pInfo, nSbxFlags );
277 else
278 //MI: pInfo->AddParam( GetName(), pBaseType->GetSbxDataType(), nSbxFlags );
279 pInfo->AddParam( GetName(), SbxVARIANT, nSbxFlags );
283 /*************************************************************************
284 |* SvMetaAttribute::FillSbxObject()
286 |* Beschreibung
287 *************************************************************************/
289 void SvMetaAttribute::FillSbxObject( SvIdlDataBase & rBase,
290 SbxObject * pObj, BOOL bVariable )
292 // keine Attribut fuer Automation
293 if( !GetAutomation() || !GetExport() )
294 return;
296 if( bVariable && IsVariable() )
298 SvMetaType * pType = GetType();
299 DBG_ASSERT( pType, "no type for attribute" );
300 SvMetaType * pBaseType = pType->GetBaseType();
301 DBG_ASSERT( pBaseType, "no base type for attribute" );
303 if( pBaseType->GetType() == TYPE_STRUCT )
305 SvNumberIdentifier aSlotId = rBase.aStructSlotId;
306 if ( GetSlotId().Len() )
307 rBase.aStructSlotId = GetSlotId();
308 const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
309 ULONG nCount = rList.Count();
310 for( ULONG i = 0; i < nCount; i++ )
311 rList.GetObject( i )->FillSbxObject( rBase, pObj, bVariable );
312 rBase.aStructSlotId = aSlotId;
314 else
316 SbxPropertyRef xProp = new SbxProperty( GetName(), SbxVARIANT );
317 //MI: pBaseType->GetSbxDataType() );
318 if ( GetReadonly() || IsMethod() )
319 xProp->ResetFlag( SBX_WRITE );
320 xProp->SetUserData( MakeSlotValue( rBase, TRUE ) );
321 pType->FillSbxObject( xProp, bVariable );
323 pObj->Insert( &xProp );
326 else if( !bVariable && IsMethod() )
328 SvMetaType * pType = GetType();
329 SvMetaType * pRetBaseType = GetType()->GetReturnType()->GetBaseType();
330 SbxMethodRef xMeth = new SbxMethod( GetName(),
331 pRetBaseType->GetSbxDataType() );
332 xMeth->ResetFlag( SBX_WRITE );
333 xMeth->SetUserData( MakeSlotValue( rBase, FALSE ) );
334 pType->FillSbxObject( xMeth, bVariable );
336 pObj->Insert( &xMeth );
340 #ifdef IDL_COMPILER
341 /*************************************************************************
342 |* SvMetaAttribute::Test()
344 |* Beschreibung
345 *************************************************************************/
346 BOOL SvMetaAttribute::Test( SvIdlDataBase & rBase,
347 SvTokenStream & rInStm )
349 BOOL bOk = TRUE;
350 if( GetType()->IsItem() && !GetSlotId().IsSet() )
352 rBase.SetError( "slot without id declared", rInStm.GetToken() );
353 rBase.WriteError( rInStm );
354 bOk = FALSE;
357 if( !GetType()->IsItem() && GetSlotId().IsSet() )
359 rBase.SetError( "slot without item declared", rInStm.GetToken() );
360 rBase.WriteError( rInStm );
361 bOk = FALSE;
364 return bOk;
367 /*************************************************************************
368 |* SvMetaAttribute::ReadSvIdl()
370 |* Beschreibung
371 *************************************************************************/
372 BOOL SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase,
373 SvTokenStream & rInStm )
375 UINT32 nTokPos = rInStm.Tell();
376 if( !GetType() )
377 // Es wurde kein Typ im ctor mitgegeben
378 aType = rBase.ReadKnownType( rInStm );
379 BOOL bOk = FALSE;
380 if( GetType() )
382 ReadNameSvIdl( rBase, rInStm );
383 aSlotId.ReadSvIdl( rBase, rInStm );
385 bOk = TRUE;
386 SvToken * pTok = rInStm.GetToken();
387 if( bOk && pTok->IsChar() && pTok->GetChar() == '(' )
389 SvMetaTypeRef xT = new SvMetaType();
390 xT->SetRef( GetType() );
391 aType = xT;
392 bOk = aType->ReadMethodArgs( rBase, rInStm );
394 if( bOk )
395 bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
397 else
398 rBase.SetError( "unknown type", rInStm.GetToken() );
400 if( !bOk )
401 rInStm.Seek( nTokPos );
402 return bOk;
405 /*************************************************************************
406 |* SvMetaAttribute::WriteSvIdl()
408 |* Beschreibung
409 *************************************************************************/
410 void SvMetaAttribute::WriteSvIdl
412 SvIdlDataBase & rBase,
413 SvStream & rOutStm,
414 USHORT nTab
417 SvMetaType * pType = GetType();
418 pType->WriteTypePrefix( rBase, rOutStm, nTab, WRITE_IDL );
419 rOutStm << ' ' << GetName().GetBuffer();
420 if( aSlotId.IsSet() )
421 rOutStm << ' ' << aSlotId.GetBuffer();
422 if( pType->GetType() == TYPE_METHOD )
423 pType->WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
424 ULONG nPos = rOutStm.Tell();
425 rOutStm << endl;
426 SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
427 TestAndSeekSpaceOnly( rOutStm, nPos );
430 /*************************************************************************
431 |* SvMetaAttribute::ReadAttributesSvIdl()
433 |* Beschreibung
434 *************************************************************************/
435 void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase,
436 SvTokenStream & rInStm )
438 SvMetaReference::ReadAttributesSvIdl( rBase, rInStm );
439 aSlotId.ReadSvIdl( rBase, SvHash_SlotId(), rInStm );
440 aExport.ReadSvIdl( SvHash_Export(), rInStm );
441 aHidden.ReadSvIdl( SvHash_Hidden(), rInStm );
442 aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
443 aIsCollection.ReadSvIdl( SvHash_IsCollection(), rInStm );
444 aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm );
445 if( aReadonly.ReadSvIdl( SvHash_Readonly(), rInStm ) )
447 if( GetType()->GetType() == TYPE_METHOD )
449 // Fehler setzen
450 rBase.SetError( "Readonly in function attribute", rInStm.GetToken() );
451 rBase.WriteError( rInStm );
456 /*************************************************************************
457 |* SvMetaAttribute::WriteAttributesSvIdl()
459 |* Beschreibung
460 *************************************************************************/
461 void SvMetaAttribute::WriteAttributesSvIdl
463 SvIdlDataBase & rBase,
464 SvStream & rOutStm,
465 USHORT nTab
468 SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab );
470 //aSlotId.WriteSvIdl( SvHash_SlotId(), rOutStm, nTab );
471 if( !aExport || !aAutomation || aReadonly )
473 WriteTab( rOutStm, nTab );
474 rOutStm << "//class SvMetaAttribute" << endl;
475 if( !aExport )
477 WriteTab( rOutStm, nTab );
478 aExport.WriteSvIdl( SvHash_Export(), rOutStm );
479 rOutStm << ';' << endl;
481 if ( aHidden != aExport )
483 WriteTab( rOutStm, nTab );
484 aExport.WriteSvIdl( SvHash_Hidden(), rOutStm );
485 rOutStm << ';' << endl;
487 if( aReadonly )
489 WriteTab( rOutStm, nTab );
490 aReadonly.WriteSvIdl( SvHash_Readonly(), rOutStm );
491 rOutStm << ';' << endl;
493 if( !aAutomation )
495 WriteTab( rOutStm, nTab );
496 aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
497 rOutStm << ';' << endl;
499 if( aIsCollection )
501 WriteTab( rOutStm, nTab );
502 aIsCollection.WriteSvIdl( SvHash_IsCollection(), rOutStm );
503 rOutStm << ';' << endl;
505 if( !aReadOnlyDoc )
507 WriteTab( rOutStm, nTab );
508 aReadOnlyDoc.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm );
509 rOutStm << ';' << endl;
514 /*************************************************************************
515 |* SvMetaAttribute::WriteParam()
517 |* Beschreibung
518 *************************************************************************/
519 void SvMetaAttribute::WriteParam( SvIdlDataBase & rBase,
520 SvStream & rOutStm,
521 USHORT nTab,
522 WriteType nT )
524 SvMetaType * pType = GetType();
525 DBG_ASSERT( pType, "no type for attribute" );
526 SvMetaType * pBaseType = pType->GetBaseType();
527 DBG_ASSERT( pBaseType, "no base type for attribute" );
529 if( nT == WRITE_ODL || nT == WRITE_DOCU
530 || nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
532 if( pBaseType->GetType() == TYPE_STRUCT )
534 const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
535 ULONG nCount = rList.Count();
536 for( ULONG i = 0; i < nCount; i++ )
538 rList.GetObject( i )->WriteParam( rBase, rOutStm, nTab, nT );
539 if( i+1<nCount )
541 // if ( nT == WRITE_DOCU )
542 rOutStm << ',';
543 // else
544 // rOutStm << ',' << endl;
548 else
550 if ( nT != WRITE_DOCU )
552 WriteTab( rOutStm, nTab );
553 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
556 if( GetName().Len() )
558 rOutStm << ' ';
559 rOutStm << GetName().GetBuffer();
562 if ( nT == WRITE_DOCU )
564 if( pBaseType->GetType() == TYPE_METHOD ||
565 pBaseType->GetType() == TYPE_STRUCT ||
566 pBaseType->GetType() == TYPE_ENUM )
568 DBG_ERROR( "Falscher Parametertyp!" );
570 else
571 rOutStm << pBaseType->GetBasicPostfix().GetBuffer();
576 else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
578 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
579 rOutStm << ' ';
580 rOutStm << GetName().GetBuffer();
585 /*************************************************************************
586 |* SvMetaSlot::WriteSlotId()
588 |* Beschreibung
589 *************************************************************************/
590 ULONG SvMetaAttribute::MakeSlotValue( SvIdlDataBase & rBase, BOOL bVar ) const
592 const SvNumberIdentifier & rId = GetSlotId();
593 ULONG n = rId.GetValue();
594 if( rBase.aStructSlotId.Len() )
596 n = n << 20;
597 n += rBase.aStructSlotId.GetValue();
599 if( PTR_CAST( SvMetaSlot, this ) )
600 n |= 0x20000;
601 if( !bVar )
602 n += 0x10000;
603 else if ( GetIsCollection() )
604 n += 0x40000;
605 return n;
608 /*************************************************************************
609 |* SvMetaSlot::WriteAttributes()
611 |* Beschreibung
612 *************************************************************************/
613 void SvMetaAttribute::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
614 USHORT nTab,
615 WriteType nT, WriteAttribute nA )
617 if( nT == WRITE_ODL )
619 const SvNumberIdentifier & rId = GetSlotId();
620 BOOL bReadonly = GetReadonly() || ( nA & WA_READONLY );
621 if( (rId.IsSet() && !(nA & WA_STRUCT)) || bReadonly )
623 BOOL bVar = IsVariable();
624 if( nA & WA_VARIABLE )
625 bVar = TRUE;
626 else if( nA & WA_METHOD )
627 bVar = FALSE;
629 WriteTab( rOutStm, nTab );
630 rOutStm << "//class SvMetaAttribute" << endl;
631 if( rId.IsSet() && !(nA & WA_STRUCT) )
633 WriteTab( rOutStm, nTab );
634 rOutStm << "id("
635 << ByteString::CreateFromInt32(MakeSlotValue( rBase, bVar )).GetBuffer()
636 << ")," << endl;
638 if( bVar && (bReadonly || IsMethod()) )
640 WriteTab( rOutStm, nTab );
641 rOutStm << "readonly," << endl;
647 /*************************************************************************
648 |* SvMetaAttribute::WriteCSource()
650 |* Beschreibung
651 *************************************************************************/
652 void SvMetaAttribute::WriteCSource( SvIdlDataBase & rBase, SvStream & rOutStm,
653 BOOL bSet )
655 rOutStm << endl;
656 SvMetaType * pType = GetType();
657 SvMetaType * pBaseType = pType->GetBaseType();
659 // Bei Set ist der Return immer void
660 BOOL bVoid = bSet;
661 if( pBaseType->GetType() == TYPE_METHOD )
662 bVoid = pBaseType->GetReturnType()->GetBaseType()->GetName() == "void";
664 // Methoden/Funktions-Body ausgeben
665 rOutStm << '{' << endl;
666 WriteTab( rOutStm, 1 );
667 // rOutStm << "if( SvIPCIsConnected() )" << endl;
668 // WriteTab( rOutStm, 1 );
669 // rOutStm << '{' << endl;
670 // WriteTab( rOutStm, 2 );
672 if( !bVoid )
674 if ( pBaseType->GetCName() == "double" )
676 rOutStm << "return *(double*)";
678 else
680 rOutStm << "return (";
681 pType->WriteTypePrefix( rBase, rOutStm, 2, WRITE_C_SOURCE );
682 rOutStm << ") ";
685 rOutStm << "pODKCallFunction( "
686 << ByteString::CreateFromInt32(MakeSlotValue( rBase, IsVariable() )).GetBuffer();
687 rOutStm << ',' << endl;
688 WriteTab( rOutStm, 3 );
689 rOutStm << " h" << rBase.aIFaceName.GetBuffer() << " , ";
691 ByteString aParserStr;
692 if( pBaseType->GetType() == TYPE_METHOD || bSet )
693 aParserStr = pBaseType->GetParserString();
694 if( aParserStr.Len() )
696 rOutStm << '\"';
697 rOutStm << aParserStr.GetBuffer();
698 rOutStm << "\", ";
700 else
701 rOutStm << "NULL, ";
703 if( pBaseType->GetType() == TYPE_METHOD && !bVoid )
705 rOutStm << "'";
706 rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetParserChar();
707 rOutStm << "'";
709 else if ( !bSet )
711 rOutStm << "'";
712 rOutStm << pBaseType->GetParserChar();
713 rOutStm << "'";
715 else
716 rOutStm << '0';
718 if( aParserStr.Len() )
720 rOutStm << ", ";
721 if( IsMethod() )
722 // void SetPosSize( C_Object *, C_Rectangle * pRect );
723 pBaseType->WriteParamNames( rBase, rOutStm, ByteString() );
724 else if( bSet )
725 pBaseType->WriteParamNames( rBase, rOutStm, GetName() );
728 rOutStm << " );" << endl;
729 // WriteTab( rOutStm, 1 );
730 // rOutStm << '}' << endl;
731 // if( !bVoid )
732 // {
733 // WriteTab( rOutStm, 1 );
734 // rOutStm << "return 0;" << endl;
735 // }
736 rOutStm << '}' << endl;
739 /*************************************************************************
740 |* SvMetaAttribute::WriteRecursiv_Impl()
742 |* Beschreibung
743 *************************************************************************/
744 void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase & rBase,
745 SvStream & rOutStm, USHORT nTab,
746 WriteType nT, WriteAttribute nA )
748 const SvMetaAttributeMemberList & rList = GetType()->GetBaseType()->GetAttrList();
749 ULONG nCount = rList.Count();
751 SvNumberIdentifier slotId = rBase.aStructSlotId;
752 if ( GetSlotId().Len() )
753 rBase.aStructSlotId = GetSlotId();
755 // Offizielle Hack-Schnittstelle von MM: spezielle Schalter werden "uber
756 // die WriteAttribute "ubergeben
757 if ( GetReadonly() )
758 nA |= WA_READONLY;
760 for( ULONG i = 0; i < nCount; i++ )
762 SvMetaAttribute *pAttr = rList.GetObject( i );
763 if ( nT == WRITE_DOCU )
764 pAttr->SetDescription( GetDescription() );
765 pAttr->Write( rBase, rOutStm, nTab, nT, nA );
766 if( nT == WRITE_ODL && i +1 < nCount )
767 rOutStm << ';' << endl;
770 rBase.aStructSlotId = slotId;
773 /*************************************************************************
774 |* SvMetaAttribute::Write()
776 |* Beschreibung
777 *************************************************************************/
778 void SvMetaAttribute::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
779 USHORT nTab,
780 WriteType nT, WriteAttribute nA )
782 // keine Attribut fuer Automation
783 if( nT == WRITE_DOCU )
785 if ( GetHidden() )
786 return;
788 else if ( !GetAutomation() || !GetExport() )
789 return;
791 BOOL bVariable;
792 if( nA & WA_VARIABLE )
793 bVariable = TRUE;
794 else if( nA & WA_METHOD )
795 bVariable = FALSE;
796 else
797 bVariable = IsVariable();
799 SvMetaType * pType = GetType();
800 DBG_ASSERT( pType, "no type for attribute" );
801 SvMetaType * pBaseType = pType->GetBaseType();
802 DBG_ASSERT( pBaseType, "no base type for attribute" );
803 int nBType = pBaseType->GetType();
805 if( nT == WRITE_ODL )
807 if( (bVariable && IsVariable()) || (!bVariable && IsMethod()) )
809 if( nBType == TYPE_STRUCT )
810 WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
811 else
813 SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA );
814 WriteTab( rOutStm, nTab );
815 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
817 if( GetName().Len() )
819 rOutStm << ' ';
820 rOutStm << GetName().GetBuffer();
822 if( pType->GetType() == TYPE_METHOD )
823 pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
827 else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
829 if( !bVariable && IsMethod() )
831 ByteString name; // (rBase.GetActModulePrefix());
832 name += rBase.aIFaceName;
833 name += GetName();
834 const char * pName = name.GetBuffer();
835 // Beispiel
836 // void SetPosSize( C_Object *, C_Rectangle * );
837 WriteTab( rOutStm, nTab );
838 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
839 // rOutStm << " SYSCALL";
840 rOutStm << ' ' << pName;
841 pType->WriteMethodArgs( rBase, rOutStm, nTab, nT );
842 if( nT == WRITE_C_HEADER )
843 rOutStm << ';' << endl << endl;
844 else
845 WriteCSource( rBase, rOutStm, FALSE );
847 else if ( bVariable && IsVariable() )
849 if( nBType == TYPE_STRUCT )
851 // Zur Hilfe den Namen des Properties als Kommentar ausgeben
852 rOutStm << "/* " << GetName().GetBuffer() << " */" << endl;
854 WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
856 else
858 // Beispiel
859 // void SetValue( C_Object *, USHORT n );
860 ByteString name = GetName();
862 BOOL bReadonly = GetReadonly() || ( nA & WA_READONLY );
863 if ( !bReadonly && !IsMethod() )
865 // Zuweisung
866 WriteTab( rOutStm, nTab );
867 rOutStm << "void ";
868 // rOutStm << "SYSCALL ";
869 // if ( rBase.GetActModulePrefix().Len() )
870 // rOutStm << rBase.GetActModulePrefix().GetBuffer();
871 rOutStm << rBase.aIFaceName.GetBuffer()
872 << "Set" << name.GetBuffer() << "( " << C_PREF
873 << "Object h" << rBase.aIFaceName.GetBuffer() << ", " << endl;
874 WriteTab( rOutStm, nTab+1 );
875 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
876 rOutStm << ' ' << name.GetBuffer() << " )";
877 if( nT == WRITE_C_HEADER )
878 rOutStm << ';' << endl << endl;
879 else
880 WriteCSource( rBase, rOutStm, TRUE );
883 // Zugriff
884 WriteTab( rOutStm, nTab );
885 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
886 rOutStm << ' ';
887 // rOutStm << "SYSCALL ";
888 // if ( rBase.GetActModulePrefix().Len() )
889 // rOutStm << rBase.GetActModulePrefix().GetBuffer();
890 rOutStm << rBase.aIFaceName.GetBuffer()
891 << "Get" << name.GetBuffer() << "( " << C_PREF
892 << "Object h" << rBase.aIFaceName.GetBuffer() << " )";
893 if( nT == WRITE_C_HEADER )
894 rOutStm << ';' << endl << endl;
895 else
896 WriteCSource( rBase, rOutStm, FALSE );
900 else if ( nT == WRITE_DOCU )
902 if( !bVariable && IsMethod() )
904 rOutStm << "<METHOD>" << endl
905 << GetSlotId().GetBuffer() << endl
906 << GetName().GetBuffer() << endl
907 << endl; // readonly
909 // Returntype
910 SvMetaType* pType2 = GetType();
911 SvMetaType* pBaseType2 = pType2->GetBaseType();
912 rOutStm << pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().GetBuffer() << endl;
914 DBG_ASSERT( pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().Len(),
915 "Leerer BasicName" );
917 // Syntax
918 rOutStm << GetName().GetBuffer();
919 pType2->WriteMethodArgs( rBase, rOutStm, nTab, nT );
921 // C-Returntype
922 pBaseType2->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
923 rOutStm << endl;
925 // Bei Methoden auch C-Syntax
926 rOutStm << "<C-SYNTAX>" << endl;
927 Write( rBase, rOutStm, 0, WRITE_C_HEADER, nA );
928 rOutStm << "</C-SYNTAX>" << endl;
930 // Description
931 WriteDescription( rOutStm );
932 rOutStm << "</METHOD>" << endl << endl;
934 else if( bVariable && IsVariable() )
936 if( nBType == TYPE_STRUCT )
938 WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA );
940 else
942 rOutStm << "<PROPERTY>" << endl
943 << GetSlotId().GetBuffer() << endl
944 << GetName().GetBuffer() << endl;
945 if ( GetReadonly() )
946 rOutStm << "(nur lesen)" << endl;
947 else
948 rOutStm << endl;
950 // Bei properties Type anstelle des return value
951 rOutStm << pBaseType->GetBasicName().GetBuffer() << endl;
953 DBG_ASSERT( pBaseType->GetBasicName().Len(),
954 "Leerer BasicName" );
956 // Bei properties keine Syntax
957 rOutStm << endl;
959 // C-Returntype
960 pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER );
961 rOutStm << endl;
963 // Description
964 WriteDescription( rOutStm );
965 rOutStm << "</PROPERTY>" << endl << endl;
971 /*************************************************************************
972 |* SvMetaAttribute::MakeSfx()
974 |* Beschreibung
975 *************************************************************************/
976 ULONG SvMetaAttribute::MakeSfx( ByteString * pAttrArray )
978 SvMetaType * pType = GetType();
979 DBG_ASSERT( pType, "no type for attribute" );
980 SvMetaType * pBaseType = pType->GetBaseType();
981 DBG_ASSERT( pBaseType, "no base type for attribute" );
982 if( pBaseType->GetType() == TYPE_STRUCT )
983 return pBaseType->MakeSfx( pAttrArray );
984 else
986 *pAttrArray += '{';
987 *pAttrArray += GetSlotId();
988 *pAttrArray += ",\"";
989 *pAttrArray += GetName();
990 *pAttrArray += "\"}";
991 return 1;
995 void SvMetaAttribute::Insert (SvSlotElementList&, const ByteString &, SvIdlDataBase&)
999 /*************************************************************************
1000 |* SvMetaAttribute::WriteSrc()
1002 |* Beschreibung
1003 *************************************************************************/
1004 void SvMetaAttribute::WriteSrc( SvIdlDataBase &, SvStream &, Table * )
1008 void SvMetaAttribute::WriteHelpId( SvIdlDataBase &, SvStream &, Table * )
1012 #endif // IDL_COMPILER
1014 /****************** SvMetaType *************************************/
1015 /************************************************************************/
1016 SV_IMPL_META_FACTORY1( SvMetaType, SvMetaExtern );
1017 /*************************************************************************
1018 |* SvMetaType::SvMetaType()
1020 |* Beschreibung
1021 *************************************************************************/
1022 #define CTOR \
1023 : aCall0( CALL_VALUE, FALSE ) \
1024 , aCall1( CALL_VALUE, FALSE ) \
1025 , aSbxDataType( 0, FALSE ) \
1026 , pAttrList( NULL ) \
1027 , nType( TYPE_BASE ) \
1028 , bIsItem( FALSE ) \
1029 , bIsShell( FALSE ) \
1030 , cParserChar( 'h' )
1032 SvMetaType::SvMetaType()
1033 CTOR
1037 SvMetaType::SvMetaType( const ByteString & rName, char cPC,
1038 const ByteString & rCName )
1039 CTOR
1041 SetName( rName );
1042 cParserChar = cPC;
1043 aCName = rCName;
1046 SvMetaType::SvMetaType( const ByteString & rName,
1047 const ByteString & rSbxName,
1048 const ByteString & rOdlName,
1049 char cPc,
1050 const ByteString & rCName,
1051 const ByteString & rBasicName,
1052 const ByteString & rBasicPostfix )
1053 CTOR
1055 // aSbxDataType = (int)nT;
1056 SetName( rName );
1057 aSbxName = rSbxName;
1058 aOdlName = rOdlName;
1059 cParserChar = cPc;
1060 aCName = rCName;
1061 aBasicName = rBasicName;
1062 aBasicPostfix = rBasicPostfix;
1065 void SvMetaType::Load( SvPersistStream & rStm )
1067 SvMetaExtern::Load( rStm );
1069 USHORT nMask;
1070 rStm >> nMask;
1071 if( nMask & 0x0001 ) rStm >> aIn;
1072 if( nMask & 0x0002 ) rStm >> aOut;
1073 if( nMask & 0x0004 ) rStm >> aCall0;
1074 if( nMask & 0x0008 ) rStm >> aCall1;
1075 if( nMask & 0x0010 ) rStm >> aSbxDataType;
1076 if( nMask & 0x0020 ) rStm >> aSvName;
1077 if( nMask & 0x0040 ) rStm >> aSbxName;
1078 if( nMask & 0x0080 ) rStm >> aOdlName;
1079 if( nMask & 0x0100 ) rStm >> GetAttrList();
1080 if( nMask & 0x0200 ) bIsItem = TRUE;
1081 if( nMask & 0x0400 ) bIsShell = TRUE;
1082 if( nMask & 0x0800 )
1084 USHORT nT;
1085 rStm >> nT;
1086 nType = nT;
1088 if( nMask & 0x1000 ) rStm >> cParserChar;
1089 if( nMask & 0x2000 ) rStm >> aCName;
1090 if( nMask & 0x4000 ) rStm >> aBasicName;
1091 if( nMask & 0x8000 ) rStm >> aBasicPostfix;
1094 void SvMetaType::Save( SvPersistStream & rStm )
1096 SvMetaExtern::Save( rStm );
1098 // Maske erstellen
1099 USHORT nMask = 0;
1100 if( aIn.IsSet() ) nMask |= 0x0001;
1101 if( aOut.IsSet() ) nMask |= 0x0002;
1102 if( aCall0.IsSet() ) nMask |= 0x0004;
1103 if( aCall1.IsSet() ) nMask |= 0x0008;
1104 if( aSbxDataType.IsSet() ) nMask |= 0x0010;
1105 if( aSvName.IsSet() ) nMask |= 0x0020;
1106 if( aSbxName.IsSet() ) nMask |= 0x0040;
1107 if( aOdlName.IsSet() ) nMask |= 0x0080;
1108 if( GetAttrCount() ) nMask |= 0x0100;
1109 if( bIsItem ) nMask |= 0x0200;
1110 if( bIsShell ) nMask |= 0x0400;
1111 if( nType != TYPE_BASE ) nMask |= 0x0800;
1112 if( cParserChar != 'h' ) nMask |= 0x1000;
1113 if( aCName.IsSet() ) nMask |= 0x2000;
1114 if( aBasicName.IsSet() ) nMask |= 0x4000;
1115 if( aBasicPostfix.IsSet() ) nMask |= 0x8000;
1117 // Daten schreiben
1118 rStm << nMask;
1119 if( nMask & 0x0001 ) rStm << aIn;
1120 if( nMask & 0x0002 ) rStm << aOut;
1121 if( nMask & 0x0004 ) rStm << aCall0;
1122 if( nMask & 0x0008 ) rStm << aCall1;
1123 if( nMask & 0x0010 ) rStm << aSbxDataType;
1124 if( nMask & 0x0020 ) rStm << aSvName;
1125 if( nMask & 0x0040 ) rStm << aSbxName;
1126 if( nMask & 0x0080 ) rStm << aOdlName;
1127 if( nMask & 0x0100 ) rStm << *pAttrList;
1128 if( nMask & 0x0800 ) rStm << (USHORT)nType;
1129 if( nMask & 0x1000 ) rStm << cParserChar;
1130 if( nMask & 0x2000 ) rStm << aCName;
1131 if( nMask & 0x4000 ) rStm << aBasicName;
1132 if( nMask & 0x8000 ) rStm << aBasicPostfix;
1135 /*************************************************************************
1136 |* SvMetaType::GetAttrList()
1138 |* Beschreibung
1139 *************************************************************************/
1140 SvMetaAttributeMemberList & SvMetaType::GetAttrList() const
1142 if( !pAttrList )
1143 ((SvMetaType *)this)->pAttrList = new SvMetaAttributeMemberList();
1144 return *pAttrList;
1147 /*************************************************************************
1148 |* SvMetaType::SetType()
1150 |* Beschreibung
1151 *************************************************************************/
1152 void SvMetaType::SetType( int nT )
1154 nType = nT;
1155 if( nType == TYPE_ENUM )
1157 aOdlName = "short";
1158 // aSbxDataType = SbxINTEGER;
1160 else if( nType == TYPE_CLASS )
1162 aCName = C_PREF;
1163 aCName += "Object *";
1167 /*************************************************************************
1168 |* SvMetaType::GetBaseType()
1170 |* Beschreibung
1171 *************************************************************************/
1172 SvMetaType * SvMetaType::GetBaseType() const
1174 if( GetRef() && GetType() == TYPE_BASE )
1175 return ((SvMetaType *)GetRef())->GetBaseType();
1176 return (SvMetaType *)this;
1179 /*************************************************************************
1180 |* SvMetaType::GetReturnType()
1182 |* Beschreibung
1183 *************************************************************************/
1184 SvMetaType * SvMetaType::GetReturnType() const
1186 DBG_ASSERT( GetType() == TYPE_METHOD, "no method" );
1187 DBG_ASSERT( GetRef(), "no return type" );
1188 return (SvMetaType *)GetRef();
1191 /*************************************************************************
1192 |* SvMetaType::GetSbxDataType()
1194 |* Beschreibung
1195 *************************************************************************/
1197 SbxDataType SvMetaType::GetSbxDataType() const
1199 if( aSbxDataType.IsSet() || !GetRef() )
1200 return (SbxDataType)(int)aSbxDataType;
1201 else
1202 return ((SvMetaType *)GetRef())->GetSbxDataType();
1205 /*************************************************************************
1206 |* SvMetaType::GetBasicName()
1208 |* Beschreibung
1209 *************************************************************************/
1210 const ByteString& SvMetaType::GetBasicName() const
1212 if( aBasicName.IsSet() || !GetRef() )
1213 return aBasicName;
1214 else
1215 return ((SvMetaType*)GetRef())->GetBasicName();
1218 /*************************************************************************
1219 |* SvMetaType::GetBasicPostfix()
1221 |* Beschreibung
1222 *************************************************************************/
1223 ByteString SvMetaType::GetBasicPostfix() const
1226 ByteString aRet;
1228 // MBN und Co wollen immer "As xxx"
1230 if( aBasicPostfix.IsSet() || !GetRef() )
1231 aRet = aBasicPostfix;
1232 else
1233 aRet = ((SvMetaType*)GetRef())->GetBasicPostfix();
1235 if ( !aRet.Len() && GetBasicName().Len() )
1239 aRet = " As ";
1240 aRet += GetBasicName();
1243 return aRet;
1246 /*************************************************************************
1247 |* SvMetaType::GetIn()
1249 |* Beschreibung
1250 *************************************************************************/
1251 BOOL SvMetaType::GetIn() const
1253 if( aIn.IsSet() || !GetRef() )
1254 return aIn;
1255 else
1256 return ((SvMetaType *)GetRef())->GetIn();
1259 /*************************************************************************
1260 |* SvMetaType::GetOut()
1262 |* Beschreibung
1263 *************************************************************************/
1264 BOOL SvMetaType::GetOut() const
1266 if( aOut.IsSet() || !GetRef() )
1267 return aOut;
1268 else
1269 return ((SvMetaType *)GetRef())->GetOut();
1272 /*************************************************************************
1273 |* SvMetaType::SetCall0()
1275 |* Beschreibung
1276 *************************************************************************/
1277 void SvMetaType::SetCall0( int e )
1279 aCall0 = (int)e;
1280 if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
1282 if( GetType() == TYPE_POINTER )
1283 SetType( TYPE_BASE );
1285 else
1287 DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
1288 "set no base type to pointer" );
1289 SetType( TYPE_POINTER );
1293 /*************************************************************************
1294 |* SvMetaType::GetCall0()
1296 |* Beschreibung
1297 *************************************************************************/
1298 int SvMetaType::GetCall0() const
1300 if( aCall0.IsSet() || !GetRef() )
1301 return aCall0;
1302 else
1303 return ((SvMetaType *)GetRef())->GetCall0();
1306 /*************************************************************************
1307 |* SvMetaType::SetCall1()
1309 |* Beschreibung
1310 *************************************************************************/
1311 void SvMetaType::SetCall1( int e )
1313 aCall1 = (int)e;
1314 if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE )
1316 if( GetType() == TYPE_POINTER )
1317 SetType( TYPE_BASE );
1319 else
1321 DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE,
1322 "set no base type to pointer" );
1323 SetType( TYPE_POINTER );
1327 /*************************************************************************
1328 |* SvMetaType::GetCall1()
1330 |* Beschreibung
1331 *************************************************************************/
1332 int SvMetaType::GetCall1() const
1334 if( aCall1.IsSet() || !GetRef() )
1335 return aCall1;
1336 else
1337 return ((SvMetaType *)GetRef())->GetCall1();
1340 /*************************************************************************
1341 |* SvMetaType::GetSvName()
1343 |* Beschreibung
1344 *************************************************************************/
1345 const ByteString & SvMetaType::GetSvName() const
1347 if( aSvName.IsSet() || !GetRef() )
1348 return aSvName;
1349 else
1350 return ((SvMetaType *)GetRef())->GetSvName();
1353 /*************************************************************************
1354 |* SvMetaType::GetSbxName()
1356 |* Beschreibung
1357 *************************************************************************/
1358 const ByteString & SvMetaType::GetSbxName() const
1360 if( aSbxName.IsSet() || !GetRef() )
1361 return aSbxName;
1362 else
1363 return ((SvMetaType *)GetRef())->GetSbxName();
1366 /*************************************************************************
1367 |* SvMetaType::GetOdlName()
1369 |* Beschreibung
1370 *************************************************************************/
1371 const ByteString & SvMetaType::GetOdlName() const
1373 if( aOdlName.IsSet() || !GetRef() )
1374 return aOdlName;
1375 else
1376 return ((SvMetaType *)GetRef())->GetOdlName();
1379 /*************************************************************************
1380 |* SvMetaType::GetCName()
1382 |* Beschreibung
1383 *************************************************************************/
1384 const ByteString & SvMetaType::GetCName() const
1386 if( aCName.IsSet() || !GetRef() )
1387 return aCName;
1388 else
1389 return ((SvMetaType *)GetRef())->GetCName();
1392 /*************************************************************************
1393 |* SvMetaType::SetName()
1395 |* Beschreibung
1396 *************************************************************************/
1397 BOOL SvMetaType::SetName( const ByteString & rName, SvIdlDataBase * pBase )
1399 aSvName = rName;
1400 aSbxName = rName;
1401 aCName = rName;
1402 if( GetType() != TYPE_ENUM )
1403 aOdlName = rName;
1404 return SvMetaReference::SetName( rName, pBase );
1407 /*************************************************************************
1408 |* SvMetaType::FillSbxObject()
1410 |* Beschreibung
1411 *************************************************************************/
1413 void SvMetaType::FillSbxObject( SbxVariable * pObj, BOOL bVariable )
1415 if( PTR_CAST( SbxMethod, pObj ) )
1417 if( GetType() == TYPE_METHOD )
1419 ULONG nCount = GetAttrCount();
1420 if( nCount )
1422 SbxInfoRef xInfo = pObj->GetInfo();
1423 if( !xInfo.Is() )
1425 xInfo = new SbxInfo();
1426 pObj->SetInfo( xInfo );
1428 for( ULONG n = nCount; n > 0; n-- )
1429 pAttrList->GetObject( n -1 )->FillSbxObject( xInfo );
1435 #ifdef IDL_COMPILER
1436 /*************************************************************************
1437 |* SvMetaType::GetString()
1439 |* Beschreibung
1440 *************************************************************************/
1441 ByteString SvMetaType::GetCString() const
1443 ByteString out( GetSvName() );
1444 if( aCall0 == (int)CALL_POINTER )
1445 out += " *";
1446 else if( aCall0 == (int)CALL_REFERENCE )
1447 out += " &";
1448 if( aCall1 == (int)CALL_POINTER )
1449 out += '*';
1450 else if( aCall1 == (int)CALL_REFERENCE )
1451 out += '&';
1452 return out;
1455 /*************************************************************************
1456 |* SvMetaType::ReadHeaderSvIdl()
1458 |* Beschreibung
1459 *************************************************************************/
1460 BOOL SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase,
1461 SvTokenStream & rInStm )
1463 BOOL bOk = FALSE;
1464 UINT32 nTokPos = rInStm.Tell();
1465 SvToken * pTok = rInStm.GetToken_Next();
1467 if( pTok->Is( SvHash_interface() )
1468 || pTok->Is( SvHash_shell() ) )
1470 if( pTok->Is( SvHash_shell() ) )
1471 bIsShell = TRUE;
1472 SetType( TYPE_CLASS );
1473 bOk = ReadNamesSvIdl( rBase, rInStm );
1476 else if( pTok->Is( SvHash_struct() ) )
1478 SetType( TYPE_STRUCT );
1479 bOk = ReadNamesSvIdl( rBase, rInStm );
1481 else if( pTok->Is( SvHash_union() ) )
1483 SetType( TYPE_UNION );
1484 if( ReadNameSvIdl( rBase, rInStm ) )
1485 return TRUE;
1487 else if( pTok->Is( SvHash_enum() ) )
1489 SetType( TYPE_ENUM );
1490 bOk = ReadNameSvIdl( rBase, rInStm );
1492 else if( pTok->Is( SvHash_typedef() )
1493 || pTok->Is( SvHash_item() ) )
1495 if( pTok->Is( SvHash_item() ) )
1496 bIsItem = TRUE;
1498 SvMetaType * pType = rBase.ReadKnownType( rInStm );
1499 if( pType )
1501 SetRef( pType );
1502 if( ReadNameSvIdl( rBase, rInStm ) )
1504 /* // um aufwaertskompatibel zu bleiben
1505 aOdlName = pType->GetOdlName();
1507 if( rInStm.Read( '(' ) )
1509 //DoReadContextSvIdl( rBase, rInStm, ',' );
1510 DoReadContextSvIdl( rBase, rInStm );
1511 if( rInStm.Read( ')' ) )
1513 SetType( TYPE_METHOD );
1514 bOk = TRUE;
1517 else
1519 bOk = TRUE;
1523 else
1525 ByteString aStr = "wrong typedef: ";
1526 rBase.SetError( aStr, rInStm.GetToken() );
1527 rBase.WriteError( rInStm );
1530 if( bOk )
1531 SetModule( rBase );
1532 else
1533 rInStm.Seek( nTokPos );
1534 return bOk;
1537 /*************************************************************************
1538 |* SvMetaType::ReadSvIdl()
1540 |* Beschreibung
1541 *************************************************************************/
1542 BOOL SvMetaType::ReadSvIdl( SvIdlDataBase & rBase,
1543 SvTokenStream & rInStm )
1545 if( ReadHeaderSvIdl( rBase, rInStm ) )
1547 rBase.Write( '.' );
1548 return SvMetaExtern::ReadSvIdl( rBase, rInStm );
1550 return FALSE;
1553 /*************************************************************************
1554 |* SvMetaType::WriteSvIdl()
1556 |* Beschreibung
1557 *************************************************************************/
1558 void SvMetaType::WriteSvIdl
1560 SvIdlDataBase & rBase,
1561 SvStream & rOutStm,
1562 USHORT nTab
1565 WriteHeaderSvIdl( rBase, rOutStm, nTab );
1566 if( GetType() == TYPE_METHOD )
1567 WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL );
1569 ULONG nOldPos = rOutStm.Tell();
1570 rOutStm << endl;
1571 SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab );
1572 if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) )
1573 // nichts geschrieben
1574 rOutStm.Seek( nOldPos );
1575 rOutStm << ';' << endl;
1578 /*************************************************************************
1579 |* SvMetaType::WriteContext()
1581 |* Beschreibung
1582 *************************************************************************/
1583 void SvMetaType::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
1584 USHORT nTab,
1585 WriteType nT, WriteAttribute nA )
1587 if( GetAttrCount() )
1589 SvMetaAttribute * pAttr = pAttrList->First();
1590 while( pAttr )
1592 pAttr->Write( rBase, rOutStm, nTab, nT, nA );
1593 if( GetType() == TYPE_METHOD )
1594 rOutStm << ',' << endl;
1595 else
1596 rOutStm << ';' << endl;
1597 pAttr = pAttrList->Next();
1602 /*************************************************************************
1603 |* SvMetaType::Write()
1605 |* Beschreibung
1606 *************************************************************************/
1607 void SvMetaType::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
1608 USHORT nTab,
1609 WriteType nT, WriteAttribute nA )
1611 if( nT == WRITE_C_HEADER && nType != TYPE_ENUM )
1612 // nur enum schreiben
1613 return;
1615 ByteString name = GetName();
1616 if( nT == WRITE_ODL || nT == WRITE_C_HEADER || nT == WRITE_CXX_HEADER )
1618 switch( nType )
1620 case TYPE_CLASS:
1623 break;
1624 case TYPE_STRUCT:
1625 case TYPE_UNION:
1626 case TYPE_ENUM:
1628 WriteStars( rOutStm );
1629 if( nType == TYPE_STRUCT || nType == TYPE_UNION )
1630 nA = WA_STRUCT;
1632 if( nT == WRITE_ODL || nT == WRITE_C_HEADER)
1634 if ( nT == WRITE_C_HEADER )
1636 ByteString aStr = name;
1637 aStr.ToUpperAscii();
1638 rOutStm << "#ifndef " << C_PREF << aStr.GetBuffer() << "_DEF " << endl;
1639 rOutStm << "#define " << C_PREF << aStr.GetBuffer() << "_DEF " << endl;
1642 WriteTab( rOutStm, nTab );
1643 rOutStm << "typedef" << endl;
1644 if ( nT == WRITE_ODL )
1645 SvMetaName::Write( rBase, rOutStm, nTab, nT, nA );
1647 WriteTab( rOutStm, nTab );
1648 if( nType == TYPE_STRUCT )
1649 rOutStm << "struct";
1650 else if( nType == TYPE_UNION )
1651 rOutStm << "union";
1652 else
1653 rOutStm << "enum";
1654 if( nT != WRITE_ODL && nT != WRITE_C_HEADER)
1655 rOutStm << ' ' << name.GetBuffer();
1657 rOutStm << endl;
1658 WriteTab( rOutStm, nTab );
1659 rOutStm << '{' << endl;
1660 WriteContext( rBase, rOutStm, nTab +1, nT, nA );
1661 WriteTab( rOutStm, nTab );
1662 rOutStm << '}';
1663 if( nT == WRITE_ODL || nT == WRITE_C_HEADER )
1665 rOutStm << ' ' << C_PREF << name.GetBuffer();
1667 rOutStm << ';' << endl;
1669 if ( nT == WRITE_C_HEADER )
1670 rOutStm << "#endif";
1671 rOutStm << endl;
1673 break;
1674 case TYPE_POINTER:
1675 case TYPE_BASE:
1678 break;
1679 case TYPE_METHOD:
1682 break;
1687 /*************************************************************************
1688 |* SvMetaType::ReadNamesSvIdl()
1690 |* Beschreibung
1691 *************************************************************************/
1692 BOOL SvMetaType::ReadNamesSvIdl( SvIdlDataBase & rBase,
1693 SvTokenStream & rInStm )
1695 BOOL bOk = ReadNameSvIdl( rBase, rInStm );
1697 if( bOk )
1699 UINT32 nTokPos = rInStm.Tell();
1700 SvToken * pTok = rInStm.GetToken_Next();
1702 if( pTok->IsIdentifier() )
1704 aSbxName = pTok->GetString();
1706 nTokPos = rInStm.Tell();
1707 pTok = rInStm.GetToken_Next();
1708 if( pTok->IsIdentifier() )
1710 aItemName = pTok->GetString();
1711 nTokPos = rInStm.Tell();
1714 rInStm.Seek( nTokPos );
1717 return bOk;
1720 /*************************************************************************
1721 |* SvMetaType::WriteHeaderSvIdl()
1723 |* Beschreibung
1724 *************************************************************************/
1725 void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase & rBase,
1726 SvStream & rOutStm,
1727 USHORT nTab )
1729 switch( nType )
1731 case TYPE_CLASS:
1733 if( IsShell() )
1734 rOutStm << SvHash_shell()->GetName().GetBuffer();
1735 else
1736 rOutStm << SvHash_interface()->GetName().GetBuffer();
1737 rOutStm << ' ' << GetName().GetBuffer();
1739 break;
1740 case TYPE_STRUCT:
1742 rOutStm << SvHash_struct()->GetName().GetBuffer()
1743 << ' ' << GetName().GetBuffer();
1745 break;
1746 case TYPE_UNION:
1748 rOutStm << SvHash_union()->GetName().GetBuffer()
1749 << ' ' << GetName().GetBuffer();
1751 break;
1752 case TYPE_ENUM:
1754 rOutStm << SvHash_enum()->GetName().GetBuffer()
1755 << ' ' << GetName().GetBuffer();
1757 break;
1758 case TYPE_POINTER:
1759 case TYPE_BASE:
1761 if( IsItem() )
1762 rOutStm << SvHash_item()->GetName().GetBuffer() << ' ';
1763 else
1764 rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' ';
1765 if( GetRef() )
1767 ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1768 rOutStm << ' ';
1770 rOutStm << GetName().GetBuffer();
1772 break;
1773 case TYPE_METHOD:
1775 rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' ';
1776 ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL );
1777 rOutStm << ' ' << GetName().GetBuffer() << "( ";
1778 WriteContextSvIdl( rBase, rOutStm, nTab );
1779 rOutStm << " )";
1781 break;
1785 /*************************************************************************
1786 |* SvMetaType::ReadAttributesSvIdl()
1788 |* Beschreibung
1789 *************************************************************************/
1790 void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase & rBase,
1791 SvTokenStream & rInStm )
1793 SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm );
1794 aSvName.ReadSvIdl( SvHash_SvName(), rInStm );
1795 aSbxName.ReadSvIdl( SvHash_SbxName(), rInStm );
1796 aOdlName.ReadSvIdl( SvHash_OdlName(), rInStm );
1799 /*************************************************************************
1800 |* SvMetaType::WriteAttributesSvIdl()
1802 |* Beschreibung
1803 *************************************************************************/
1804 void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase & rBase,
1805 SvStream & rOutStm,
1806 USHORT nTab )
1808 SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab );
1809 ByteString name = GetName();
1810 if( aSvName != name || aSbxName != name || aOdlName != name )
1812 WriteTab( rOutStm, nTab );
1813 rOutStm << "class SvMetaType" << endl;
1814 if( aSvName != name )
1816 WriteTab( rOutStm, nTab );
1817 aSvName.WriteSvIdl( SvHash_SvName(), rOutStm, nTab );
1818 rOutStm << endl;
1820 if( aSbxName != name )
1822 WriteTab( rOutStm, nTab );
1823 aSbxName.WriteSvIdl( SvHash_SbxName(), rOutStm, nTab );
1824 rOutStm << endl;
1826 if( aOdlName != name )
1828 WriteTab( rOutStm, nTab );
1829 aOdlName.WriteSvIdl( SvHash_OdlName(), rOutStm, nTab );
1830 rOutStm << endl;
1835 /*************************************************************************
1836 |* SvMetaType::ReadContextSvIdl()
1838 |* Beschreibung
1839 *************************************************************************/
1840 void SvMetaType::ReadContextSvIdl( SvIdlDataBase & rBase,
1841 SvTokenStream & rInStm )
1843 SvMetaAttributeRef xAttr = new SvMetaAttribute();
1844 if( xAttr->ReadSvIdl( rBase, rInStm ) )
1846 if( xAttr->Test( rBase, rInStm ) )
1847 GetAttrList().Append( xAttr );
1851 /*************************************************************************
1852 |* SvMetaType::WriteContextSvIdl()
1854 |* Beschreibung
1855 *************************************************************************/
1856 void SvMetaType::WriteContextSvIdl
1858 SvIdlDataBase & rBase,
1859 SvStream & rOutStm,
1860 USHORT nTab
1863 if( GetAttrCount() )
1865 SvMetaAttribute * pAttr = pAttrList->First();
1866 while( pAttr )
1868 WriteTab( rOutStm, nTab );
1869 pAttr->WriteSvIdl( rBase, rOutStm, nTab );
1870 if( GetType() == TYPE_METHOD )
1871 rOutStm << ',' << endl;
1872 else
1873 rOutStm << ';' << endl;
1874 pAttr = pAttrList->Next();
1879 /*************************************************************************
1880 |* SvMetaType::WriteAttributes()
1882 |* Beschreibung
1883 *************************************************************************/
1884 void SvMetaType::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm,
1885 USHORT nTab,
1886 WriteType nT, WriteAttribute nA )
1888 SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA );
1891 /*************************************************************************
1892 |* SvMetaType::MakeSfx()
1894 |* Beschreibung
1895 *************************************************************************/
1896 ULONG SvMetaType::MakeSfx( ByteString * pAttrArray )
1898 ULONG nC = 0;
1900 if( GetBaseType()->GetType() == TYPE_STRUCT )
1902 ULONG nAttrCount = GetAttrCount();
1903 // Die einzelnen Attribute schreiben
1904 for( ULONG n = 0; n < nAttrCount; n++ )
1906 nC += pAttrList->GetObject( n )->MakeSfx( pAttrArray );
1907 if( n +1 < nAttrCount )
1908 *pAttrArray += ", ";
1911 return nC;
1914 void SvMetaType::WriteSfxItem(
1915 const ByteString & rItemName, SvIdlDataBase &, SvStream & rOutStm )
1917 WriteStars( rOutStm );
1918 ByteString aVarName = " a";
1919 aVarName += rItemName;
1920 aVarName += "_Impl";
1922 ByteString aTypeName = "SfxType";
1923 ByteString aAttrArray;
1924 ULONG nAttrCount = MakeSfx( &aAttrArray );
1925 //ULONG nAttrCount = GetAttrCount();
1926 ByteString aAttrCount( ByteString::CreateFromInt32( nAttrCount ) );
1927 aTypeName += aAttrCount;
1929 rOutStm << "extern " << aTypeName.GetBuffer()
1930 << aVarName.GetBuffer() << ';' << endl;
1932 // Den Implementationsteil schreiben
1933 rOutStm << "#ifdef SFX_TYPEMAP" << endl
1934 << aTypeName.GetBuffer() << aVarName.GetBuffer()
1935 << " = " << endl;
1936 rOutStm << '{' << endl
1937 << "\tTYPE(" << rItemName.GetBuffer() << "), "
1938 << aAttrCount.GetBuffer();
1939 if( nAttrCount )
1941 rOutStm << ", { ";
1942 // Die einzelnen Attribute schreiben
1943 rOutStm << aAttrArray.GetBuffer();
1944 rOutStm << " }";
1946 rOutStm << endl << "};" << endl
1947 << "#endif" << endl << endl;
1950 /*************************************************************************
1951 |* SvMetaType::WriteSfx()
1953 |* Beschreibung
1954 *************************************************************************/
1955 void SvMetaType::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
1957 if( IsItem() )
1959 if( GetBaseType()->GetType() == TYPE_STRUCT )
1960 GetBaseType()->WriteSfxItem( GetName(), rBase, rOutStm );
1961 else
1962 WriteSfxItem( GetName(), rBase, rOutStm );
1966 /*************************************************************************
1967 |* SvMetaType::ReadMethodArgs()
1969 |* Beschreibung
1970 *************************************************************************/
1971 BOOL SvMetaType::ReadMethodArgs( SvIdlDataBase & rBase,
1972 SvTokenStream & rInStm )
1974 UINT32 nTokPos = rInStm.Tell();
1975 if( rInStm.Read( '(' ) )
1977 //DoReadContextSvIdl( rBase, rInStm, ',' );
1978 DoReadContextSvIdl( rBase, rInStm );
1979 if( rInStm.Read( ')' ) )
1981 SetType( TYPE_METHOD );
1982 return TRUE;
1985 rInStm.Seek( nTokPos );
1986 return FALSE;
1989 /*************************************************************************
1990 |* SvMetaType::WriteMethodArgs()
1992 |* Beschreibung
1993 *************************************************************************/
1994 void SvMetaType::WriteMethodArgs
1996 SvIdlDataBase & rBase,
1997 SvStream & rOutStm,
1998 USHORT nTab, WriteType nT
2001 if( nT == WRITE_IDL )
2003 if( GetAttrCount() )
2005 rOutStm << endl;
2006 WriteTab( rOutStm, nTab );
2007 rOutStm << '(' << endl;
2009 SvMetaAttribute * pAttr = pAttrList->First();
2010 while( pAttr )
2012 WriteTab( rOutStm, nTab +1 );
2013 pAttr->WriteSvIdl( rBase, rOutStm, nTab +1 );
2014 pAttr = pAttrList->Next();
2015 if( pAttr )
2016 rOutStm << ',' << endl;
2018 rOutStm << endl;
2019 WriteTab( rOutStm, nTab );
2020 rOutStm << ')';
2022 else
2023 rOutStm << "()";
2025 else if ( nT == WRITE_DOCU )
2028 rOutStm << '(';
2029 if( GetAttrCount() )
2031 SvMetaAttribute * pAttr = pAttrList->First();
2032 while( pAttr )
2034 pAttr->WriteParam( rBase, rOutStm, nTab+1, nT );
2035 pAttr = pAttrList->Next();
2036 if( pAttr )
2037 rOutStm << ',';
2038 else
2039 rOutStm << ' ';
2042 rOutStm << ')' << endl;
2044 else
2046 rOutStm << '(';
2047 if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2049 rOutStm << ' ' << C_PREF << "Object h" << rBase.aIFaceName.GetBuffer();
2050 if( GetAttrCount() )
2051 rOutStm << ',';
2052 else
2053 rOutStm << ' ';
2056 if( GetAttrCount() )
2058 rOutStm << endl;
2059 SvMetaAttribute * pAttr = pAttrList->First();
2060 while( pAttr )
2062 switch( nT )
2064 case WRITE_C_HEADER:
2065 case WRITE_C_SOURCE:
2066 case WRITE_ODL:
2068 pAttr->WriteParam( rBase, rOutStm, nTab +1, nT );
2070 break;
2072 default:
2074 DBG_ASSERT( FALSE, "WriteType not implemented" );
2077 pAttr = pAttrList->Next();
2078 if( pAttr )
2079 rOutStm << ',' << endl;
2081 if( nT != WRITE_C_HEADER && nT != WRITE_C_SOURCE )
2083 rOutStm << endl;
2084 WriteTab( rOutStm, nTab +1 );
2086 rOutStm << ' ';
2088 rOutStm << ')';
2092 /*************************************************************************
2093 |* SvMetaType::WriteTypePrefix()
2095 |* Beschreibung
2096 *************************************************************************/
2097 void SvMetaType::WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm,
2098 USHORT nTab, WriteType nT )
2100 switch( nT )
2102 case WRITE_IDL:
2104 if( GetIn() && GetOut() )
2105 rOutStm << SvHash_inout()->GetName().GetBuffer() << ' ';
2106 else if( GetIn() )
2107 rOutStm << SvHash_in()->GetName().GetBuffer() << ' ';
2108 else if( GetOut() )
2109 rOutStm << SvHash_out()->GetName().GetBuffer() << ' ';
2110 rOutStm << GetCString().GetBuffer();
2112 break;
2114 case WRITE_ODL:
2116 BOOL bIn = GetIn();
2117 BOOL bOut = GetOut();
2118 if( bIn || bOut )
2120 if( bIn && bOut )
2121 rOutStm << "[in,out] ";
2122 else if( bIn )
2123 rOutStm << "[in] ";
2124 else if( bOut )
2125 rOutStm << "[out] ";
2128 ByteString out;
2129 if( GetType() == TYPE_METHOD )
2130 out = GetReturnType()->GetBaseType()->GetOdlName();
2131 else
2133 SvMetaType * pBType = GetBaseType();
2134 out = pBType->GetOdlName();
2136 if( aCall0 == (int)CALL_POINTER
2137 || aCall0 == (int)CALL_REFERENCE )
2138 rOutStm << " *";
2139 if( aCall1 == (int)CALL_POINTER
2140 || aCall1 == (int)CALL_REFERENCE )
2141 rOutStm << " *";
2142 rOutStm << out.GetBuffer();
2144 break;
2146 case WRITE_C_HEADER:
2147 case WRITE_C_SOURCE:
2148 case WRITE_CXX_HEADER:
2149 case WRITE_CXX_SOURCE:
2152 SvMetaType * pBaseType = GetBaseType();
2153 DBG_ASSERT( pBaseType, "no base type for attribute" );
2155 if( pBaseType->GetType() == TYPE_METHOD )
2156 pBaseType->GetReturnType()->WriteTypePrefix(
2157 rBase, rOutStm, nTab, nT );
2158 else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2160 if( TYPE_STRUCT == pBaseType->GetType() )
2161 rOutStm << C_PREF << pBaseType->GetName().GetBuffer()
2162 << " *";
2163 else
2165 if ( pBaseType->GetType() == TYPE_ENUM )
2166 rOutStm << C_PREF;
2167 rOutStm << pBaseType->GetCName().GetBuffer();
2170 else
2172 if( TYPE_STRUCT == pBaseType->GetType() )
2173 rOutStm << pBaseType->GetName().GetBuffer() << " *";
2174 else
2175 rOutStm << pBaseType->GetName().GetBuffer();
2178 break;
2180 case WRITE_DOCU:
2183 SvMetaType * pBaseType = GetBaseType();
2184 DBG_ASSERT( pBaseType, "no base type for attribute" );
2186 if( pBaseType->GetType() == TYPE_METHOD )
2188 pBaseType->GetReturnType()->WriteTypePrefix(
2189 rBase, rOutStm, nTab, nT );
2191 else
2193 if( TYPE_STRUCT == pBaseType->GetType() )
2194 rOutStm << "VARIANT" << pBaseType->GetName().GetBuffer();
2195 else if ( pBaseType->GetType() == TYPE_ENUM )
2196 rOutStm << "integer";
2197 else
2198 rOutStm << pBaseType->GetOdlName().GetBuffer();
2202 default:
2204 DBG_ASSERT( FALSE, "WriteType not implemented" );
2209 /*************************************************************************
2210 |* SvMetaType::WriteTheType()
2212 |* Beschreibung
2213 *************************************************************************/
2214 void SvMetaType::WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm,
2215 USHORT nTab, WriteType nT )
2217 WriteTypePrefix( rBase, rOutStm, nTab, nT );
2218 if( GetType() == TYPE_METHOD )
2219 WriteMethodArgs( rBase, rOutStm, nTab +2, nT );
2222 /*************************************************************************
2223 |* SvMetaType::GetParserString()
2225 |* Beschreibung
2226 *************************************************************************/
2227 ByteString SvMetaType::GetParserString() const
2229 SvMetaType * pBT = GetBaseType();
2230 if( pBT != this )
2231 return pBT->GetParserString();
2233 int type = GetType();
2234 ByteString aPStr;
2236 if( TYPE_METHOD == type || TYPE_STRUCT == type )
2238 ULONG nAttrCount = GetAttrCount();
2239 // Die einzelnen Attribute schreiben
2240 for( ULONG n = 0; n < nAttrCount; n++ )
2242 SvMetaAttribute * pT = pAttrList->GetObject( n );
2243 aPStr += pT->GetType()->GetParserString();
2246 else
2247 aPStr = GetParserChar();
2248 return aPStr;
2251 /*************************************************************************
2252 |* SvMetaType::WriteParamNames()
2254 |* Beschreibung
2255 *************************************************************************/
2256 void SvMetaType::WriteParamNames( SvIdlDataBase & rBase,
2257 SvStream & rOutStm,
2258 const ByteString & rChief )
2260 SvMetaType * pBT = GetBaseType();
2261 if( pBT != this )
2262 pBT->WriteParamNames( rBase, rOutStm, rChief );
2263 else
2265 int type = GetType();
2266 ByteString aPStr;
2268 if( TYPE_METHOD == type || TYPE_STRUCT == type )
2270 ULONG nAttrCount = GetAttrCount();
2271 // Die einzelnen Attribute schreiben
2272 for( ULONG n = 0; n < nAttrCount; n++ )
2274 SvMetaAttribute * pA = pAttrList->GetObject( n );
2275 // Fuer Methoden ist rChief immer ""
2276 ByteString aStr = /*rChief;
2277 if( aStr.Len() )
2278 aStr += "->";
2279 aStr += */pA->GetName();
2280 pA->GetType()->WriteParamNames( rBase, rOutStm, aStr );
2281 if( n +1 < nAttrCount )
2282 rOutStm << ", ";
2285 else
2286 rOutStm << rChief.GetBuffer();
2290 #endif // IDL_COMPILER
2292 /************************************************************************/
2293 /************************************************************************/
2294 SV_IMPL_META_FACTORY1( SvMetaTypeString, SvMetaType );
2295 /*************************************************************************
2297 |* SvMetaTypeString::SvMetaTypeString()
2299 |* Beschreibung
2301 *************************************************************************/
2302 SvMetaTypeString::SvMetaTypeString()
2303 : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" )
2307 void SvMetaTypeString::Load( SvPersistStream & rStm )
2309 SvMetaType::Load( rStm );
2312 void SvMetaTypeString::Save( SvPersistStream & rStm )
2314 SvMetaType::Save( rStm );
2317 /************************************************************************/
2318 /************************************************************************/
2319 SV_IMPL_META_FACTORY1( SvMetaEnumValue, SvMetaName );
2320 /*************************************************************************
2322 |* SvMetaEnumValue::SvMetaEnumValue()
2324 |* Beschreibung
2326 *************************************************************************/
2327 SvMetaEnumValue::SvMetaEnumValue()
2331 void SvMetaEnumValue::Load( SvPersistStream & rStm )
2333 SvMetaName::Load( rStm );
2335 BYTE nMask;
2336 rStm >> nMask;
2337 if( nMask >= 0x02 )
2339 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
2340 DBG_ERROR( "wrong format" );
2341 return;
2343 if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue );
2346 void SvMetaEnumValue::Save( SvPersistStream & rStm )
2348 SvMetaName::Save( rStm );
2350 // Maske erstellen
2351 BYTE nMask = 0;
2352 if( aEnumValue.Len() ) nMask |= 0x01;
2354 // Daten schreiben
2355 rStm << nMask;
2356 if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue );
2359 #ifdef IDL_COMPILER
2360 /*************************************************************************
2362 |* SvMetaEnumValue::ReadSvIdl()
2364 |* Beschreibung
2366 *************************************************************************/
2367 BOOL SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase,
2368 SvTokenStream & rInStm )
2370 if( !ReadNameSvIdl( rBase, rInStm ) )
2371 return FALSE;
2372 return TRUE;
2375 /*************************************************************************
2377 |* SvMetaEnumValue::WriteSvIdl()
2379 |* Beschreibung
2381 *************************************************************************/
2382 void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, USHORT )
2384 rOutStm << GetName().GetBuffer();
2387 /*************************************************************************
2389 |* SvMetaEnumValue::Write()
2391 |* Beschreibung
2393 *************************************************************************/
2394 void SvMetaEnumValue::Write( SvIdlDataBase &, SvStream & rOutStm, USHORT,
2395 WriteType nT, WriteAttribute )
2397 if ( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
2398 rOutStm << C_PREF << GetName().GetBuffer();
2399 else
2400 rOutStm << GetName().GetBuffer();
2402 #endif // IDL_COMPILER
2404 /************************************************************************/
2405 /************************************************************************/
2406 SV_IMPL_META_FACTORY1( SvMetaTypeEnum, SvMetaType );
2407 /*************************************************************************
2409 |* SvMetaTypeEnum::SvMetaTypeEnum()
2411 |* Beschreibung
2413 *************************************************************************/
2414 SvMetaTypeEnum::SvMetaTypeEnum()
2416 SetBasicName( "Integer" );
2419 void SvMetaTypeEnum::Load( SvPersistStream & rStm )
2421 SvMetaType::Load( rStm );
2423 BYTE nMask;
2424 rStm >> nMask;
2425 if( nMask >= 0x04 )
2427 rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
2428 DBG_ERROR( "wrong format" );
2429 return;
2431 if( nMask & 0x01 ) rStm >> aEnumValueList;
2432 if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
2435 void SvMetaTypeEnum::Save( SvPersistStream & rStm )
2437 SvMetaType::Save( rStm );
2439 // Maske erstellen
2440 BYTE nMask = 0;
2441 if( aEnumValueList.Count() ) nMask |= 0x01;
2442 if( aPrefix.Len() ) nMask |= 0x02;
2444 // Daten schreiben
2445 rStm << nMask;
2446 if( nMask & 0x01 ) rStm << aEnumValueList;
2447 if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
2450 /*************************************************************************
2452 |* SvMetaTypeEnum::GetMaxValue()
2454 |* Beschreibung
2456 *************************************************************************/
2458 USHORT SvMetaTypeEnum::GetMaxValue() const
2460 USHORT nMax = 0;
2461 for( ULONG n = 0; n < aEnumValueList.Count(); n++ )
2463 SvMetaEnumValue * pObj = aEnumValueList.GetObject( n );
2464 if( nMax < pObj->GetValue() )
2465 nMax = pObj->GetValue();
2467 return nMax;
2471 #ifdef IDL_COMPILER
2472 /*************************************************************************
2474 |* SvMetaTypeEnum::ReadContextSvIdl()
2476 |* Beschreibung
2478 *************************************************************************/
2479 void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase,
2480 SvTokenStream & rInStm )
2482 UINT32 nTokPos = rInStm.Tell();
2484 SvMetaEnumValueRef aEnumVal = new SvMetaEnumValue();
2485 BOOL bOk = aEnumVal->ReadSvIdl( rBase, rInStm );
2486 if( bOk )
2488 if( 0 == aEnumValueList.Count() )
2489 // der Erste
2490 aPrefix = aEnumVal->GetName();
2491 else
2493 USHORT nPos = aPrefix.Match( aEnumVal->GetName() );
2494 if( nPos != aPrefix.Len() && nPos != STRING_MATCH )
2495 aPrefix.Erase( nPos );
2497 aEnumValueList.Append( aEnumVal );
2499 if( !bOk )
2500 rInStm.Seek( nTokPos );
2503 /*************************************************************************
2505 |* SvMetaTypeEnum::WriteSvIdl()
2507 |* Beschreibung
2509 *************************************************************************/
2510 void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase & rBase,
2511 SvStream & rOutStm,
2512 USHORT nTab )
2514 WriteTab( rOutStm, nTab +1 );
2515 for( ULONG n = 0; n < aEnumValueList.Count(); n++ )
2517 aEnumValueList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
2518 if( n +1 != aEnumValueList.Count() )
2519 rOutStm << ", ";
2520 else
2521 rOutStm << endl;
2525 /*************************************************************************
2527 |* SvMetaTypeEnum::ReadSvIdl()
2529 |* Beschreibung
2531 *************************************************************************/
2532 BOOL SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase & rBase,
2533 SvTokenStream & rInStm )
2535 UINT32 nTokPos = rInStm.Tell();
2536 if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm )
2537 && GetType() == TYPE_ENUM )
2539 if( SvMetaName::ReadSvIdl( rBase, rInStm ) )
2540 return TRUE;
2542 rInStm.Seek( nTokPos );
2543 return FALSE;
2546 /*************************************************************************
2548 |* SvMetaTypeEnum::WriteSvIdl()
2550 |* Beschreibung
2552 *************************************************************************/
2553 void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
2554 USHORT nTab )
2556 WriteHeaderSvIdl( rBase, rOutStm, nTab );
2557 rOutStm << endl;
2558 SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
2559 rOutStm << endl;
2562 /*************************************************************************
2564 |* SvMetaTypeEnum::Write()
2566 |* Beschreibung
2568 *************************************************************************/
2569 void SvMetaTypeEnum::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
2570 USHORT nTab,
2571 WriteType nT, WriteAttribute nA )
2573 SvMetaType::Write( rBase, rOutStm, nTab, nT, nA );
2576 /*************************************************************************
2577 |* SvMetaTypeEnum::WriteContext()
2579 |* Beschreibung
2580 *************************************************************************/
2581 void SvMetaTypeEnum::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm,
2582 USHORT nTab,
2583 WriteType nT, WriteAttribute nA )
2585 WriteTab( rOutStm, nTab +1 );
2586 for( ULONG n = 0; n < aEnumValueList.Count(); n++ )
2588 aEnumValueList.GetObject( n )->Write( rBase, rOutStm, nTab +1, nT, nA );
2590 if( n +1 != aEnumValueList.Count() )
2592 if( 2 == n % 3 )
2594 rOutStm << ',' << endl;
2595 WriteTab( rOutStm, nTab +1 );
2597 else
2598 rOutStm << ",\t";
2600 else
2601 rOutStm << endl;
2603 rOutStm << endl;
2606 #endif // IDL_COMPILER
2608 /************************************************************************/
2609 /************************************************************************/
2610 SV_IMPL_META_FACTORY1( SvMetaTypevoid, SvMetaType );
2611 /*************************************************************************
2613 |* SvMetaTypevoid::SvMetaTypevoid()
2615 |* Beschreibung
2617 *************************************************************************/
2618 SvMetaTypevoid::SvMetaTypevoid()
2619 : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" )
2623 void SvMetaTypevoid::Load( SvPersistStream & rStm )
2625 SvMetaType::Load( rStm );
2628 void SvMetaTypevoid::Save( SvPersistStream & rStm )
2630 SvMetaType::Save( rStm );
2633 ByteString SvMetaAttribute::Compare( SvMetaAttribute* pAttr )
2635 ByteString aStr;
2637 if ( aType.Is() )
2639 if ( aType->GetType() == TYPE_METHOD )
2641 // Nur testen, wenn das Attribut eine Methode ist, nicht wenn es
2642 // eine hat !!
2643 if ( !pAttr->GetType()->GetType() == TYPE_METHOD )
2644 aStr += " IsMethod\n";
2645 else if ( aType->GetReturnType() &&
2646 aType->GetReturnType()->GetType() != pAttr->GetType()->GetReturnType()->GetType() )
2647 aStr += " ReturnType\n";
2649 if ( aType->GetAttrCount() )
2651 ULONG nCount = aType->GetAttrCount();
2652 SvMetaAttributeMemberList& rList = aType->GetAttrList();
2653 SvMetaAttributeMemberList& rOtherList = pAttr->GetType()->GetAttrList();
2654 if ( pAttr->GetType()->GetAttrCount() != nCount )
2656 aStr += " AttributeCount\n";
2658 else
2660 for ( USHORT n=0; n<nCount; n++ )
2662 SvMetaAttribute *pAttr1 = rList.GetObject(n);
2663 SvMetaAttribute *pAttr2 = rOtherList.GetObject(n);
2664 pAttr1->Compare( pAttr2 );
2670 if ( GetType()->GetType() != pAttr->GetType()->GetType() )
2671 aStr += " Type\n";
2673 if ( !GetType()->GetSvName().Equals( pAttr->GetType()->GetSvName() ) )
2674 aStr += " ItemType\n";
2677 if ( GetExport() != pAttr->GetExport() )
2678 aStr += " Export\n";
2680 if ( GetAutomation() != pAttr->GetAutomation() )
2681 aStr += " Automation\n";
2683 if ( GetIsCollection() != pAttr->GetIsCollection() )
2684 aStr += " IsCollection\n";
2686 if ( GetReadOnlyDoc() != pAttr->GetReadOnlyDoc() )
2687 aStr += " ReadOnlyDoc\n";
2689 if ( GetExport() && GetReadonly() != pAttr->GetReadonly() )
2690 aStr += " Readonly\n";
2692 return aStr;
2695 void SvMetaAttribute::WriteCSV( SvIdlDataBase&, SvStream& rStrm )
2697 rStrm << GetType()->GetSvName().GetBuffer() << ' ';
2698 rStrm << GetName().GetBuffer() << ' ';
2699 rStrm << GetSlotId().GetBuffer();