Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xcap-capability-linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xcap
xcap-capability-linux
Commits
e2ddc9fa
Commit
e2ddc9fa
authored
Jul 31, 2014
by
Sarah Spall
Committed by
Vikram Narayanan
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just added syntax support for typedef
parent
e775c983
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
16 deletions
+49
-16
tools/lcd/idl/lcd_ast.cpp
tools/lcd/idl/lcd_ast.cpp
+13
-7
tools/lcd/idl/lcd_ast.h
tools/lcd/idl/lcd_ast.h
+15
-3
tools/lcd/idl/lcd_idl.peg
tools/lcd/idl/lcd_idl.peg
+21
-6
No files found.
tools/lcd/idl/lcd_ast.cpp
View file @
e2ddc9fa
...
...
@@ -6,29 +6,29 @@ PrimitiveType::PrimitiveType(TypeModifier type_mod, PrimType primitive)
this
->
primitive_
=
primitive
;
}
ProjectionType
::
ProjectionType
(
char
*
type_name
,
bool
pointer
)
ProjectionType
::
ProjectionType
(
char
*
type_name
,
bool
pointer
)
{
this
->
type_name_
=
type_name
;
this
->
pointer_
=
pointer
;
}
Scope
::
Scope
(
char
*
verbatim
,
std
::
vector
<
Rpc
*
>*
rpc_definitions
,
std
::
vector
<
Message
*
>*
message_definitions
,
std
::
map
<
char
*
,
Projection
*
>*
projection_definitions
)
std
::
map
<
char
*
,
Definition
*
>*
symbol_table
)
{
this
->
verbatim_
=
verbatim
;
this
->
rpc_definitions_
=
rpc_definitions
;
this
->
message_definitions_
=
message_definitions
;
this
->
projection_definitions_
=
projection_definitions
;
this
->
symbol_table__
=
symbol_table
;
}
Rpc
::
Rpc
(
Type
*
return_type
,
char
*
name
,
std
::
vector
<
Parameter
*
>*
parameters
)
Rpc
::
Rpc
(
Type
*
return_type
,
char
*
name
,
std
::
vector
<
Parameter
*
>*
parameters
)
{
this
->
return_type_
=
return_type
;
this
->
name_
=
name
;
this
->
parameters_
=
parameters
;
}
Projection
::
Projection
(
char
*
name
,
char
*
true_type
,
std
::
vector
<
ProjectionField
*
>*
fields
)
Projection
::
Projection
(
char
*
name
,
char
*
true_type
,
std
::
vector
<
ProjectionField
*
>*
fields
)
{
this
->
name_
=
name
;
this
->
true_type_
=
true_type
;
...
...
@@ -51,18 +51,24 @@ Parameter::Parameter(Type* type, char* name)
this
->
name_
=
name
;
}
MessageField
::
MessageField
(
Type
*
field_type
,
char
*
field_name
)
MessageField
::
MessageField
(
Type
*
field_type
,
char
*
field_name
)
{
this
->
field_type_
=
field_type
;
this
->
field_name_
=
field_name
;
}
Message
::
Message
(
char
*
name
,
std
::
vector
<
MessageField
*
>*
fields
)
Message
::
Message
(
char
*
name
,
std
::
vector
<
MessageField
*
>*
fields
)
{
this
->
name_
=
name
;
this
->
fields_
=
fields
;
}
Typedef
::
Typedef
(
char
*
real_type
,
Type
*
marshal_type
,
char
*
typedef_name
)
{
this
->
real_type_
=
real_type
;
this
->
marshal_type_
=
marshal_type
;
this
->
name_
=
typedef_name
;
}
tools/lcd/idl/lcd_ast.h
View file @
e2ddc9fa
...
...
@@ -4,7 +4,7 @@
#include <vector>
#include <map>
enum
DefinitionType
{
kRpc
=
1
,
kModule
,
kMessage
,
kProjection
};
enum
DefinitionType
{
kRpc
=
1
,
kModule
,
kMessage
,
kProjection
,
kTypedef
};
enum
PrimType
{
kChar
=
1
,
kShort
,
kInt
,
kLong
,
kLongLong
,
kCapability
};
enum
TypeModifier
{
kUnsigned
=
1
,
kNone
};
...
...
@@ -47,6 +47,18 @@ class ProjectionType : public Type // complex type
// get full name function? class isn't aware of parent need to pass env
};
class
Typedef
:
public
Definition
{
char
*
real_type_
;
// how should this be represented?
Type
*
marshal_type_
;
// should this be a supported type?
char
*
name_
;
public:
Typedef
(
char
*
real_type
,
Type
*
marshal_type
,
char
*
typedef_name
);
char
*
name
()
{
return
name_
;
}
DefinitionType
get_definition_type
(){
return
kTypedef
;
}
};
class
Parameter
{
Type
*
type_
;
...
...
@@ -126,12 +138,12 @@ class Scope
char
*
verbatim_
;
std
::
vector
<
Rpc
*>*
rpc_definitions_
;
std
::
vector
<
Message
*>*
message_definitions_
;
std
::
map
<
char
*
,
Projection
*>*
projection_definitions
_
;
std
::
map
<
char
*
,
Definition
*>*
symbol_table_
_
;
// believe it is only necessary to store projections in "env" since functions can't be referenced in other functions
public:
Scope
(
char
*
verbatim
,
std
::
vector
<
Rpc
*
>*
rpc_definitions
,
std
::
vector
<
Message
*
>*
message_definitions
,
std
::
map
<
char
*
,
Projection
*
>*
projection_definitions
);
std
::
map
<
char
*
,
Definition
*
>*
symbol_table
);
};
...
...
tools/lcd/idl/lcd_idl.peg
View file @
e2ddc9fa
...
...
@@ -26,10 +26,10 @@ IdentStart = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
IdentCont = IdentStart | [0123456789]
File = Spacing v:Verbatim t:Things* <eof> {{ std::vector<Definition *>* defs = new std::vector<Definition *>;
File = Spacing v:Verbatim
?
t:Things* <eof> {{ std::vector<Definition *>* defs = new std::vector<Definition *>;
std::vector<Rpc *>* rpcs = new std::vector<Rpc *>;
std::vector<Message *>* messages = new std::vector<Message *>;
std::map<char *,
Projection *> *env = new std::map<char *, Projec
tion *>;
std::map<char *,
Definition*> *env = new std::map<char *, Defini
tion *>;
for(Value::iterator it = t.getValues().begin(); it != t.getValues().end(); it ++)
{
const Value & v = *it;
...
...
@@ -56,7 +56,12 @@ File = Spacing v:Verbatim t:Things* <eof> {{ std::vector<Definition *>* defs =
case kProjection:
{
Projection* proj = reinterpret_cast<Projection *>(ds);
env->insert(std::pair<char *, Projection *>(proj->name(), proj));
env->insert(std::pair<char *, Definition *>(proj->name(), ds));
}
case kTypedef:
{
Typedef* td = reinterpret_cast<Typedef*>(ds);
env->insert(std::pair<char*, Definition*>(td->name(), ds));
}
break;
default:
...
...
@@ -68,7 +73,10 @@ File = Spacing v:Verbatim t:Things* <eof> {{ std::vector<Definition *>* defs =
}
value = new Scope((char*) v.getValue(), rpcs, messages, env); }}
Verbatim = "verbatim" Spacing "[" contents:VerbatimContent "]" {{ std::ostringstream total;
Typedef = "typedef" Spacing "<" Spacing rt:RealType Spacing "," Spacing mt:Type Spacing ">" Spacing id:Identifier Spacing {{
value = new Typedef((char*) rt.getValue(), (Type*) mt.getValue(), (char*) id.getValue());}}
Verbatim = "verbatim" Spacing "[" contents:VerbatimContent "]" {{ std::ostringstream total;
for(Value::iterator it = contents.getValues().begin(); it != contents.getValues().end(); it ++)
{
const Value &v = *it;
...
...
@@ -78,7 +86,14 @@ Verbatim = "verbatim" Spacing "[" contents:VerbatimContent "]" {{ std::ostringst
std::string str = total.str();
value = &str[0]; }}
VerbatimContent = !"]" .
VerbatimContent = !"]" .
RealType = fp:Identifier? Spacing sp:Identifier {{ //temporary solution
std::ostringstream total;
total << fp.getValue() << ' ' << sp.getValue();
std::string str = total.str();
value = &str[0];
}}
String = <ascii 34> l:any_letter+ <ascii 34> {{
std::ostringstream total;
...
...
@@ -116,7 +131,7 @@ String = <ascii 34> l:any_letter+ <ascii 34> {{
any_letter = [_.,/?<>'; =:%`!@#$^&*()-+{}|\\ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]
Things = Rpc | Message | Projection
Things =
Typedef |
Rpc | Message | Projection
Include = "#include" Space+ "<" Spacing f:Identifier Spacing ">" Spacing {{
std::ostringstream total;
...
...
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