Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Gestegård Robertz
LabComm
Commits
eac93190
Commit
eac93190
authored
Jan 31, 2015
by
Sven Gestegård Robertz
Browse files
renamed typedef to be consistent with type_binding
parent
9b875283
Changes
8
Show whitespace changes
Inline
Side-by-side
examples/user_types/Decoder.java
View file @
eac93190
...
...
@@ -3,7 +3,7 @@ import java.io.FileInputStream;
import
java.io.InputStream
;
import
se.lth.control.labcomm.DecoderChannel
;
import
se.lth.control.labcomm.Type
d
ef
;
import
se.lth.control.labcomm.Type
D
ef
;
import
se.lth.control.labcomm.TypeBinding
;
public
class
Decoder
...
...
@@ -11,7 +11,7 @@ public class Decoder
twoInts
.
Handler
,
theFirstInt
.
Handler
,
theSecondInt
.
Handler
,
Type
d
ef
.
Handler
,
Type
D
ef
.
Handler
,
TypeBinding
.
Handler
{
...
...
@@ -26,7 +26,7 @@ public class Decoder
twoLines
.
register
(
decoder
,
this
);
theFirstInt
.
register
(
decoder
,
this
);
theSecondInt
.
register
(
decoder
,
this
);
Type
d
ef
.
register
(
decoder
,
this
);
Type
D
ef
.
register
(
decoder
,
this
);
TypeBinding
.
register
(
decoder
,
this
);
try
{
...
...
@@ -45,8 +45,8 @@ public class Decoder
return
"Line from "
+
genPoint
(
l
.
start
)+
" to "
+
genPoint
(
l
.
end
);
}
public
void
handle_Type
d
ef
(
Type
d
ef
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got Type
d
ef: "
+
d
.
getName
()+
"("
+
d
.
getIndex
()+
")"
);
public
void
handle_Type
D
ef
(
Type
D
ef
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got Type
D
ef: "
+
d
.
getName
()+
"("
+
d
.
getIndex
()+
")"
);
}
public
void
handle_TypeBinding
(
TypeBinding
d
)
throws
java
.
io
.
IOException
{
...
...
examples/user_types/example_decoder.c
View file @
eac93190
...
...
@@ -20,8 +20,8 @@ static void handle_test_theSecondInt(int *v,void *context) {
printf
(
"Got theSecondInt. (%d)
\n
"
,
*
v
);
}
static
void
handle_typedef
(
struct
labcomm_raw_typedef
*
v
,
void
*
context
)
{
printf
(
"Got typedef. (0x%x) %s
\n
"
,
v
->
index
,
v
->
name
);
static
void
handle_type
_
def
(
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
)
{
printf
(
"Got type
_
def. (0x%x) %s
\n
"
,
v
->
index
,
v
->
name
);
}
static
void
handle_type_binding
(
struct
labcomm_type_binding
*
v
,
void
*
context
)
{
...
...
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
labcomm_decoder_register_test_theFirstInt
(
decoder
,
handle_test_theFirstInt
,
context
);
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_twoLines
(
decoder
,
handle_test_twoLines
,
context
);
labcomm_decoder_register_labcomm_typedef
(
decoder
,
handle_typedef
,
context
);
labcomm_decoder_register_labcomm_type
_
def
(
decoder
,
handle_type
_
def
,
context
);
labcomm_decoder_register_labcomm_type_binding
(
decoder
,
handle_type_binding
,
context
);
printf
(
"Decoding:
\n
"
);
...
...
lib/c/2014/labcomm_decoder.c
View file @
eac93190
...
...
@@ -182,7 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
return
tag
;
}
#ifdef OLD_
TYPEDEF
_DECODING_TEST_CODE
#ifdef OLD_
type_def
_DECODING_TEST_CODE
static
int
decode_type_binding
(
struct
labcomm_decoder
*
d
,
int
kind
)
{
int
result
;
...
...
@@ -191,12 +191,12 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
result
=
d
->
reader
->
error
;
goto
out
;
}
int
typedef_index
=
labcomm_read_packed32
(
d
->
reader
);
int
type
_
def_index
=
labcomm_read_packed32
(
d
->
reader
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
goto
out
;
}
printf
(
"type_binding: 0x%x -> 0x%x
\n
"
,
sample_index
,
typedef_index
);
printf
(
"type_binding: 0x%x -> 0x%x
\n
"
,
sample_index
,
type
_
def_index
);
out:
return
result
;
}
...
...
@@ -221,7 +221,7 @@ static int decode_type_def(struct labcomm_decoder *d, int kind){
result
=
d
->
reader
->
error
;
goto
free_signature_name
;
}
//printf("got typedef 0x%x : %s, skipping %d signature bytes", remote_index, name, size);
//printf("got type
_
def 0x%x : %s, skipping %d signature bytes", remote_index, name, size);
#if 0
signature.signature = labcomm_memory_alloc(d->memory, 1, signature.size);
if (d->reader->error < 0) {
...
...
@@ -448,8 +448,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
}
else
if
(
remote_index
==
LABCOMM_TYPE_DEF
)
{
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
if
(
result
==
-
ENOENT
)
{
//No handler for typedefs, skip
#ifdef OLD_
TYPEDEF
_DECODING_TEST_CODE
//No handler for type
_
defs, skip
#ifdef OLD_
type_def
_DECODING_TEST_CODE
result
=
decode_type_def
(
d
,
LABCOMM_TYPE_DEF
);
#else
result
=
decoder_skip
(
d
,
length
,
remote_index
);
...
...
@@ -459,7 +459,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
if
(
result
==
-
ENOENT
)
{
//No handler for type_bindings, skip
#ifdef OLD_
TYPEDEF
_DECODING_TEST_CODE
#ifdef OLD_
type_def
_DECODING_TEST_CODE
result
=
decode_type_binding
(
d
,
LABCOMM_TYPE_BINDING
);
#else
result
=
decoder_skip
(
d
,
length
,
remote_index
);
...
...
@@ -545,19 +545,19 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *d,
}
#ifndef LABCOMM_NO_TYPEDECL
//// Code for allowing user code to handle typedefs
//// Code for allowing user code to handle type
_
defs
//// (should perhaps be moved to another file)
static
void
decode_raw_typedef
(
static
void
decode_raw_type
_
def
(
struct
labcomm_reader
*
r
,
void
(
*
handle
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
),
void
*
context
)
{
struct
labcomm_raw_typedef
v
;
struct
labcomm_raw_type
_
def
v
;
v
.
index
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
goto
out
;
}
v
.
name
=
labcomm_read_string
(
r
);
...
...
@@ -580,10 +580,10 @@ free_name:
out:
return
;
}
int
labcomm_decoder_register_labcomm_typedef
(
int
labcomm_decoder_register_labcomm_type
_
def
(
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
),
void
*
context
...
...
@@ -600,7 +600,7 @@ int labcomm_decoder_register_labcomm_typedef(
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
entry
->
remote_index
=
tag
;
entry
->
signature
=
NULL
;
entry
->
decode
=
(
labcomm_decoder_function
)
decode_raw_typedef
;
entry
->
decode
=
(
labcomm_decoder_function
)
decode_raw_type
_
def
;
entry
->
handler
=
(
labcomm_handler_function
)
handler
;
entry
->
context
=
context
;
...
...
@@ -668,7 +668,7 @@ unlock:
return
tag
;
}
//// End typedef handling
//// End type
_
def handling
#endif
int
labcomm_internal_decoder_register
(
...
...
lib/c/2014/labcomm_type_signature.h
View file @
eac93190
...
...
@@ -61,11 +61,11 @@ struct labcomm_signature {
#endif
};
/* a struct for "raw" typedefs, to be used as an intermediate representation
/* a struct for "raw" type
_
defs, to be used as an intermediate representation
* between decoder and signature parser
*/
struct
labcomm_raw_typedef
{
struct
labcomm_raw_type
_
def
{
char
*
name
;
int
index
;
int
length
;
...
...
@@ -85,13 +85,13 @@ struct labcomm_type_binding {
*/
/* register a handler for typedefs and type bindings
/* register a handler for type
_
defs and type bindings
*/
int
labcomm_decoder_register_labcomm_typedef
(
int
labcomm_decoder_register_labcomm_type
_
def
(
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
),
void
*
context
...
...
lib/java/Makefile
View file @
eac93190
...
...
@@ -10,7 +10,7 @@ MODULES=Constant \
SampleDispatcher
\
SampleHandler
\
SampleType
\
Type
d
ef
\
Type
D
ef
\
TypeBinding
\
Writer
\
WriterWrapper
...
...
lib/java/se/lth/control/labcomm/DecoderRegistry.java
View file @
eac93190
...
...
@@ -97,7 +97,7 @@ public class DecoderRegistry {
public
synchronized
void
add
(
SampleDispatcher
dispatcher
,
SampleHandler
handler
)
throws
IOException
{
//XXX kludge: special handling of predefined types
if
(
dispatcher
.
getSampleClass
()
==
Type
d
ef
.
class
){
if
(
dispatcher
.
getSampleClass
()
==
Type
D
ef
.
class
){
Entry
e
=
new
Entry
(
dispatcher
,
handler
);
e
.
setIndex
(
Constant
.
TYPE_DEF
);
byClass
.
put
(
dispatcher
.
getSampleClass
(),
e
);
...
...
lib/java/se/lth/control/labcomm/Typedef.java
View file @
eac93190
...
...
@@ -8,7 +8,7 @@ import se.lth.control.labcomm.DecoderChannel;
import
se.lth.control.labcomm.SampleDispatcher
;
import
se.lth.control.labcomm.SampleHandler
;
public
class
Type
d
ef
implements
SampleType
{
public
class
Type
D
ef
implements
SampleType
{
private
int
index
;
private
String
name
;
private
byte
signature
[];
...
...
@@ -22,14 +22,14 @@ public class Typedef implements SampleType {
}
public
void
dump
()
{
System
.
out
.
print
(
"=== Type
d
ef "
+
getName
()+
"( "
+
Integer
.
toHexString
(
getIndex
())+
") : "
);
System
.
out
.
print
(
"=== Type
D
ef "
+
getName
()+
"( "
+
Integer
.
toHexString
(
getIndex
())+
") : "
);
for
(
byte
b
:
signature
)
{
System
.
out
.
print
(
String
.
format
(
"0x%02X "
,
b
));
}
System
.
out
.
println
();
}
public
interface
Handler
extends
SampleHandler
{
public
void
handle_Type
d
ef
(
Type
d
ef
value
)
throws
Exception
;
public
void
handle_Type
D
ef
(
Type
D
ef
value
)
throws
Exception
;
}
public
static
void
register
(
Decoder
d
,
Handler
h
)
throws
IOException
{
...
...
@@ -44,7 +44,7 @@ public class Typedef implements SampleType {
throw
new
IOException
(
"cannot send TypeDefs"
);
}
static
class
Dispatcher
implements
SampleDispatcher
<
Type
d
ef
>
{
static
class
Dispatcher
implements
SampleDispatcher
<
Type
D
ef
>
{
private
static
Dispatcher
singleton
;
...
...
@@ -53,12 +53,12 @@ public class Typedef implements SampleType {
return
singleton
;
}
public
Class
<
Type
d
ef
>
getSampleClass
()
{
return
Type
d
ef
.
class
;
public
Class
<
Type
D
ef
>
getSampleClass
()
{
return
Type
D
ef
.
class
;
}
public
String
getName
()
{
return
"Type
d
ef"
;
return
"Type
D
ef"
;
}
public
byte
getTypeDeclTag
()
{
...
...
@@ -87,7 +87,7 @@ public class Typedef implements SampleType {
public
void
decodeAndHandle
(
Decoder
d
,
SampleHandler
h
)
throws
Exception
{
((
Handler
)
h
).
handle_Type
d
ef
(
Type
d
ef
.
decode
(
d
));
((
Handler
)
h
).
handle_Type
D
ef
(
Type
D
ef
.
decode
(
d
));
}
public
boolean
hasDependencies
()
{
...
...
@@ -95,18 +95,18 @@ public class Typedef implements SampleType {
}
}
public
static
void
encode
(
Encoder
e
,
Type
d
ef
value
)
throws
IOException
{
public
static
void
encode
(
Encoder
e
,
Type
D
ef
value
)
throws
IOException
{
throw
new
Error
(
"Should not be called"
);
}
public
Type
d
ef
(
int
index
,
String
name
,
byte
sig
[])
{
public
Type
D
ef
(
int
index
,
String
name
,
byte
sig
[])
{
this
.
index
=
index
;
this
.
name
=
name
;
this
.
signature
=
sig
;
}
public
static
Type
d
ef
decode
(
Decoder
d
)
throws
IOException
{
Type
d
ef
result
;
public
static
Type
D
ef
decode
(
Decoder
d
)
throws
IOException
{
Type
D
ef
result
;
int
index
=
d
.
decodePacked32
();
String
name
=
d
.
decodeString
();
int
siglen
=
d
.
decodePacked32
();
...
...
@@ -114,7 +114,7 @@ public class Typedef implements SampleType {
for
(
int
i
=
0
;
i
<
siglen
;
i
++){
sig
[
i
]
=
d
.
decodeByte
();
}
result
=
new
Type
d
ef
(
index
,
name
,
sig
);
result
=
new
Type
D
ef
(
index
,
name
,
sig
);
return
result
;
}
}
...
...
lib/java/se/lth/control/labcomm2006/Typedef.java
View file @
eac93190
public
class
Type
d
ef
{
public
class
Type
D
ef
{
}
Write
Preview
Supports
Markdown
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