Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
2c1ef4dc
Commit
2c1ef4dc
authored
12 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Preparing to remove need for decoder->reader and encoder->writer
indirection in generated C-code.
parent
f0f8cc6e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/c/labcomm.c
+20
-28
20 additions, 28 deletions
lib/c/labcomm.c
lib/c/labcomm_private.h
+3
-3
3 additions, 3 deletions
lib/c/labcomm_private.h
with
23 additions
and
31 deletions
lib/c/labcomm.c
+
20
−
28
View file @
2c1ef4dc
...
...
@@ -224,17 +224,17 @@ static int get_encoder_index(
#endif
}
void
labcomm_encode_signature
(
struct
labcomm_encoder
*
e
,
static
void
labcomm_encode_signature
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
signature
)
{
int
i
,
index
;
index
=
get_encoder_index
(
e
,
signature
);
e
->
writer
.
action
.
start
(
&
e
->
writer
,
e
,
index
,
signature
,
NULL
);
labcomm_
encod
e_packed32
(
e
,
signature
->
type
);
labcomm_
encod
e_packed32
(
e
,
index
);
labcomm_
writ
e_packed32
(
&
e
->
writer
,
signature
->
type
);
labcomm_
writ
e_packed32
(
&
e
->
writer
,
index
);
labcomm_
encod
e_string
(
e
,
signature
->
name
);
labcomm_
writ
e_string
(
&
e
->
writer
,
signature
->
name
);
for
(
i
=
0
;
i
<
signature
->
size
;
i
++
)
{
if
(
e
->
writer
.
pos
>=
e
->
writer
.
count
)
{
e
->
writer
.
action
.
flush
(
&
e
->
writer
);
...
...
@@ -406,7 +406,7 @@ int labcomm_internal_encode(
result
=
e
->
writer
.
action
.
start
(
&
e
->
writer
,
e
,
index
,
signature
,
value
);
if
(
result
==
-
EALREADY
)
{
result
=
0
;
goto
no_end
;
}
if
(
result
!=
0
)
{
goto
out
;
}
result
=
labcomm_
encod
e_packed32
(
e
,
index
);
result
=
labcomm_
writ
e_packed32
(
&
e
->
writer
,
index
);
if
(
result
!=
0
)
{
goto
out
;
}
result
=
encode
(
e
,
value
);
out:
...
...
@@ -469,36 +469,32 @@ static void collect_flat_signature(
labcomm_decoder_t
*
decoder
,
labcomm_encoder_t
*
signature_writer
)
{
//int type = labcomm_decode_int(decoder);
int
type
=
labcomm_decode_packed32
(
decoder
);
// printf("%s: type=%x\n", __FUNCTION__, type);
int
type
=
labcomm_read_packed32
(
&
decoder
->
reader
);
if
(
type
>=
LABCOMM_USER
)
{
decoder
->
on_error
(
LABCOMM_ERROR_UNIMPLEMENTED_FUNC
,
3
,
"Implement %s ... (1) for type 0x%x
\n
"
,
__FUNCTION__
,
type
);
}
else
{
//labcomm_encode_int(signature_writer, type);
labcomm_encode_packed32
(
signature_writer
,
type
);
labcomm_write_packed32
(
&
signature_writer
->
writer
,
type
);
switch
(
type
)
{
case
LABCOMM_ARRAY
:
{
int
dimensions
,
i
;
dimensions
=
labcomm_
decode
_packed32
(
decoder
);
//labcomm_decode_int(decoder); //unpack32
labcomm_
encod
e_packed32
(
signature_writer
,
dimensions
);
//pack32
dimensions
=
labcomm_
read
_packed32
(
&
decoder
->
reader
);
labcomm_
writ
e_packed32
(
&
signature_writer
->
writer
,
dimensions
);
for
(
i
=
0
;
i
<
dimensions
;
i
++
)
{
int
n
=
labcomm_
decode
_packed32
(
decoder
);
//labcomm_decode_int(deco
der);
labcomm_
encod
e_packed32
(
signature_writer
,
n
);
// labcomm_encode_int(signature_
writer, n);
int
n
=
labcomm_
read
_packed32
(
&
decoder
->
rea
der
);
labcomm_
writ
e_packed32
(
&
signature_writer
->
writer
,
n
);
}
collect_flat_signature
(
decoder
,
signature_writer
);
}
break
;
case
LABCOMM_STRUCT
:
{
int
fields
,
i
;
//fields = labcomm_decode_int(decoder);
//labcomm_encode_int(signature_writer, fields);
fields
=
labcomm_decode_packed32
(
decoder
);
labcomm_encode_packed32
(
signature_writer
,
fields
);
fields
=
labcomm_read_packed32
(
&
decoder
->
reader
);
labcomm_write_packed32
(
&
signature_writer
->
writer
,
fields
);
for
(
i
=
0
;
i
<
fields
;
i
++
)
{
char
*
name
=
labcomm_
decode
_string
(
decoder
);
labcomm_
encod
e_string
(
signature_writer
,
name
);
char
*
name
=
labcomm_
read
_string
(
&
decoder
->
reader
);
labcomm_
writ
e_string
(
&
signature_writer
->
writer
,
name
);
free
(
name
);
collect_flat_signature
(
decoder
,
signature_writer
);
}
...
...
@@ -580,9 +576,7 @@ int labcomm_decoder_decode_one(labcomm_decoder_t *d)
if
(
result
>
0
)
{
labcomm_decoder_context_t
*
context
=
d
->
context
;
// printf("do_decode_one: result = %x\n", result);
result
=
labcomm_decode_packed32
(
d
);
// printf("do_decode_one: result(2) = %x\n", result);
result
=
labcomm_read_packed32
(
&
d
->
reader
);
if
(
result
==
LABCOMM_TYPEDEF
||
result
==
LABCOMM_SAMPLE
)
{
/* TODO: should the labcomm_dynamic_buffer_writer be
a permanent part of labcomm_decoder? */
...
...
@@ -592,12 +586,10 @@ int labcomm_decoder_decode_one(labcomm_decoder_t *d)
labcomm_sample_entry_t
*
entry
=
NULL
;
int
index
,
err
;
index
=
labcomm_
decode
_packed32
(
d
);
//int
signature
.
name
=
labcomm_
decode
_string
(
d
);
index
=
labcomm_
read
_packed32
(
&
d
->
reader
);
//int
signature
.
name
=
labcomm_
read
_string
(
&
d
->
reader
);
signature
.
type
=
result
;
e
->
writer
.
action
.
start
(
&
e
->
writer
,
NULL
,
0
,
NULL
,
NULL
);
/* printf("do_decode_one: result = %x, index = %x, name=%s\n",
result, index, signature.name); */
collect_flat_signature
(
d
,
e
);
e
->
writer
.
action
.
end
(
&
e
->
writer
);
err
=
labcomm_encoder_ioctl
(
e
,
LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN
,
...
...
This diff is collapsed.
Click to expand it.
lib/c/labcomm_private.h
+
3
−
3
View file @
2c1ef4dc
...
...
@@ -127,7 +127,7 @@ LABCOMM_DECODE(long, long long)
LABCOMM_DECODE
(
float
,
float
)
LABCOMM_DECODE
(
double
,
double
)
static
inline
unsigned
int
labcomm_read_
un
packed32
(
labcomm_reader_t
*
r
)
static
inline
unsigned
int
labcomm_read_packed32
(
labcomm_reader_t
*
r
)
{
unsigned
int
result
=
0
;
...
...
@@ -149,7 +149,7 @@ static inline unsigned int labcomm_read_unpacked32(labcomm_reader_t *r)
static
inline
unsigned
int
labcomm_decode_packed32
(
labcomm_decoder_t
*
d
)
{
return
labcomm_read_
un
packed32
(
&
d
->
reader
);
return
labcomm_read_packed32
(
&
d
->
reader
);
}
static
inline
char
*
labcomm_read_string
(
labcomm_reader_t
*
r
)
...
...
@@ -157,7 +157,7 @@ static inline char *labcomm_read_string(labcomm_reader_t *r)
char
*
result
;
int
length
,
i
;
length
=
labcomm_read_
un
packed32
(
r
);
length
=
labcomm_read_packed32
(
r
);
result
=
malloc
(
length
+
1
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
if
(
r
->
pos
>=
r
->
count
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment