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
3c46c2ca
Commit
3c46c2ca
authored
Jan 09, 2015
by
Sarah Spall
Committed by
Vikram Narayanan
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switching branch
parent
8a1f8a00
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
33 deletions
+79
-33
tools/lcd/idl/ast/scope.cpp
tools/lcd/idl/ast/scope.cpp
+14
-11
tools/lcd/idl/gen/source_gen.cpp
tools/lcd/idl/gen/source_gen.cpp
+42
-0
tools/lcd/idl/include/gen_visitor.h
tools/lcd/idl/include/gen_visitor.h
+4
-3
tools/lcd/idl/include/lcd_idl.h
tools/lcd/idl/include/lcd_idl.h
+3
-0
tools/lcd/idl/test/mod_test.idl
tools/lcd/idl/test/mod_test.idl
+0
-5
tools/lcd/idl/test/rpc_test.idl
tools/lcd/idl/test/rpc_test.idl
+2
-2
tools/lcd/idl/test/test.py
tools/lcd/idl/test/test.py
+14
-12
No files found.
tools/lcd/idl/ast/scope.cpp
View file @
3c46c2ca
...
@@ -45,13 +45,14 @@ Type * RootScope::lookup_symbol(const char * sym, int* err)
...
@@ -45,13 +45,14 @@ Type * RootScope::lookup_symbol(const char * sym, int* err)
std
::
string
temp
=
sym
;
std
::
string
temp
=
sym
;
if
(
this
->
types_
->
find
(
temp
)
==
this
->
types_
->
end
())
if
(
this
->
types_
->
find
(
temp
)
==
this
->
types_
->
end
())
{
{
// printf("looking up %s\n", sym);
// printf("is empty? %d\n", this->types_->size());
*
err
=
0
;
*
err
=
0
;
return
0
;
return
0
;
}
}
else
else
{
*
err
=
1
;
return
(
*
(
this
->
types_
))[
temp
];
return
(
*
(
this
->
types_
))[
temp
];
}
}
}
int
RootScope
::
insert_symbol
(
const
char
*
sym
,
Type
*
value
)
int
RootScope
::
insert_symbol
(
const
char
*
sym
,
Type
*
value
)
...
@@ -67,13 +68,16 @@ int RootScope::insert_symbol(const char* sym, Type * value)
...
@@ -67,13 +68,16 @@ int RootScope::insert_symbol(const char* sym, Type * value)
Type
*
FileScope
::
lookup_symbol
(
const
char
*
sym
,
int
*
err
)
Type
*
FileScope
::
lookup_symbol
(
const
char
*
sym
,
int
*
err
)
{
{
std
::
string
temp
=
sym
;
std
::
string
temp
=
sym
;
// lookup here or root first?
if
(
t
ypes_
->
find
(
temp
)
==
types_
->
end
())
if
(
t
his
->
types_
->
find
(
temp
)
==
this
->
types_
->
end
())
{
{
// error
return
this
->
root_
->
lookup_symbol
(
sym
,
err
);
}
}
else
else
{
*
err
=
1
;
return
(
*
types_
)[
temp
];
return
(
*
types_
)[
temp
];
}
}
}
...
@@ -82,10 +86,9 @@ int FileScope::insert_symbol(const char* sym, Type* value)
...
@@ -82,10 +86,9 @@ int FileScope::insert_symbol(const char* sym, Type* value)
std
::
string
temp
=
sym
;
std
::
string
temp
=
sym
;
// redefinition of something at root scope?
// redefinition of something at root scope?
std
::
pair
<
std
::
map
<
std
::
string
,
Type
*>::
iterator
,
bool
>
ret
;
std
::
pair
<
std
::
map
<
std
::
string
,
Type
*>::
iterator
,
bool
>
ret
;
ret
=
types_
->
insert
(
std
::
pair
<
std
::
string
,
Type
*>
(
temp
,
value
));
// filescope map not rootscope
ret
=
this
->
types_
->
insert
(
std
::
pair
<
std
::
string
,
Type
*>
(
temp
,
value
));
return
ret
.
second
;
return
ret
.
second
;
}
}
FileScope
::
FileScope
(
RootScope
*
root
)
FileScope
::
FileScope
(
RootScope
*
root
)
...
...
tools/lcd/idl/gen/source_gen.cpp
View file @
3c46c2ca
#include "gen_visitor.h"
#include "gen_visitor.h"
SourceVisitor
::
SourceVisitor
(
FILE
*
out
,
int
stub_proxy
)
{
this
->
out_f_
=
out
;
this
->
stub_or_proxy_
=
stub_proxy
;
}
void
SourceVisitor
::
visit
(
File
*
f
)
void
SourceVisitor
::
visit
(
File
*
f
)
{
{
for
(
std
::
vector
<
Rpc
*>::
iterator
it
=
f
->
rpc_defs
()
->
begin
();
it
!=
f
->
rpc_defs
()
->
end
();
it
++
)
{
Rpc
*
r
=
(
Rpc
*
)
*
it
;
r
->
accept
(
this
);
fprintf
(
this
->
out_f_
,
"
\n\n
"
);
}
}
}
void
SourceVisitor
::
visit
(
Rpc
*
r
)
void
SourceVisitor
::
visit
(
Rpc
*
r
)
{
{
Type
*
rt
=
r
->
return_type
();
printf
(
"here in hv hisit rpc
\n
"
);
printf
(
"%d
\n
"
,
rt
->
num
());
rt
->
accept
(
this
);
// this seems unnecessary in this case
const
char
*
name
=
r
->
name
();
fprintf
(
this
->
out_f_
,
" %s("
,
name
);
for
(
std
::
vector
<
Parameter
*>::
iterator
it
=
r
->
parameters
()
->
begin
();
it
!=
r
->
parameters
()
->
end
();
it
++
)
{
Parameter
*
p
=
(
Parameter
*
)
*
it
;
p
->
accept
(
this
);
if
((
it
+
1
)
!=
r
->
parameters
()
->
end
())
fprintf
(
this
->
out_f_
,
", "
);
}
fprintf
(
this
->
out_f_
,
") {
\n
"
);
// print body
// TODO
fprintf
(
this
->
out_f_
,
"}
\n
"
);
}
}
void
SourceVisitor
::
visit
(
Parameter
*
p
)
void
SourceVisitor
::
visit
(
Parameter
*
p
)
{
{
p
->
type
()
->
accept
(
this
);
// print p->name_
fprintf
(
this
->
out_f_
,
" %s"
,
p
->
name
());
}
}
void
SourceVisitor
::
visit
(
ProjectionType
*
p
)
void
SourceVisitor
::
visit
(
ProjectionType
*
p
)
{
{
fprintf
(
this
->
out_f_
,
"%s"
,
p
->
real_type
());
}
}
void
SourceVisitor
::
visit
(
ProjectionField
*
pf
)
void
SourceVisitor
::
visit
(
ProjectionField
*
pf
)
...
@@ -23,12 +58,19 @@ void SourceVisitor::visit(ProjectionField *pf)
...
@@ -23,12 +58,19 @@ void SourceVisitor::visit(ProjectionField *pf)
void
SourceVisitor
::
visit
(
IntegerType
*
it
)
void
SourceVisitor
::
visit
(
IntegerType
*
it
)
{
{
if
(
it
->
unsigned_huh
())
fprintf
(
this
->
out_f_
,
"unsigned "
);
fprintf
(
this
->
out_f_
,
"%s"
,
it
->
type
());
}
}
void
SourceVisitor
::
visit
(
PointerType
*
pt
)
void
SourceVisitor
::
visit
(
PointerType
*
pt
)
{
{
pt
->
type
()
->
accept
(
this
);
fprintf
(
this
->
out_f_
,
"* "
);
}
}
void
SourceVisitor
::
visit
(
Typedef
*
td
)
void
SourceVisitor
::
visit
(
Typedef
*
td
)
{
{
fprintf
(
this
->
out_f_
,
"%s"
,
td
->
alias
());
}
}
tools/lcd/idl/include/gen_visitor.h
View file @
3c46c2ca
...
@@ -35,9 +35,10 @@ class HeaderVisitor : public GenVisitor
...
@@ -35,9 +35,10 @@ class HeaderVisitor : public GenVisitor
class
SourceVisitor
:
public
GenVisitor
class
SourceVisitor
:
public
GenVisitor
{
{
// FILE* out_f_;
FILE
*
out_f_
;
int
stub_or_proxy_
;
// 1 equals stub, 2 equals proxy
public:
public:
SourceVisitor
(
FILE
*
f
);
SourceVisitor
(
FILE
*
out
,
int
stub_proxy
);
virtual
void
visit
(
File
*
f
);
virtual
void
visit
(
File
*
f
);
virtual
void
visit
(
Rpc
*
rpc
);
virtual
void
visit
(
Rpc
*
rpc
);
virtual
void
visit
(
Parameter
*
p
);
virtual
void
visit
(
Parameter
*
p
);
...
...
tools/lcd/idl/include/lcd_idl.h
View file @
3c46c2ca
...
@@ -4,10 +4,13 @@
...
@@ -4,10 +4,13 @@
#include <string>
#include <string>
namespace
Parser
{
namespace
Parser
{
/* filename should be a path to a file */
/* filename should be a path to a file */
extern
const
void
*
parse
(
const
std
::
string
&
filename
,
bool
stats
=
false
);
extern
const
void
*
parse
(
const
std
::
string
&
filename
,
bool
stats
=
false
);
...
...
tools/lcd/idl/test/mod_test.idl
deleted
100644 → 0
View file @
8a1f8a00
module
name
{
projection
super_block
<
struct
super_block
>
{
[
in
]
int
field1
;
}
}
tools/lcd/idl/test/rpc_test.idl
View file @
3c46c2ca
rpc
int
foo
(
capability
cpa
,
char
v1
,
int
v2
)
;
rpc
int
foo
(
int
cpa
,
char
v1
,
int
v2
)
;
rpc
int
bar
(
projection
super_block
*
rp
)
;
rpc
int
bar
(
projection
super_block
*
rp
)
;
tools/lcd/idl/test/test.py
View file @
3c46c2ca
...
@@ -2,23 +2,25 @@
...
@@ -2,23 +2,25 @@
from
os
import
getcwd
,
listdir
from
os
import
getcwd
,
listdir
from
os.path
import
join
from
os.path
import
join
from
subprocess
import
c
all
,
check_output
from
subprocess
import
c
heck_call
,
check_output
,
CalledProcessError
def
main
():
def
main
():
print
(
"in main"
)
current_dir
=
getcwd
(
)
test_dir
=
getcwd
(
)
test_dir
=
join
(
current_dir
,
"test"
)
comp_dir
=
"../compiler"
comp_dir
=
join
(
current_dir
,
"compiler"
)
out_dir
=
join
(
test_dir
,
"out"
)
out_dir
=
join
(
test_dir
,
"out"
)
for
file
in
listdir
(
test_dir
):
for
file
in
listdir
(
test_dir
):
print
(
"in loop: "
+
file
)
if
file
.
endswith
(
".idl"
):
if
file
.
endswith
(
".idl"
):
try
:
try
:
result
=
check_output
([
comp_dir
,
'-header'
,
file
],
timeout
=
2
)
print
(
"in loop: "
+
file
)
print
(
"in try"
)
idl_file
=
join
(
"test"
,
file
)
except
:
out_file
=
join
(
"test"
,
file
+
".h"
)
print
(
"in except"
)
print
(
out_file
)
p
ass
p
rint
(
idl_file
)
check_call
([
comp_dir
,
'-header'
,
idl_file
,
'-out'
,
out_file
])
except
Exception
as
e
:
print
(
"f"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
...
...
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