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
c754c320
Commit
c754c320
authored
Sep 20, 2015
by
Sarah Spall
Committed by
Vikram Narayanan
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commiting to swtich branches
parent
625e3986
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
204 deletions
+66
-204
tools/lcd/idl/code_gen/helper.cpp
tools/lcd/idl/code_gen/helper.cpp
+9
-0
tools/lcd/idl/code_gen/marshal.cpp
tools/lcd/idl/code_gen/marshal.cpp
+14
-87
tools/lcd/idl/code_gen/server.cpp
tools/lcd/idl/code_gen/server.cpp
+26
-0
tools/lcd/idl/code_gen/unmarshal.cpp
tools/lcd/idl/code_gen/unmarshal.cpp
+17
-117
No files found.
tools/lcd/idl/code_gen/helper.cpp
View file @
c754c320
#include "ccst.h"
CCSTPostFixExpr
*
access_variable
(
Variable
*
p
)
{
if
(
p
->
accessor
()
==
0x0
)
{
return
new
CCSTPrimaryExprId
(
p
->
identifier
());
}
return
new
CCSTPostFixExprAccess
(
access_parameter
(
p
->
accessor
()),
accessor
,
p
->
identifier
());
}
CCSTExDeclaration
*
construct_enum
(
File
*
f
)
{
const
char
*
enum_name
=
"todo"
;
...
...
tools/lcd/idl/code_gen/marshal.cpp
View file @
c754c320
#include "ccst.h"
/* driver function */
CCSTCompoundStatement
*
marshal_parameter
(
Parameter
*
p
)
{
MarshalTypeVisitor
*
visitor
=
new
MarshalTypeVisitor
();
return
p
->
get_marshal_info
()
->
accept
(
visitor
);
}
CCSTCompoundStatement
*
MarshalTypeVisitor
::
visit
(
Marshal_projection
*
data
)
CCSTStatement
*
MarshalVariableVisitor
::
visit
(
Variable
*
param
)
{
ProjectionType
*
pt
=
dynamic_cast
<
ProjectionType
*>
(
data
->
get_type
());
Assert
(
pt
!=
0x0
,
"Error: Expected ProjectionType got something else.
\n
"
);
std
::
vector
<
CCSTDeclaration
*>
comp_declarations
;
std
::
vector
<
CCSTStatement
*>
comp_statements
;
std
::
vector
<
Marshal_type
*>
fields
=
data
->
fields
();
for
(
std
::
vector
<
Marshal_type
*>::
iterator
it
=
fields
.
begin
();
it
!=
fields
.
end
();
it
++
)
{
Marshal_type
*
mt
=
*
it
;
std
::
vector
<
CCSTDecSpecifier
*>
type_specifier
=
type
(
mt
->
get_type
());
std
::
vector
<
CCSTInitDeclarator
*>
init_decs
;
if
(
mt
->
get_type
()
->
num
()
==
3
)
{
printf
(
"MDAASDFSADFSA1 is %s
\n
"
,
mt
->
get_name
());
init_decs
.
push_back
(
new
CCSTInitDeclarator
(
new
CCSTDeclarator
(
new
CCSTPointer
()
,
new
CCSTDirectDecId
(
mt
->
get_name
()))
,
new
CCSTInitializer
(
new
CCSTPostFixExprAccess
(
new
CCSTPrimaryExprId
(
data
->
get_name
()),
object_access_t
,
mt
->
get_name
()))));
}
else
{
printf
(
"MTMTMTMTM2 is %s
\n
"
,
mt
->
get_name
());
init_decs
.
push_back
(
new
CCSTInitDeclarator
(
new
CCSTDeclarator
(
0x0
,
new
CCSTDirectDecId
(
mt
->
get_name
()))
,
new
CCSTInitializer
(
new
CCSTPostFixExprAccess
(
new
CCSTPrimaryExprId
(
data
->
get_name
()),
object_access_t
,
mt
->
get_name
()))));
}
comp_declarations
.
push_back
(
new
CCSTDeclaration
(
type_specifier
,
init_decs
));
comp_statements
.
push_back
(
mt
->
accept
(
this
));
}
return
new
CCSTCompoundStatement
(
comp_declarations
,
comp_statements
);
}
CCSTCompoundStatement
*
MarshalTypeVisitor
::
visit
(
Marshal_integer
*
data
)
{
IntegerType
*
t
=
dynamic_cast
<
IntegerType
*>
(
data
->
get_type
());
Assert
(
t
!=
0x0
,
"Error: expected IntegerType got something else.
\n
"
);
if
(
param
->
type
()
==
4
)
{
Assert
(
0
==
1
,
"Error: variable to marshal cannot be of a complex type.
\n
"
);
}
// need register.
int
reg
=
param
->
marshal_info
()
->
get_register
();
const
char
*
func_name
=
access_register_mapping
(
reg
);
std
::
vector
<
CCSTDeclaration
*>
comp_declarations
;
std
::
vector
<
CCSTStatement
*>
comp_statements
;
std
::
vector
<
CCSTAssignExpr
*>
args
;
// register_0((long) param)
std
::
vector
<
CCSTAssignExpr
*>
arguments
;
// type that we are castng to.
std
::
vector
<
CCSTSpecifierQual
*>
spec_quals
;
spec_quals
.
push_back
(
new
CCSTSimpleTypeSpecifier
(
long_t
));
spec_quals
.
push_back
(
new
CCSTSimpleTypeSpecifier
(
long_t
));
args
.
push_back
(
new
CCSTCastExpr
(
new
CCSTTypeName
(
spec_quals
,
0x0
)
,
new
CCSTPrimaryExprId
(
data
->
get_name
())));
CCSTPostFixExprAssnExpr
*
func_call
=
new
CCSTPostFixExprAssnExpr
(
new
CCSTPrimaryExprId
(
store_register_mapping
(
data
->
get_register
()))
,
args
);
comp_statements
.
push_back
(
new
CCSTExprStatement
(
func_call
));
return
new
CCSTCompoundStatement
(
comp_declarations
,
comp_statements
);
arguments
.
push_back
(
new
CCSTCastExpr
(
new
CCSTTypeName
(
spec_quals
,
0x0
)
,
access_variable
(
param
)));
// access here...
// a CCSTExpression/CCSTExprStatement
return
new
CCSTPostFixExprAssnExpr
(
new
CCSTPrimaryExprId
(
func_name
),
arguments
);
}
CCSTCompoundStatement
*
MarshalTypeVisitor
::
visit
(
Marshal_void
*
data
)
{
}
CCSTCompoundStatement
*
MarshalTypeVisitor
::
visit
(
Marshal_typedef
*
data
)
{
}
CCSTCompoundStatement
*
MarshalTypeVisitor
::
visit
(
Marshal_pointer
*
data
)
{
PointerType
*
t
=
dynamic_cast
<
PointerType
*>
(
data
->
get_type
());
Assert
(
t
!=
0x0
,
"Error: expected PointerType got something else.
\n
"
);
Marshal_type
*
pointer_to
=
data
->
get_m_type
();
const
char
*
name
=
pointer_to
->
get_name
();
std
::
vector
<
CCSTDeclaration
*>
comp_declarations
;
std
::
vector
<
CCSTStatement
*>
comp_statements
;
std
::
vector
<
CCSTDecSpecifier
*>
ds
=
type
(
pointer_to
->
get_type
());
std
::
vector
<
CCSTInitDeclarator
*>
id
;
id
.
push_back
(
new
CCSTInitDeclarator
(
new
CCSTDeclarator
(
0x0
,
new
CCSTDirectDecId
(
name
))
,
new
CCSTInitializer
(
new
CCSTUnaryExprCastExpr
(
new
CCSTUnaryOp
(
unary_mult_t
)
,
new
CCSTPrimaryExprId
(
data
->
get_name
())
)
)
));
comp_declarations
.
push_back
(
new
CCSTDeclaration
(
ds
,
id
));
comp_statements
.
push_back
(
pointer_to
->
accept
(
this
));
return
new
CCSTCompoundStatement
(
comp_declarations
,
comp_statements
);
}
tools/lcd/idl/code_gen/server.cpp
View file @
c754c320
...
...
@@ -292,3 +292,29 @@ CCSTFile* generate_server_source(File *file)
return
c_file
;
}
CCSTCompoundStatement
*
create_callee_body
(
Rpc
*
r
)
{
std
::
vector
<
Parameter
*>
parameters
=
r
->
parameters
();
for
(
std
::
vector
<
Parameter
*>::
iterator
it
=
parameters
.
begin
();
it
!=
parameters
.
end
();
it
++
)
{
Parameter
*
p
=
(
Parameter
*
)
*
it
;
if
(
p
->
alloc
())
{
AllocateVariableVisitor
*
worker
=
new
AllocateVariableVisitor
();
p
->
type
()
->
accept
(
worker
);
// allocates space if needed.
}
else
{
// if not alloc must be bind?
// grab from some function.
}
UnmarshalVariableVisitor
*
worker
=
new
UnmarshalVariableVisitor
();
p
->
accept
(
worker
);
}
// make real call.
// for each implicit return, marshal
// marshal explicit return
}
tools/lcd/idl/code_gen/unmarshal.cpp
View file @
c754c320
#include "ccst.h"
CCST
CompoundStatement
*
unmarshal_parameter
(
Parameter
*
p
)
CCST
Statement
*
UnmarshalVariableVisitor
::
visit
(
Variable
*
param
)
{
// create visitor
UnmarshalTypeVisitor
*
visitor
=
new
UnmarshalTypeVisitor
();
return
p
->
get_marshal_info
()
->
accept
(
visitor
);
}
CCSTCompoundStatement
*
UnmarshalTypeVisitor
::
visit
(
Marshal_projection
*
data
,
const
char
*
name
)
{
// loop through fields.
for
(
std
::
vector
<
ProjectionField
*>::
iterator
it
=
pt
->
fields
().
begin
();
pt
->
fields
().
end
();
it
++
)
{
ProjectionField
*
pf
=
*
it
;
}
}
/*
// This code will produce the CAST that unmarshals the params. instead of where it was before
CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_projection *data, const char *name)
{
ProjectionType *pt = dynamic_cast<ProjectionType*>(data->get_type());
Assert(pt != 0x0, "Error: Expected ProjectionType got something else.\n");
for(std::vector<ProjectionField*>::iterator it = pt->fields().begin(); pt->fields().end(); it ++)
{
}
std::vector<CCSTDeclaration*> declarations;
std::vector<CCSTStatement*> statements;
std::vector<CCSTInitDeclarator*> decs;
std::vector<CCSTSpecifierQual*> squal;
squal.push_back(new CCSTStructUnionSpecifier(struct_t, pt->real_type()));
// get register
// pull value out of register.
// ASSUME THE STRUCTURE A VARIABLE BELONGS TO HAS ALREADY BEEN ALLOCATED OR GRABBED.
CCSTTypeName *type_cast = new CCSTTypeName(squal, new CCSTPointer());
std::vector<CCSTAssignExpr*> args;
args.push_back( new CCSTUnaryExprSizeOf( new CCSTTypeName(squal, 0x0)));
CCSTCastExpr *malloc_call = new CCSTCastExpr(type_cast
, new CCSTPostFixExprAssnExpr(new CCSTPrimaryExprId("malloc")
, args) );
// set value to param, which has already been allocated or whatever.
// for example: param = (type) get_reg0();
decs.push_back(new CCSTInitDeclarator(new CCSTDeclarator(0x0
, new CCSTDirectDecId(data->get_name()))
, new CCSTInitializer(new CCSTUnaryExprCastExpr(new CCSTUnaryOp(unary_mult_t) , new CCSTCastExpr(type_cast , malloc_call )))));
int
reg
=
param
->
marshal_info
()
->
get_register
();
const
char
*
func_name
=
store_register_mapping
(
reg
);
declarations.push_back(new CCSTDeclaration(type(pt), decs));
// have malloced space for struct
const char* param_name = data->get_name();
TypeNameVisitor
*
worker
=
new
TypeNameVisitor
();
CCSTTypeName
*
type_name
=
param
->
type
()
->
accept
(
worker
);
std::vector<Marshal_type*> fields = data->fields(); // all of the out fields
for(std::vector<Marshal_type*>::iterator it = fields.begin(); it != fields.end(); it ++)
{
Marshal_type *mt = *it;
const char* field_name = mt->get_name();
CCSTCompoundStatement * cs = mt->accept(this);
statements.push_back(cs);
printf("FIELDLDLFDLFL %s\n", field_name);
CCSTAssignExpr *a = new CCSTAssignExpr(new CCSTPostFixExprAccess( new CCSTPrimaryExprId(param_name)
, object_access_t
, field_name)
, new CCSTAssignOp(equal_t)
, new CCSTPrimaryExprId(field_name));
CCSTExprStatement *assign_field = new CCSTExprStatement(a);
statements.push_back(assign_field);
}
return new CCSTCompoundStatement(declarations, statements);
return
new
CCSTAssignExpr
(
access_variable
(
param
),
new
CCSTAssignOp
(
equal_t
)
,
new
CCSTCastExpr
(
type_name
,
func_name
));
}
*/
CCST
CompoundStatement
*
UnmarshalTypeVisitor
::
visit
(
Marshal_integer
*
data
)
CCST
PostFixExpr
*
access_variable
(
Variable
*
p
)
{
IntegerType
*
t
=
dynamic_cast
<
IntegerType
*>
(
data
->
get_type
());
Assert
(
t
!=
0x0
,
"Error: expected IntegerType got something else.
\n
"
);
std
::
vector
<
CCSTDecSpecifier
*>
specifier
=
type
(
t
);
if
(
p
->
accessor
()
==
0x0
)
{
return
new
CCSTPrimaryExprId
(
p
->
identifier
());
}
std
::
vector
<
CCSTInitDeclarator
*>
decs
;
std
::
vector
<
CCSTAssignExpr
*>
empty_args
;
CCSTPostFixExprAssnExpr
*
func_call
=
new
CCSTPostFixExprAssnExpr
(
new
CCSTPrimaryExprId
(
access_register_mapping
(
data
->
get_register
()))
,
empty_args
);
CCSTInitializer
*
init
=
new
CCSTInitializer
(
new
CCSTCastExpr
(
type_cast
(
t
)
,
func_call
));
decs
.
push_back
(
new
CCSTInitDeclarator
(
new
CCSTDeclarator
(
0x0
,
new
CCSTDirectDecId
(
data
->
get_name
()))
,
init
));
std
::
vector
<
CCSTDeclaration
*>
comp_declarations
;
std
::
vector
<
CCSTStatement
*>
comp_statements
;
comp_declarations
.
push_back
(
new
CCSTDeclaration
(
specifier
,
decs
));
return
new
CCSTCompoundStatement
(
comp_declarations
,
comp_statements
);
return
new
CCSTPostFixExprAccess
(
access_parameter
(
p
->
accessor
()),
accessor
,
p
->
identifier
());
}
CCSTCompoundStatement
*
UnmarshalTypeVisitor
::
visit
(
Marshal_void
*
data
)
{
VoidType
*
pt
=
dynamic_cast
<
VoidType
*>
(
data
->
get_type
());
Assert
(
pt
!=
0x0
,
"Dynamic cast has failed!
\n
"
);
}
CCSTCompoundStatement
*
UnmarshalTypeVisitor
::
visit
(
Marshal_typedef
*
data
)
{
Typedef
*
pt
=
dynamic_cast
<
Typedef
*>
(
data
->
get_type
());
Assert
(
pt
!=
0x0
,
"Dynamic cast has failed!
\n
"
);
}
CCSTCompoundStatement
*
UnmarshalTypeVisitor
::
visit
(
Marshal_pointer
*
data
)
{
PointerType
*
pt
=
dynamic_cast
<
PointerType
*>
(
data
->
get_type
());
Assert
(
pt
!=
0x0
,
"Error: expected PointerType got something else.
\n
"
);
CCSTPointer
*
__p
=
create_pointer
(
count_nested_pointer
(
pt
));
Type
*
inner_t
=
get_non_pointer_type
(
pt
);
std
::
vector
<
CCSTDecSpecifier
*>
specifier
=
type
(
inner_t
);
std
::
vector
<
CCSTInitDeclarator
*>
decs
;
decs
.
push_back
(
new
CCSTInitDeclarator
(
new
CCSTDeclarator
(
__p
,
new
CCSTDirectDecId
(
data
->
get_name
()))
,
new
CCSTInitializer
(
new
CCSTUnaryExprCastExpr
(
new
CCSTUnaryOp
(
unary_bit_and_t
),
new
CCSTPrimaryExprId
(
data
->
get_m_type
()
->
get_name
())))));
CCSTCompoundStatement
*
c
=
data
->
get_m_type
()
->
accept
(
this
);
std
::
vector
<
CCSTDeclaration
*>
comp_declarations
;
comp_declarations
.
push_back
(
new
CCSTDeclaration
(
specifier
,
decs
));
std
::
vector
<
CCSTStatement
*>
comp_statements
;
c
->
add_statement
(
new
CCSTCompoundStatement
(
comp_declarations
,
comp_statements
));
return
c
;
}
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