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
bc7624d5
Commit
bc7624d5
authored
Oct 29, 2015
by
Sarah Spall
Committed by
Vikram Narayanan
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
committing to switch branches
parent
f1c4147b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
63 deletions
+101
-63
tools/lcd/idl/code_gen/client.cpp
tools/lcd/idl/code_gen/client.cpp
+4
-2
tools/lcd/idl/code_gen/helper.cpp
tools/lcd/idl/code_gen/helper.cpp
+22
-2
tools/lcd/idl/parser/lcd_idl.peg
tools/lcd/idl/parser/lcd_idl.peg
+75
-59
No files found.
tools/lcd/idl/code_gen/client.cpp
View file @
bc7624d5
...
...
@@ -37,11 +37,13 @@ CCSTFile* generate_client_source(Module* f)
// create initialization function
std
::
vector
<
CCSTExDeclaration
*>
definitions
;
for
(
std
::
vector
<
Rpc
*>::
iterator
it
=
f
->
rpc_defs
().
begin
();
it
!=
f
->
rpc_defs
().
end
();
it
++
)
{
Rpc
*
r
=
(
Rpc
*
)
*
it
;
definitions
.
push_back
(
create_function_definition
(
create_
function_declaration
(
r
)
,
create_
caller_body
(
r
)));
definitions
.
push_back
(
function_definition
(
function_declaration
(
r
)
,
caller_body
(
r
)));
}
return
new
CCSTFile
(
definitions
);
...
...
tools/lcd/idl/code_gen/helper.cpp
View file @
bc7624d5
#include "ccst.h"
/*
creates the C code for a container struct
for the projection provided
*/
CCSTDeclaration
*
container_struct
(
const
char
*
name
,
ProjectionType
*
pt
)
{
CCSTStructDeclaration
*
container_field
=
new
CCSTStructDeclaration
();
CCSTStructUnionSpecifier
*
container
=
new
CCSTStructUnionSpecifier
(
struct_t
,
name
,
container_fields
);
std
::
vector
<
CCSTDecSpecifier
*>
struct_specifier
;
struct_specifier
.
push_back
(
container
);
std
::
vector
<
CCSTInitDeclarator
*>
empty
;
return
new
CCSTDeclaration
(
struct_specifier
,
empty
);
}
CCSTPostFixExpr
*
access_variable
(
Variable
*
p
)
{
if
(
p
->
accessor
()
==
0x0
)
{
...
...
@@ -98,7 +118,7 @@ CCSTPointer* create_pointer(int p_count)
* from a function declaration
* and a body
*/
CCSTFuncDef
*
create_
function_definition
(
CCSTDeclaration
*
function_declaration
,
CCSTCompoundStatement
*
body
)
CCSTFuncDef
*
function_definition
(
CCSTDeclaration
*
function_declaration
,
CCSTCompoundStatement
*
body
)
{
Assert
(
function_declaration
->
decs_
.
size
()
==
1
,
"Error: More than one initializer/declarator in function declaration"
);
...
...
@@ -118,7 +138,7 @@ CCSTParamTypeList* create_parameter_list()
/* creates a function declaration
* from an rpc, not callee
*/
CCSTDeclaration
*
create_
function_declaration
(
Rpc
*
r
)
CCSTDeclaration
*
function_declaration
(
Rpc
*
r
)
{
std
::
vector
<
CCSTDecSpecifier
*>
specifier
=
type
(
r
->
explicit_return_type
());
...
...
tools/lcd/idl/parser/lcd_idl.peg
View file @
bc7624d5
...
...
@@ -407,85 +407,101 @@ Projection = "projection" Space+ id:Identifier Spacing "<" Spacing t:Proj_type "
Proj_type = "struct" Space+ id:Identifier Spacing {{
value = id;}}
Keyword = "out" {{ int * x = (int *) malloc(sizeof(int));
*x = 1;
value = x; }}
| "in" {{ int * x = (int *) malloc(sizeof(int));
*x = 2;
value = x; }}
| "bind" {{ int * x = (int *) malloc(sizeof(int));
*x = 3;
value = x; }}
| "alloc" {{ int * x = (int *) malloc(sizeof(int));
*x = 4;
value = x; }}
Keyword = "out" {{
int * x = (int *) malloc(sizeof(int));
*x = 1;
value = x;
}}
| "in" {{
int * x = (int *) malloc(sizeof(int));
*x = 2;
value = x;
}}
| "alloc" Spacing OPEN Spacing "caller" Spacing "," "callee" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 6;
value = x;
}}
| "alloc" Spacing OPEN Spacing "caller" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 4;
value = x;
}}
| "alloc" Spacing OPEN Spacing "callee" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 5;
value = x;
}}
| "alloc" {{
int * x = (int *) malloc(sizeof(int));
*x = 3;
value = x;
}}
Start = k:Keyword Spacing COMMA Spacing {{ value = k; }}
Specification = s:Start* l:Last {{
std::vector<bool>* specs = new std::vector<bool>(4, false);
for(Value::iterator it = s.getValues().begin(); it != s.getValues().end(); it ++)
{
const Value & v = *it;
int* x = (int*) v.getValue();
if(!x)
{
printf("error x is null\n");
exit(0);
}
specs->at(*x -1) = true;
std::vector<bool>* specs = new std::vector<bool>(7, false);
for(Value::iterator it = s.getValues().begin(); it != s.getValues().end(); it ++) {
const Value & v = *it;
int* x = (int*) v.getValue();
if(!x) {
printf("error x is null\n");
exit(0);
}
specs->at(*x) = true;
}
int * y = (int *) l.getValue();
if(!y) { printf("error y is null\n"); exit(0); }
specs->at(*y-1) = true;
value = specs; }}
int * y = (int *) l.getValue();
if(!y) {
printf("error y is null\n"); exit(0);
}
specs->at(*y) = true;
value = specs;
}}
ProjField = t:Type_form Spacing OPENS Spacing s:Specification CLOSES Spacing id:Identifier Spacing SEMI Spacing {{
bool in = false; bool out = false; bool bind = false; bool alloc = false;
std::vector<bool>* specs = (std::vector<bool>*) s.getValue();
int i = 0
;
ProjectionField *pf = new ProjectionField((Type *) t.getValue(), (char *) id.getValue())
;
if(specs->at(0) == true) {
out = true;
}
if(specs->at(1) == true) {
in = true;
}
if(specs->at(2) == true) {
bind = true;
}
if(specs->at(3) == true) {
alloc = true;
pf->set_out(true);
} if(specs->at(2) == true) {
pf->set_in(true);
} if(specs->at(3) == true) {
pf->set_alloc(true);
} if(specs->at(4) == true) {
pf->set_alloc_caller(true);
} if(specs->at(5) == true) {
pf->set_alloc_callee(true);
} if(specs->at(6) == true) {
pf->alloc_callee_caller(true);
}
std::vector<ProjectionField*> *fields = new std::vector<ProjectionField*>();
fields->push_back(
new ProjectionField(in, out, alloc, bind, (Type *) t.getValue(), (char *) id.getValue()))
fields->push_back(
pf);
value = fields;
}}
| "rpc" Space+ rt:Type_form Spacing OPENS Spacing s:Specification CLOSES Spacing OPEN Spacing "*" Spacing id:Identifier CLOSE Spacing OPEN p:FP_Parameters CLOSE SEMI Spacing {{
bool in = false; bool out = false; bool bind = false; bool alloc = false;
std::vector<bool>* specs = (std::vector<bool>*) s.getValue();
printf("In Proj field\n");
int i = 0;
printf("%zu", specs->size());
if(specs->at(0) == true) {
out = true;
}
if(specs->at(1) == true) {
in = true;
}
if(specs->at(2) == true) {
bind = true;
}
if(specs->at(3) == true) {
alloc = true;
FunctionPointer *fp = new FunctionPointer((char*) id.getValue(), (Type*) rt.getValue(), (std::vector<FPParameter*>) *p.getValue());
ProjectionField *pf = new ProjectionField(fp, (char*) id.getValue());
if(specs->at(1) == true) {
pf->set_out(true);
} if(specs->at(2) == true) {
pf->set_in(true);
} if(specs->at(3) == true) {
pf->set_alloc(true);
} if(specs->at(4) == true) {
pf->set_alloc_caller(true);
} if(specs->at(5) == true) {
pf->set_alloc_callee(true);
} if(specs->at(6) == true) {
pf->alloc_callee_caller(true);
}
FunctionPointer *fp = new FunctionPointer((char*) id.getValue(), (Type*) rt.getValue(), (std::vector<FPParameter*>) *p.getValue());
std::vector<ProjectionField*> *fields = new std::vector<ProjectionField*>();
fields->push_back(
new ProjectionField(in, out, alloc, bind, fp, (char*) id.getValue())
);
fields->push_back(
pf
);
value = fields;
}}
| pc_unnamed_scope
...
...
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