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
506eb33b
Commit
506eb33b
authored
Mar 22, 2013
by
Sven Robertz
Browse files
put back varargs in writer
parent
3b18c8bf
Changes
10
Hide whitespace changes
Inline
Side-by-side
compiler/C_CodeGen.jrag
View file @
506eb33b
...
...
@@ -641,7 +641,8 @@ aspect C_Encoder {
env.println(")");
env.println("{");
env.indent();
env.println("e->writer.write(&e->writer, labcomm_writer_start);");
env.println("labcomm_encoder_start(e, &labcomm_signature_" +
env.prefix + getName() + ");");
env.println("labcomm_encode_type_index(e, &labcomm_signature_" +
env.prefix + getName() + ");");
env.println("{");
...
...
@@ -649,7 +650,8 @@ aspect C_Encoder {
getType().C_emitEncoder(env);
env.unindent();
env.println("}");
env.println("e->writer.write(&e->writer, labcomm_writer_end);");
env.println("labcomm_encoder_end(e, &labcomm_signature_" +
env.prefix + getName() + ");");
env.unindent();
env.println("}");
...
...
lib/c/labcomm.c
View file @
506eb33b
...
...
@@ -183,6 +183,25 @@ static int get_encoder_index(
return
result
;
}
void
labcomm_encoder_start
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
s
)
{
int
index
=
get_encoder_index
(
e
,
s
);
e
->
writer
.
write
(
&
e
->
writer
,
labcomm_writer_start
,
index
);
}
void
labcomm_encoder_end
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
s
)
{
e
->
writer
.
write
(
&
e
->
writer
,
labcomm_writer_end
);
}
void
labcomm_encode_type_index
(
labcomm_encoder_t
*
e
,
labcomm_signature_t
*
s
)
{
int
index
=
get_encoder_index
(
e
,
s
);
labcomm_encode_packed32
(
e
,
index
);
}
void
labcomm_encode_signature
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
signature
)
{
...
...
@@ -248,7 +267,7 @@ static void do_encode(
}
labcomm_encoder_t
*
labcomm_encoder_new
(
int
(
*
writer
)(
labcomm_writer_t
*
,
labcomm_writer_action_t
),
int
(
*
writer
)(
labcomm_writer_t
*
,
labcomm_writer_action_t
,
...
),
void
*
writer_context
)
{
labcomm_encoder_t
*
result
=
malloc
(
sizeof
(
labcomm_encoder_t
));
...
...
@@ -342,12 +361,6 @@ int labcomm_encoder_ioctl(struct labcomm_encoder *encoder,
}
void
labcomm_encode_type_index
(
labcomm_encoder_t
*
e
,
labcomm_signature_t
*
s
)
{
int
index
=
get_encoder_index
(
e
,
s
);
labcomm_encode_packed32
(
e
,
index
);
}
static
void
collect_flat_signature
(
labcomm_decoder_t
*
decoder
,
labcomm_encoder_t
*
signature_writer
)
...
...
lib/c/labcomm.h
View file @
506eb33b
...
...
@@ -147,13 +147,13 @@ typedef struct labcomm_writer {
int
count
;
int
pos
;
int
error
;
int
(
*
write
)(
struct
labcomm_writer
*
,
labcomm_writer_action_t
);
int
(
*
write
)(
struct
labcomm_writer
*
,
labcomm_writer_action_t
,
...
);
int
(
*
ioctl
)(
struct
labcomm_writer
*
,
int
,
va_list
);
labcomm_error_handler_callback
on_error
;
}
labcomm_writer_t
;
struct
labcomm_encoder
*
labcomm_encoder_new
(
int
(
*
writer
)(
labcomm_writer_t
*
,
labcomm_writer_action_t
),
int
(
*
writer
)(
labcomm_writer_t
*
,
labcomm_writer_action_t
,
...
),
void
*
writer_context
);
void
labcomm_encoder_free
(
struct
labcomm_encoder
*
encoder
);
...
...
@@ -162,4 +162,10 @@ int labcomm_encoder_ioctl(struct labcomm_encoder *encoder,
int
ioctl_action
,
...);
void
labcomm_encoder_start
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
s
)
;
//HERE BE DRAGONS: is the signature_t* needed here?
void
labcomm_encoder_end
(
struct
labcomm_encoder
*
e
,
labcomm_signature_t
*
s
)
;
#endif
lib/c/labcomm_dynamic_buffer_reader_writer.c
View file @
506eb33b
...
...
@@ -2,7 +2,7 @@
int
labcomm_dynamic_buffer_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
)
labcomm_writer_action_t
action
,
...
)
{
switch
(
action
)
{
case
labcomm_writer_alloc
:
{
...
...
lib/c/labcomm_dynamic_buffer_reader_writer.h
View file @
506eb33b
...
...
@@ -9,6 +9,6 @@ extern int labcomm_dynamic_buffer_reader(
extern
int
labcomm_dynamic_buffer_writer
(
labcomm_writer_t
*
writer
,
labcomm_writer_action_t
action
);
labcomm_writer_action_t
action
,
...
);
#endif
lib/c/labcomm_fd_reader_writer.c
View file @
506eb33b
...
...
@@ -62,7 +62,7 @@ int labcomm_fd_reader(
int
labcomm_fd_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
)
labcomm_writer_action_t
action
,
...
)
{
int
result
=
0
;
int
*
fd
=
w
->
context
;
...
...
lib/c/labcomm_fd_reader_writer.h
View file @
506eb33b
...
...
@@ -9,6 +9,6 @@ extern int labcomm_fd_reader(
extern
int
labcomm_fd_writer
(
labcomm_writer_t
*
writer
,
labcomm_writer_action_t
action
);
labcomm_writer_action_t
action
,
...
);
#endif
lib/c/labcomm_private.h
View file @
506eb33b
...
...
@@ -331,7 +331,7 @@ static inline void labcomm_encode_string(labcomm_encoder_t *e,
void
labcomm_encode_type_index
(
labcomm_encoder_t
*
e
,
labcomm_signature_t
*
s
);
static
inline
int
labcomm_buffer_write
(
struct
labcomm_writer
*
w
,
labcomm_writer_action_t
action
)
labcomm_writer_action_t
action
,
...
)
{
// If this gets called, it is an error,
// so note error and let producer proceed
...
...
lib/c/test/labcomm_mem_writer.c
View file @
506eb33b
...
...
@@ -27,7 +27,7 @@ static void copy_data(labcomm_writer_t *w, labcomm_mem_writer_context_t *mcontex
* Write encoded messages to memory. w->context is assumed to be a pointer to a
* labcomm_mem_writer_context_t structure.
*/
int
labcomm_mem_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
)
int
labcomm_mem_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
,
...
)
{
int
result
=
0
;
// Unwrap pointers for easy access.
...
...
lib/c/test/labcomm_mem_writer.h
View file @
506eb33b
...
...
@@ -11,7 +11,7 @@ struct labcomm_mem_writer_context_t {
unsigned
char
*
buf
;
// Allocated destination buffer.
};
int
labcomm_mem_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
);
int
labcomm_mem_writer
(
labcomm_writer_t
*
w
,
labcomm_writer_action_t
action
,
...
);
/* Wrapper the internal static function copy_data. This is needed so that the exceptions can be unit tested. */
void
test_copy_data
(
labcomm_writer_t
*
w
,
labcomm_mem_writer_context_t
*
mcontext
,
unsigned
char
*
mbuf
);
...
...
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