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
Hide whitespace changes
Inline
Side-by-side
examples/user_types/Decoder.java
View file @
eac93190
...
@@ -3,7 +3,7 @@ import java.io.FileInputStream;
...
@@ -3,7 +3,7 @@ import java.io.FileInputStream;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
se.lth.control.labcomm.DecoderChannel
;
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
;
import
se.lth.control.labcomm.TypeBinding
;
public
class
Decoder
public
class
Decoder
...
@@ -11,7 +11,7 @@ public class Decoder
...
@@ -11,7 +11,7 @@ public class Decoder
twoInts
.
Handler
,
twoInts
.
Handler
,
theFirstInt
.
Handler
,
theFirstInt
.
Handler
,
theSecondInt
.
Handler
,
theSecondInt
.
Handler
,
Type
d
ef
.
Handler
,
Type
D
ef
.
Handler
,
TypeBinding
.
Handler
TypeBinding
.
Handler
{
{
...
@@ -26,7 +26,7 @@ public class Decoder
...
@@ -26,7 +26,7 @@ public class Decoder
twoLines
.
register
(
decoder
,
this
);
twoLines
.
register
(
decoder
,
this
);
theFirstInt
.
register
(
decoder
,
this
);
theFirstInt
.
register
(
decoder
,
this
);
theSecondInt
.
register
(
decoder
,
this
);
theSecondInt
.
register
(
decoder
,
this
);
Type
d
ef
.
register
(
decoder
,
this
);
Type
D
ef
.
register
(
decoder
,
this
);
TypeBinding
.
register
(
decoder
,
this
);
TypeBinding
.
register
(
decoder
,
this
);
try
{
try
{
...
@@ -45,8 +45,8 @@ public class Decoder
...
@@ -45,8 +45,8 @@ public class Decoder
return
"Line from "
+
genPoint
(
l
.
start
)+
" to "
+
genPoint
(
l
.
end
);
return
"Line from "
+
genPoint
(
l
.
start
)+
" to "
+
genPoint
(
l
.
end
);
}
}
public
void
handle_Type
d
ef
(
Type
d
ef
d
)
throws
java
.
io
.
IOException
{
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
()+
")"
);
System
.
out
.
println
(
"Got Type
D
ef: "
+
d
.
getName
()+
"("
+
d
.
getIndex
()+
")"
);
}
}
public
void
handle_TypeBinding
(
TypeBinding
d
)
throws
java
.
io
.
IOException
{
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) {
...
@@ -20,8 +20,8 @@ static void handle_test_theSecondInt(int *v,void *context) {
printf
(
"Got theSecondInt. (%d)
\n
"
,
*
v
);
printf
(
"Got theSecondInt. (%d)
\n
"
,
*
v
);
}
}
static
void
handle_typedef
(
struct
labcomm_raw_typedef
*
v
,
void
*
context
)
{
static
void
handle_type
_
def
(
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
)
{
printf
(
"Got typedef. (0x%x) %s
\n
"
,
v
->
index
,
v
->
name
);
printf
(
"Got type
_
def. (0x%x) %s
\n
"
,
v
->
index
,
v
->
name
);
}
}
static
void
handle_type_binding
(
struct
labcomm_type_binding
*
v
,
void
*
context
)
{
static
void
handle_type_binding
(
struct
labcomm_type_binding
*
v
,
void
*
context
)
{
...
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
...
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
labcomm_decoder_register_test_theFirstInt
(
decoder
,
handle_test_theFirstInt
,
context
);
labcomm_decoder_register_test_theFirstInt
(
decoder
,
handle_test_theFirstInt
,
context
);
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_twoLines
(
decoder
,
handle_test_twoLines
,
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
);
labcomm_decoder_register_labcomm_type_binding
(
decoder
,
handle_type_binding
,
context
);
printf
(
"Decoding:
\n
"
);
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)
...
@@ -182,7 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
return
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
)
static
int
decode_type_binding
(
struct
labcomm_decoder
*
d
,
int
kind
)
{
{
int
result
;
int
result
;
...
@@ -191,12 +191,12 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
...
@@ -191,12 +191,12 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
result
=
d
->
reader
->
error
;
result
=
d
->
reader
->
error
;
goto
out
;
goto
out
;
}
}
int
typedef_index
=
labcomm_read_packed32
(
d
->
reader
);
int
type
_
def_index
=
labcomm_read_packed32
(
d
->
reader
);
if
(
d
->
reader
->
error
<
0
)
{
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
result
=
d
->
reader
->
error
;
goto
out
;
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:
out:
return
result
;
return
result
;
}
}
...
@@ -221,7 +221,7 @@ static int decode_type_def(struct labcomm_decoder *d, int kind){
...
@@ -221,7 +221,7 @@ static int decode_type_def(struct labcomm_decoder *d, int kind){
result
=
d
->
reader
->
error
;
result
=
d
->
reader
->
error
;
goto
free_signature_name
;
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
#if 0
signature.signature = labcomm_memory_alloc(d->memory, 1, signature.size);
signature.signature = labcomm_memory_alloc(d->memory, 1, signature.size);
if (d->reader->error < 0) {
if (d->reader->error < 0) {
...
@@ -448,8 +448,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
...
@@ -448,8 +448,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
}
else
if
(
remote_index
==
LABCOMM_TYPE_DEF
)
{
}
else
if
(
remote_index
==
LABCOMM_TYPE_DEF
)
{
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
if
(
result
==
-
ENOENT
)
{
if
(
result
==
-
ENOENT
)
{
//No handler for typedefs, skip
//No handler for type
_
defs, skip
#ifdef OLD_
TYPEDEF
_DECODING_TEST_CODE
#ifdef OLD_
type_def
_DECODING_TEST_CODE
result
=
decode_type_def
(
d
,
LABCOMM_TYPE_DEF
);
result
=
decode_type_def
(
d
,
LABCOMM_TYPE_DEF
);
#else
#else
result
=
decoder_skip
(
d
,
length
,
remote_index
);
result
=
decoder_skip
(
d
,
length
,
remote_index
);
...
@@ -459,7 +459,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
...
@@ -459,7 +459,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
if
(
result
==
-
ENOENT
)
{
if
(
result
==
-
ENOENT
)
{
//No handler for type_bindings, skip
//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
);
result
=
decode_type_binding
(
d
,
LABCOMM_TYPE_BINDING
);
#else
#else
result
=
decoder_skip
(
d
,
length
,
remote_index
);
result
=
decoder_skip
(
d
,
length
,
remote_index
);
...
@@ -545,19 +545,19 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *d,
...
@@ -545,19 +545,19 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *d,
}
}
#ifndef LABCOMM_NO_TYPEDECL
#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)
//// (should perhaps be moved to another file)
static
void
decode_raw_typedef
(
static
void
decode_raw_type
_
def
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader
*
r
,
void
(
*
handle
)(
void
(
*
handle
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
void
*
context
),
),
void
*
context
void
*
context
)
)
{
{
struct
labcomm_raw_typedef
v
;
struct
labcomm_raw_type
_
def
v
;
v
.
index
=
labcomm_read_packed32
(
r
);
v
.
index
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
goto
out
;
}
if
(
r
->
error
<
0
)
{
goto
out
;
}
v
.
name
=
labcomm_read_string
(
r
);
v
.
name
=
labcomm_read_string
(
r
);
...
@@ -580,10 +580,10 @@ free_name:
...
@@ -580,10 +580,10 @@ free_name:
out:
out:
return
;
return
;
}
}
int
labcomm_decoder_register_labcomm_typedef
(
int
labcomm_decoder_register_labcomm_type
_
def
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
void
(
*
handler
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
void
*
context
),
),
void
*
context
void
*
context
...
@@ -600,7 +600,7 @@ int labcomm_decoder_register_labcomm_typedef(
...
@@ -600,7 +600,7 @@ int labcomm_decoder_register_labcomm_typedef(
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
entry
->
remote_index
=
tag
;
entry
->
remote_index
=
tag
;
entry
->
signature
=
NULL
;
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
->
handler
=
(
labcomm_handler_function
)
handler
;
entry
->
context
=
context
;
entry
->
context
=
context
;
...
@@ -668,7 +668,7 @@ unlock:
...
@@ -668,7 +668,7 @@ unlock:
return
tag
;
return
tag
;
}
}
//// End typedef handling
//// End type
_
def handling
#endif
#endif
int
labcomm_internal_decoder_register
(
int
labcomm_internal_decoder_register
(
...
...
lib/c/2014/labcomm_type_signature.h
View file @
eac93190
...
@@ -61,11 +61,11 @@ struct labcomm_signature {
...
@@ -61,11 +61,11 @@ struct labcomm_signature {
#endif
#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
* between decoder and signature parser
*/
*/
struct
labcomm_raw_typedef
{
struct
labcomm_raw_type
_
def
{
char
*
name
;
char
*
name
;
int
index
;
int
index
;
int
length
;
int
length
;
...
@@ -85,13 +85,13 @@ struct labcomm_type_binding {
...
@@ -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
,
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
void
(
*
handler
)(
struct
labcomm_raw_typedef
*
v
,
struct
labcomm_raw_type
_
def
*
v
,
void
*
context
void
*
context
),
),
void
*
context
void
*
context
...
...
lib/java/Makefile
View file @
eac93190
...
@@ -10,7 +10,7 @@ MODULES=Constant \
...
@@ -10,7 +10,7 @@ MODULES=Constant \
SampleDispatcher
\
SampleDispatcher
\
SampleHandler
\
SampleHandler
\
SampleType
\
SampleType
\
Type
d
ef
\
Type
D
ef
\
TypeBinding
\
TypeBinding
\
Writer
\
Writer
\
WriterWrapper
WriterWrapper
...
...
lib/java/se/lth/control/labcomm/DecoderRegistry.java
View file @
eac93190
...
@@ -97,7 +97,7 @@ public class DecoderRegistry {
...
@@ -97,7 +97,7 @@ public class DecoderRegistry {
public
synchronized
void
add
(
SampleDispatcher
dispatcher
,
public
synchronized
void
add
(
SampleDispatcher
dispatcher
,
SampleHandler
handler
)
throws
IOException
{
SampleHandler
handler
)
throws
IOException
{
//XXX kludge: special handling of predefined types
//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
);
Entry
e
=
new
Entry
(
dispatcher
,
handler
);
e
.
setIndex
(
Constant
.
TYPE_DEF
);
e
.
setIndex
(
Constant
.
TYPE_DEF
);
byClass
.
put
(
dispatcher
.
getSampleClass
(),
e
);
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;
...
@@ -8,7 +8,7 @@ import se.lth.control.labcomm.DecoderChannel;
import
se.lth.control.labcomm.SampleDispatcher
;
import
se.lth.control.labcomm.SampleDispatcher
;
import
se.lth.control.labcomm.SampleHandler
;
import
se.lth.control.labcomm.SampleHandler
;
public
class
Type
d
ef
implements
SampleType
{
public
class
Type
D
ef
implements
SampleType
{
private
int
index
;
private
int
index
;
private
String
name
;
private
String
name
;
private
byte
signature
[];
private
byte
signature
[];
...
@@ -22,14 +22,14 @@ public class Typedef implements SampleType {
...
@@ -22,14 +22,14 @@ public class Typedef implements SampleType {
}
}
public
void
dump
()
{
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
)
{
for
(
byte
b
:
signature
)
{
System
.
out
.
print
(
String
.
format
(
"0x%02X "
,
b
));
System
.
out
.
print
(
String
.
format
(
"0x%02X "
,
b
));
}
}
System
.
out
.
println
();
System
.
out
.
println
();
}
}
public
interface
Handler
extends
SampleHandler
{
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
{
public
static
void
register
(
Decoder
d
,
Handler
h
)
throws
IOException
{
...
@@ -44,7 +44,7 @@ public class Typedef implements SampleType {
...
@@ -44,7 +44,7 @@ public class Typedef implements SampleType {
throw
new
IOException
(
"cannot send TypeDefs"
);
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
;
private
static
Dispatcher
singleton
;
...
@@ -53,12 +53,12 @@ public class Typedef implements SampleType {
...
@@ -53,12 +53,12 @@ public class Typedef implements SampleType {
return
singleton
;
return
singleton
;
}
}
public
Class
<
Type
d
ef
>
getSampleClass
()
{
public
Class
<
Type
D
ef
>
getSampleClass
()
{
return
Type
d
ef
.
class
;
return
Type
D
ef
.
class
;
}
}
public
String
getName
()
{
public
String
getName
()
{
return
"Type
d
ef"
;
return
"Type
D
ef"
;
}
}
public
byte
getTypeDeclTag
()
{
public
byte
getTypeDeclTag
()
{
...
@@ -87,7 +87,7 @@ public class Typedef implements SampleType {
...
@@ -87,7 +87,7 @@ public class Typedef implements SampleType {
public
void
decodeAndHandle
(
Decoder
d
,
public
void
decodeAndHandle
(
Decoder
d
,
SampleHandler
h
)
throws
Exception
{
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
()
{
public
boolean
hasDependencies
()
{
...
@@ -95,18 +95,18 @@ public class Typedef implements SampleType {
...
@@ -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"
);
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
.
index
=
index
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
signature
=
sig
;
this
.
signature
=
sig
;
}
}
public
static
Type
d
ef
decode
(
Decoder
d
)
throws
IOException
{
public
static
Type
D
ef
decode
(
Decoder
d
)
throws
IOException
{
Type
d
ef
result
;
Type
D
ef
result
;
int
index
=
d
.
decodePacked32
();
int
index
=
d
.
decodePacked32
();
String
name
=
d
.
decodeString
();
String
name
=
d
.
decodeString
();
int
siglen
=
d
.
decodePacked32
();
int
siglen
=
d
.
decodePacked32
();
...
@@ -114,7 +114,7 @@ public class Typedef implements SampleType {
...
@@ -114,7 +114,7 @@ public class Typedef implements SampleType {
for
(
int
i
=
0
;
i
<
siglen
;
i
++){
for
(
int
i
=
0
;
i
<
siglen
;
i
++){
sig
[
i
]
=
d
.
decodeByte
();
sig
[
i
]
=
d
.
decodeByte
();
}
}
result
=
new
Type
d
ef
(
index
,
name
,
sig
);
result
=
new
Type
D
ef
(
index
,
name
,
sig
);
return
result
;
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