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
Anders Blomdell
LabComm
Commits
72099bf9
Commit
72099bf9
authored
May 24, 2015
by
Anders Blomdell
Browse files
Probably got typedefs right under renaming.
parent
c115becb
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/c/2014/labcomm2014_renaming_encoder.c
View file @
72099bf9
...
...
@@ -26,8 +26,7 @@
struct
renamed
{
struct
labcomm2014_signature
signature
;
struct
labcomm2014_signature
renamed
;
struct
labcomm2014_signature_data
treedata
[
2
];
struct
labcomm2014_signature_data
s_treedata
[
2
];
};
struct
encoder
{
...
...
@@ -107,24 +106,16 @@ static struct renamed *set_renamed(
result
->
signature
.
signature
=
signature
->
signature
;
result
->
signature
.
index
=
0
;
#ifndef LABCOMM_NO_TYPEDECL
result
->
renamed
.
name
=
result
->
signature
.
name
;
result
->
renamed
.
encoded_size
=
NULL
;
result
->
renamed
.
size
=
0
;
result
->
renamed
.
signature
=
NULL
;
result
->
renamed
.
index
=
0
;
result
->
renamed
.
tdsize
=
signature
->
tdsize
;
result
->
renamed
.
treedata
=
signature
->
treedata
;
struct
labcomm2014_signature_data
treedata
[
2
]
=
{
LABCOMM_SIGDEF_SIGNATURE
(
result
->
renamed
),
struct
labcomm2014_signature_data
s_treedata
[
2
]
=
{
LABCOMM_SIGDEF_SIGNATURE
(
*
signature
),
LABCOMM_SIGDEF_END
};
result
->
treedata
[
0
]
=
treedata
[
0
];
result
->
treedata
[
1
]
=
treedata
[
1
];
result
->
signature
.
tdsize
=
sizeof
(
result
->
treedata
);
result
->
signature
.
treedata
=
result
->
treedata
;
result
->
s_
treedata
[
0
]
=
s_
treedata
[
0
];
result
->
s_
treedata
[
1
]
=
s_
treedata
[
1
];
result
->
signature
.
tdsize
=
sizeof
(
result
->
s_
treedata
);
result
->
signature
.
treedata
=
result
->
s_
treedata
;
#endif
labcomm2014_set_local_index
(
&
result
->
signature
);
labcomm2014_set_local_index
(
&
result
->
renamed
);
*
renamed
=
result
;
goto
unlock
;
unlock_free_result:
...
...
@@ -146,10 +137,12 @@ static int do_type_register(struct labcomm2014_encoder *e,
renamed
=
get_renamed
(
e
,
signature
);
if
(
renamed
)
{
/* Register renaming type */
ie
->
next
->
type_register
(
ie
->
next
,
&
renamed
->
renamed
);
/* Register base type and renamed type */
ie
->
next
->
type_register
(
ie
->
next
,
signature
);
return
ie
->
next
->
type_register
(
ie
->
next
,
&
renamed
->
signature
);
}
else
{
return
ie
->
next
->
type_register
(
ie
->
next
,
signature
);
}
return
ie
->
next
->
type_register
(
ie
->
next
,
signature
);
}
static
int
do_type_bind
(
struct
labcomm2014_encoder
*
e
,
...
...
lib/c/2014/test/test_labcomm_renaming_encoder.c
View file @
72099bf9
...
...
@@ -123,7 +123,7 @@ static int buf_writer_ioctl(
seen_variable
[
VARIABLE
(
expected
[
i
])]
=
buffer
[
i
];
}
if
(
seen_variable
[
VARIABLE
(
expected
[
i
])]
!=
buffer
[
i
])
{
fprintf
(
stderr
,
"Unexpected variable v%d (%
d
: != %
d
)
\n
"
,
fprintf
(
stderr
,
"Unexpected variable v%d (%
02x
: != %
02x
)
\n
"
,
VARIABLE
(
expected
[
i
]),
seen_variable
[
VARIABLE
(
expected
[
i
])],
buffer
[
i
]);
mismatch
=
1
;
...
...
@@ -132,7 +132,7 @@ static int buf_writer_ioctl(
mismatch
=
1
;
}
}
if
(
mismatch
)
{
if
(
1
||
mismatch
)
{
fprintf
(
stderr
,
"Encoder mismatch (%s:%d)
\n
"
,
__FILE__
,
line
);
...
...
@@ -148,7 +148,7 @@ static int buf_writer_ioctl(
}
}
printf
(
"
\n
"
);
exit
(
1
);
if
(
mismatch
)
{
exit
(
1
);
}
}
result
=
0
;
}
break
;
...
...
@@ -229,16 +229,16 @@ int main(void)
labcomm2014_encoder_register_generated_encoding_V
(
prefix
);
labcomm2014_encoder_register_generated_encoding_V
(
prefix
);
EXPECT
({
0x02
,
0x08
,
VARIABLE
(
3
),
0x03
,
'p'
,
'.'
,
'V'
,
0x02
,
0x11
,
0x00
,
0x04
,
0x07
,
VARIABLE
(
4
),
0x03
,
'p'
,
'.'
,
'V'
,
0x01
,
VARIABLE
(
1
),
0x04
,
0x07
,
VARIABLE
(
4
),
0x03
,
'p'
,
'.'
,
'V'
,
0x01
,
VARIABLE
(
2
),
0x05
,
0x02
,
VARIABLE
(
3
),
VARIABLE
(
4
)
});
labcomm2014_encoder_ioctl
(
suffix
,
IOCTL_WRITER_RESET
);
labcomm2014_encoder_register_generated_encoding_V
(
suffix
);
labcomm2014_encoder_register_generated_encoding_V
(
suffix
);
EXPECT
({
0x02
,
0x0a
,
VARIABLE
(
6
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x02
,
0x11
,
0x00
,
0x04
,
0x0
c
,
VARIABLE
(
7
),
0x0
7
,
'
p'
,
'.'
,
'v'
,
'_'
,
't
'
,
'.'
,
's'
,
0x0
2
,
0x11
,
0x00
,
0x04
,
0x09
,
VARIABLE
(
8
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x01
,
VARIABLE
(
1
)
/* WEIRD */
,
0x05
,
0x02
,
VARIABLE
(
6
),
VARIABLE
(
22
)
});
EXPECT
({
0x02
,
0x0a
,
VARIABLE
(
5
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x02
,
0x11
,
0x00
,
0x04
,
0x0
7
,
VARIABLE
(
6
),
0x0
3
,
'
V
'
,
'.'
,
's'
,
0x0
1
,
VARIABLE
(
2
)
,
0x04
,
0x09
,
VARIABLE
(
7
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x01
,
VARIABLE
(
6
)
,
0x05
,
0x02
,
VARIABLE
(
5
),
VARIABLE
(
7
)
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
...
...
@@ -247,7 +247,7 @@ int main(void)
labcomm2014_signature_generated_encoding_V
);
labcomm2014_encoder_sample_ref_register
(
encoder
,
labcomm2014_signature_generated_encoding_V
);
EXPECT
({
0x03
,
0x06
,
VARIABLE
(
9
),
0x01
,
'V'
,
0x02
,
0x11
,
0x00
});
EXPECT
({
0x03
,
0x06
,
VARIABLE
(
8
),
0x01
,
'V'
,
0x02
,
0x11
,
0x00
});
labcomm2014_encoder_ioctl
(
prefix
,
IOCTL_WRITER_RESET
);
/* Register twice to make sure that only one registration gets encoded */
...
...
@@ -255,15 +255,14 @@ int main(void)
labcomm2014_signature_generated_encoding_V
);
labcomm2014_encoder_sample_ref_register
(
prefix
,
labcomm2014_signature_generated_encoding_V
);
EXPECT
({
0x03
,
0x08
,
VARIABLE
(
10
),
0x03
,
'p'
,
'.'
,
'V'
,
0x02
,
0x11
,
0x00
});
EXPECT
({
0x03
,
0x08
,
VARIABLE
(
9
),
0x03
,
'p'
,
'.'
,
'V'
,
0x02
,
0x11
,
0x00
});
labcomm2014_encoder_ioctl
(
suffix
,
IOCTL_WRITER_RESET
);
/* Register twice to make sure that only one registration gets encoded */
labcomm2014_encoder_sample_ref_register
(
suffix
,
labcomm2014_signature_generated_encoding_V
);
labcomm2014_encoder_sample_ref_register
(
suffix
,
labcomm2014_signature_generated_encoding_V
);
EXPECT
({
0x03
,
0x0a
,
VARIABLE
(
1
1
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x02
,
0x11
,
0x00
});
EXPECT
({
0x03
,
0x0a
,
VARIABLE
(
1
0
),
0x05
,
'p'
,
'.'
,
'V'
,
'.'
,
's'
,
0x02
,
0x11
,
0x00
});
labcomm2014_encoder_ioctl
(
encoder
,
IOCTL_WRITER_RESET
);
...
...
@@ -276,7 +275,7 @@ int main(void)
labcomm2014_encoder_ioctl
(
suffix
,
IOCTL_WRITER_RESET
);
labcomm2014_encode_generated_encoding_V
(
suffix
);
EXPECT
({
VARIABLE
(
6
),
0x00
});
EXPECT
({
VARIABLE
(
5
),
0x00
});
return
0
;
}
...
...
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