Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
ac432839
Kaydet (Commit)
ac432839
authored
Şub 12, 2016
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
move item and struct parsing into SvIdlParser
Change-Id: I1ba88bca82b5b251ed34330ab5e0cb8bd88a5815
üst
d4a10f00
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
81 deletions
+92
-81
parser.hxx
idl/inc/parser.hxx
+6
-0
types.hxx
idl/inc/types.hxx
+3
-5
types.cxx
idl/source/objects/types.cxx
+2
-28
database.cxx
idl/source/prj/database.cxx
+3
-22
parser.cxx
idl/source/prj/parser.cxx
+78
-26
No files found.
idl/inc/parser.hxx
Dosyayı görüntüle @
ac432839
...
...
@@ -26,6 +26,8 @@ class SvTokenStream;
class
SvIdlDataBase
;
class
SvMetaModule
;
class
SvMetaTypeEnum
;
class
SvStringHashEntry
;
class
SvMetaType
;
class
SvIdlParser
{
...
...
@@ -38,12 +40,16 @@ public:
bool
ReadModuleBody
(
SvMetaModule
&
rModule
);
void
ReadModuleElement
(
SvMetaModule
&
rModule
);
void
ReadInclude
(
SvMetaModule
&
rModule
);
void
ReadItem
();
void
ReadStruct
();
void
ReadEnum
();
void
ReadEnumValue
(
SvMetaTypeEnum
&
rEnum
);
SvMetaType
*
ReadKnownType
();
void
ReadChar
(
char
cChar
);
void
ReadDelimiter
();
OString
ReadIdentifier
();
OString
ReadString
();
void
ReadToken
(
SvStringHashEntry
*
);
};
#endif // INCLUDED_IDL_INC_PARSER_HXX
...
...
idl/inc/types.hxx
Dosyayı görüntüle @
ac432839
...
...
@@ -30,13 +30,12 @@ typedef SvRefMemberList< SvMetaSlot* > SvSlotElementList;
class
SvMetaAttribute
:
public
SvMetaReference
{
tools
::
SvRef
<
SvMetaType
>
aType
;
SvIdentifier
aSlotId
;
protected
:
virtual
void
ReadAttributesSvIdl
(
SvIdlDataBase
&
rBase
,
SvTokenStream
&
rInStm
)
override
;
public
:
tools
::
SvRef
<
SvMetaType
>
aType
;
SvIdentifier
aSlotId
;
SvMetaAttribute
();
SvMetaAttribute
(
SvMetaType
*
);
...
...
@@ -81,6 +80,7 @@ public:
MetaTypeType
GetMetaTypeType
()
const
{
return
nType
;
}
SvMetaType
*
GetBaseType
()
const
;
SvMetaType
*
GetReturnType
()
const
;
void
SetItem
(
bool
b
)
{
bIsItem
=
b
;
}
bool
IsItem
()
const
{
return
bIsItem
;
}
virtual
bool
ReadSvIdl
(
SvIdlDataBase
&
,
SvTokenStream
&
rInStm
)
override
;
...
...
@@ -101,8 +101,6 @@ class SvMetaEnumValue : public SvMetaObject
{
public
:
SvMetaEnumValue
();
virtual
bool
ReadSvIdl
(
SvIdlDataBase
&
,
SvTokenStream
&
rInStm
)
override
;
};
class
SvMetaTypeEnum
:
public
SvMetaType
...
...
idl/source/objects/types.cxx
Dosyayı görüntüle @
ac432839
...
...
@@ -74,7 +74,7 @@ bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase,
bOk
=
true
;
SvToken
&
rTok
=
rInStm
.
GetToken
();
if
(
bOk
&&
rTok
.
IsChar
()
&&
rTok
.
GetChar
()
==
'('
)
if
(
rTok
.
IsChar
()
&&
rTok
.
GetChar
()
==
'('
)
{
tools
::
SvRef
<
SvMetaType
>
xT
(
new
SvMetaType
()
);
xT
->
SetRef
(
GetType
()
);
...
...
@@ -164,7 +164,7 @@ SvMetaType * SvMetaType::GetReturnType() const
return
static_cast
<
SvMetaType
*>
(
GetRef
());
}
bool
SvMetaType
::
ReadHeaderSvIdl
(
SvIdlDataBase
&
rBase
,
bool
SvMetaType
::
ReadHeaderSvIdl
(
SvIdlDataBase
&
,
SvTokenStream
&
rInStm
)
{
bool
bOk
=
false
;
...
...
@@ -181,26 +181,6 @@ bool SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase,
SetType
(
MetaTypeType
::
Shell
);
bOk
=
ReadNamesSvIdl
(
rInStm
);
}
else
if
(
rTok
.
Is
(
SvHash_struct
()
)
)
{
SetType
(
MetaTypeType
::
Struct
);
bOk
=
ReadNamesSvIdl
(
rInStm
);
}
else
if
(
rTok
.
Is
(
SvHash_enum
()
)
)
{
SetType
(
MetaTypeType
::
Enum
);
bOk
=
ReadNameSvIdl
(
rInStm
);
}
else
if
(
rTok
.
Is
(
SvHash_item
()
)
)
{
bIsItem
=
true
;
SvMetaType
*
pType
=
rBase
.
ReadKnownType
(
rInStm
);
if
(
!
pType
)
throw
SvParseException
(
rInStm
,
"wrong typedef: "
);
SetRef
(
pType
);
bOk
=
ReadNameSvIdl
(
rInStm
);
}
if
(
!
bOk
)
rInStm
.
Seek
(
nTokPos
);
return
bOk
;
...
...
@@ -344,12 +324,6 @@ SvMetaEnumValue::SvMetaEnumValue()
{
}
bool
SvMetaEnumValue
::
ReadSvIdl
(
SvIdlDataBase
&
,
SvTokenStream
&
rInStm
)
{
return
ReadNameSvIdl
(
rInStm
);
}
SvMetaTypeEnum
::
SvMetaTypeEnum
()
{
}
...
...
idl/source/prj/database.cxx
Dosyayı görüntüle @
ac432839
...
...
@@ -274,34 +274,15 @@ SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm )
sal_uInt32
nTokPos
=
rInStm
.
Tell
();
SvToken
&
rTok
=
rInStm
.
GetToken_Next
();
if
(
rTok
.
HasHash
()
)
{
sal_uInt32
nBeginPos
=
0
;
// can not happen with Tell
while
(
nBeginPos
!=
rInStm
.
Tell
()
)
{
nBeginPos
=
rInStm
.
Tell
();
}
}
if
(
rTok
.
IsIdentifier
()
)
{
OString
aName
=
rTok
.
GetString
();
SvRefMemberList
<
SvMetaType
*>
&
rList
=
GetTypeList
();
SvRefMemberList
<
SvMetaType
*>::
const_iterator
it
=
rList
.
begin
();
SvMetaType
*
pType
=
nullptr
;
while
(
it
!=
rList
.
end
()
)
for
(
const
auto
&
aType
:
GetTypeList
()
)
{
if
(
(
*
it
)
->
GetName
().
equals
(
aName
)
)
if
(
aType
->
GetName
().
equals
(
aName
)
)
{
pType
=
*
it
;
break
;
return
aType
;
}
++
it
;
}
if
(
pType
)
{
// is exactly this type
return
pType
;
}
}
rInStm
.
Seek
(
nTokPos
);
...
...
idl/source/prj/parser.cxx
Dosyayı görüntüle @
ac432839
...
...
@@ -133,16 +133,13 @@ void SvIdlParser::ReadModuleElement( SvMetaModule& rModule )
{
ReadEnum
();
}
else
if
(
rInStm
.
GetToken
().
Is
(
SvHash_item
()
)
||
rInStm
.
GetToken
().
Is
(
SvHash_struct
()
)
)
else
if
(
rInStm
.
GetToken
().
Is
(
SvHash_item
()
)
)
{
tools
::
SvRef
<
SvMetaType
>
xItem
(
new
SvMetaType
()
);
if
(
xItem
->
ReadSvIdl
(
rBase
,
rInStm
)
)
{
// announce globally
rBase
.
GetTypeList
().
push_back
(
xItem
);
}
ReadItem
();
}
else
if
(
rInStm
.
GetToken
().
Is
(
SvHash_struct
()
)
)
{
ReadStruct
();
}
else
if
(
rInStm
.
GetToken
().
Is
(
SvHash_include
()
)
)
{
...
...
@@ -215,10 +212,66 @@ void SvIdlParser::ReadInclude( SvMetaModule& rModule )
rInStm
.
Seek
(
nTokPos
);
}
void
SvIdlParser
::
ReadStruct
()
{
ReadToken
(
SvHash_struct
()
);
rInStm
.
GetToken_Next
();
tools
::
SvRef
<
SvMetaType
>
xStruct
(
new
SvMetaType
()
);
xStruct
->
SetType
(
MetaTypeType
::
Struct
);
xStruct
->
SetName
(
ReadIdentifier
()
);
ReadChar
(
'{'
);
sal_uInt32
nBeginPos
=
0
;
// can not happen with Tell
while
(
nBeginPos
!=
rInStm
.
Tell
()
)
{
nBeginPos
=
rInStm
.
Tell
();
tools
::
SvRef
<
SvMetaAttribute
>
xAttr
(
new
SvMetaAttribute
()
);
xAttr
->
aType
=
ReadKnownType
();
xAttr
->
SetName
(
ReadIdentifier
());
xAttr
->
aSlotId
.
setString
(
ReadIdentifier
());
sal_uLong
n
;
if
(
!
rBase
.
FindId
(
xAttr
->
aSlotId
.
getString
(),
&
n
)
)
throw
SvParseException
(
rInStm
,
"no value for identifier <"
+
xAttr
->
aSlotId
.
getString
()
+
"> "
);
xAttr
->
aSlotId
.
SetValue
(
n
);
xStruct
->
GetAttrList
().
push_back
(
xAttr
);
rInStm
.
ReadIfDelimiter
();
if
(
rInStm
.
GetToken
().
IsChar
()
&&
rInStm
.
GetToken
().
GetChar
()
==
'}'
)
break
;
}
ReadChar
(
'}'
);
// announce globally
rBase
.
GetTypeList
().
push_back
(
xStruct
);
}
void
SvIdlParser
::
ReadItem
()
{
ReadToken
(
SvHash_item
()
);
rInStm
.
GetToken_Next
();
tools
::
SvRef
<
SvMetaType
>
xItem
(
new
SvMetaType
()
);
xItem
->
SetItem
(
true
);
xItem
->
SetRef
(
ReadKnownType
()
);
xItem
->
SetName
(
ReadIdentifier
()
);
// announce globally
rBase
.
GetTypeList
().
push_back
(
xItem
);
}
SvMetaType
*
SvIdlParser
::
ReadKnownType
()
{
OString
aName
=
ReadIdentifier
();
for
(
const
auto
&
aType
:
rBase
.
GetTypeList
()
)
{
if
(
aType
->
GetName
().
equals
(
aName
)
)
{
return
aType
;
}
}
throw
SvParseException
(
rInStm
,
"wrong typedef: "
);
}
void
SvIdlParser
::
ReadEnum
()
{
tools
::
SvRef
<
SvMetaTypeEnum
>
xEnum
(
new
SvMetaTypeEnum
()
);
rInStm
.
GetToken_Next
();
tools
::
SvRef
<
SvMetaTypeEnum
>
xEnum
(
new
SvMetaTypeEnum
()
);
xEnum
->
SetType
(
MetaTypeType
::
Enum
);
xEnum
->
SetName
(
ReadIdentifier
()
);
...
...
@@ -249,25 +302,18 @@ static OString getCommonSubPrefix(const OString &rA, const OString &rB)
void
SvIdlParser
::
ReadEnumValue
(
SvMetaTypeEnum
&
rEnum
)
{
sal_uInt32
nTokPos
=
rInStm
.
Tell
();
tools
::
SvRef
<
SvMetaEnumValue
>
aEnumVal
=
new
SvMetaEnumValue
();
bool
bOk
=
aEnumVal
->
ReadSvIdl
(
rBase
,
rInStm
);
if
(
bOk
)
aEnumVal
->
SetName
(
ReadIdentifier
()
);
if
(
rEnum
.
aEnumValueList
.
empty
()
)
{
if
(
rEnum
.
aEnumValueList
.
empty
()
)
{
// the first
rEnum
.
aPrefix
=
aEnumVal
->
GetName
();
}
else
{
rEnum
.
aPrefix
=
getCommonSubPrefix
(
rEnum
.
aPrefix
,
aEnumVal
->
GetName
());
}
rEnum
.
aEnumValueList
.
push_back
(
aEnumVal
);
// the first
rEnum
.
aPrefix
=
aEnumVal
->
GetName
();
}
if
(
!
bOk
)
rInStm
.
Seek
(
nTokPos
);
else
{
rEnum
.
aPrefix
=
getCommonSubPrefix
(
rEnum
.
aPrefix
,
aEnumVal
->
GetName
());
}
rEnum
.
aEnumValueList
.
push_back
(
aEnumVal
);
}
...
...
@@ -300,4 +346,10 @@ OString SvIdlParser::ReadString()
return
rTok
.
GetString
();
}
void
SvIdlParser
::
ReadToken
(
SvStringHashEntry
*
entry
)
{
if
(
!
rInStm
.
GetToken
().
Is
(
entry
)
)
throw
SvParseException
(
"expected "
+
entry
->
GetName
(),
rInStm
.
GetToken
());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment