gmio_core: rename member gmio_rwargs::memblock -> stream_memblock
This commit is contained in:
parent
0298cf3c89
commit
9d9d65bbd5
@ -182,12 +182,12 @@ static void bmk_gmio_stl_readwrite_conv(const char* filepath)
|
|||||||
rw_conv.out_format = GMIO_STL_FORMAT_ASCII;
|
rw_conv.out_format = GMIO_STL_FORMAT_ASCII;
|
||||||
|
|
||||||
if (infile != NULL) {
|
if (infile != NULL) {
|
||||||
read.core.memblock = gmio_memblock_malloc(512 * 1024);
|
read.core.stream_memblock = gmio_memblock_malloc(512 * 1024);
|
||||||
read.core.stream = gmio_stream_stdio(infile);
|
read.core.stream = gmio_stream_stdio(infile);
|
||||||
rw_conv.in_format = gmio_stl_get_format(&read.core.stream);
|
rw_conv.in_format = gmio_stl_get_format(&read.core.stream);
|
||||||
}
|
}
|
||||||
if (outfile != NULL) {
|
if (outfile != NULL) {
|
||||||
rw_conv.rwargs.memblock = gmio_memblock_malloc(512 * 1024);
|
rw_conv.rwargs.stream_memblock = gmio_memblock_malloc(512 * 1024);
|
||||||
rw_conv.rwargs.stream = gmio_stream_stdio(outfile);
|
rw_conv.rwargs.stream = gmio_stream_stdio(outfile);
|
||||||
rw_conv.rwargs.stream.func_get_pos(
|
rw_conv.rwargs.stream.func_get_pos(
|
||||||
rw_conv.rwargs.stream.cookie,
|
rw_conv.rwargs.stream.cookie,
|
||||||
@ -202,8 +202,8 @@ static void bmk_gmio_stl_readwrite_conv(const char* filepath)
|
|||||||
|
|
||||||
error = gmio_stl_read(&read);
|
error = gmio_stl_read(&read);
|
||||||
|
|
||||||
gmio_memblock_deallocate(&read.core.memblock);
|
gmio_memblock_deallocate(&read.core.stream_memblock);
|
||||||
gmio_memblock_deallocate(&rw_conv.rwargs.memblock);
|
gmio_memblock_deallocate(&rw_conv.rwargs.stream_memblock);
|
||||||
|
|
||||||
if (error != GMIO_ERROR_OK)
|
if (error != GMIO_ERROR_OK)
|
||||||
printf("gmio error: 0x%X\n", error);
|
printf("gmio error: 0x%X\n", error);
|
||||||
|
@ -40,7 +40,7 @@ struct gmio_rwargs
|
|||||||
* is created with the global default constructor function (see
|
* is created with the global default constructor function (see
|
||||||
* gmio_memblock_default())
|
* gmio_memblock_default())
|
||||||
*/
|
*/
|
||||||
struct gmio_memblock memblock;
|
struct gmio_memblock stream_memblock;
|
||||||
|
|
||||||
/*! Optional interface by which the I/O operation can be controlled */
|
/*! Optional interface by which the I/O operation can be controlled */
|
||||||
struct gmio_task_iface task_iface;
|
struct gmio_task_iface task_iface;
|
||||||
|
@ -26,9 +26,9 @@ gmio_bool_t gmio_check_rwargs(int *error, const struct gmio_rwargs* args)
|
|||||||
*error = GMIO_ERROR_NULL_RWARGS;
|
*error = GMIO_ERROR_NULL_RWARGS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (args->memblock.ptr == NULL)
|
if (args->stream_memblock.ptr == NULL)
|
||||||
*error = GMIO_ERROR_NULL_MEMBLOCK;
|
*error = GMIO_ERROR_NULL_MEMBLOCK;
|
||||||
else if (args->memblock.size == 0)
|
else if (args->stream_memblock.size == 0)
|
||||||
*error = GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
*error = GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ gmio_bool_t gmio_stlb_check_params(
|
|||||||
if (!gmio_check_rwargs(error, args))
|
if (!gmio_check_rwargs(error, args))
|
||||||
return GMIO_FALSE;
|
return GMIO_FALSE;
|
||||||
|
|
||||||
if (args->memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE)
|
if (args->stream_memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE)
|
||||||
*error = GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
*error = GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
||||||
if (byte_order != GMIO_ENDIANNESS_LITTLE
|
if (byte_order != GMIO_ENDIANNESS_LITTLE
|
||||||
&& byte_order != GMIO_ENDIANNESS_BIG)
|
&& byte_order != GMIO_ENDIANNESS_BIG)
|
||||||
|
@ -126,7 +126,7 @@ GMIO_INLINE gmio_bool_t gmio_rwargs_flush_buffer(
|
|||||||
{
|
{
|
||||||
const size_t write_count =
|
const size_t write_count =
|
||||||
gmio_stream_write(
|
gmio_stream_write(
|
||||||
&args->stream, args->memblock.ptr, sizeof(char), n);
|
&args->stream, args->stream_memblock.ptr, sizeof(char), n);
|
||||||
return write_count == n;
|
return write_count == n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,8 @@ int gmio_stla_write(struct gmio_stl_write_args* args)
|
|||||||
const uint32_t total_facet_count =
|
const uint32_t total_facet_count =
|
||||||
args->mesh.triangle_count;
|
args->mesh.triangle_count;
|
||||||
const uint32_t buffer_facet_count =
|
const uint32_t buffer_facet_count =
|
||||||
gmio_size_to_uint32(args->core.memblock.size / GMIO_STLA_FACET_SIZE_P2);
|
gmio_size_to_uint32(
|
||||||
|
args->core.stream_memblock.size / GMIO_STLA_FACET_SIZE_P2);
|
||||||
const char* opt_solid_name =
|
const char* opt_solid_name =
|
||||||
args->options.stla_solid_name;
|
args->options.stla_solid_name;
|
||||||
const char* solid_name =
|
const char* solid_name =
|
||||||
@ -152,7 +153,7 @@ int gmio_stla_write(struct gmio_stl_write_args* args)
|
|||||||
/* Variables */
|
/* Variables */
|
||||||
struct gmio_rwargs* core_args = &args->core;
|
struct gmio_rwargs* core_args = &args->core;
|
||||||
uint32_t ifacet = 0;
|
uint32_t ifacet = 0;
|
||||||
void* mblock_ptr = core_args->memblock.ptr;
|
void* mblock_ptr = core_args->stream_memblock.ptr;
|
||||||
char* buffc = mblock_ptr;
|
char* buffc = mblock_ptr;
|
||||||
char coords_format[64];
|
char coords_format[64];
|
||||||
int error = GMIO_ERROR_OK;
|
int error = GMIO_ERROR_OK;
|
||||||
@ -164,7 +165,7 @@ int gmio_stla_write(struct gmio_stl_write_args* args)
|
|||||||
return error;
|
return error;
|
||||||
if (float32_prec == 0 || float32_prec > 9)
|
if (float32_prec == 0 || float32_prec > 9)
|
||||||
return GMIO_STL_ERROR_INVALID_FLOAT32_PREC;
|
return GMIO_STL_ERROR_INVALID_FLOAT32_PREC;
|
||||||
if (core_args->memblock.size < GMIO_STLA_FACET_SIZE_P2)
|
if (core_args->stream_memblock.size < GMIO_STLA_FACET_SIZE_P2)
|
||||||
return GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
return GMIO_ERROR_INVALID_MEMBLOCK_SIZE;
|
||||||
|
|
||||||
{ /* Create XYZ coords format string (for normal and vertex coords) */
|
{ /* Create XYZ coords format string (for normal and vertex coords) */
|
||||||
|
@ -75,7 +75,7 @@ int gmio_stlb_write(
|
|||||||
args->options.stl_write_triangles_only;
|
args->options.stl_write_triangles_only;
|
||||||
/* Variables */
|
/* Variables */
|
||||||
struct gmio_rwargs* core_args = &args->core;
|
struct gmio_rwargs* core_args = &args->core;
|
||||||
void* mblock_ptr = core_args->memblock.ptr;
|
void* mblock_ptr = core_args->stream_memblock.ptr;
|
||||||
struct gmio_stlb_readwrite_helper wparams = {0};
|
struct gmio_stlb_readwrite_helper wparams = {0};
|
||||||
uint32_t i_facet = 0;
|
uint32_t i_facet = 0;
|
||||||
int error = GMIO_ERROR_OK;
|
int error = GMIO_ERROR_OK;
|
||||||
@ -93,7 +93,7 @@ int gmio_stlb_write(
|
|||||||
/* Note: trsf != NULL certified by gmio_stlb_check_params() */
|
/* Note: trsf != NULL certified by gmio_stlb_check_params() */
|
||||||
/* coverity[var_deref_op : FALSE] */
|
/* coverity[var_deref_op : FALSE] */
|
||||||
wparams.facet_count = gmio_size_to_uint32(
|
wparams.facet_count = gmio_size_to_uint32(
|
||||||
core_args->memblock.size / GMIO_STLB_TRIANGLE_RAWSIZE);
|
core_args->stream_memblock.size / GMIO_STLB_TRIANGLE_RAWSIZE);
|
||||||
|
|
||||||
if (!write_triangles_only) {
|
if (!write_triangles_only) {
|
||||||
error = gmio_stlb_write_header(
|
error = gmio_stlb_write_header(
|
||||||
|
@ -82,7 +82,7 @@ int gmio_stl_write(
|
|||||||
int error = GMIO_ERROR_OK;
|
int error = GMIO_ERROR_OK;
|
||||||
if (args != NULL) {
|
if (args != NULL) {
|
||||||
struct gmio_memblock_helper mblock_helper =
|
struct gmio_memblock_helper mblock_helper =
|
||||||
gmio_memblock_helper(&args->core.memblock);
|
gmio_memblock_helper(&args->core.stream_memblock);
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case GMIO_STL_FORMAT_ASCII: {
|
case GMIO_STL_FORMAT_ASCII: {
|
||||||
error = gmio_stla_write(args);
|
error = gmio_stla_write(args);
|
||||||
|
@ -150,7 +150,7 @@ int gmio_stla_read(struct gmio_stl_read_args* args)
|
|||||||
{
|
{
|
||||||
struct gmio_rwargs* core_args = &args->core;
|
struct gmio_rwargs* core_args = &args->core;
|
||||||
struct gmio_memblock_helper mblock_helper =
|
struct gmio_memblock_helper mblock_helper =
|
||||||
gmio_memblock_helper(&core_args->memblock);
|
gmio_memblock_helper(&core_args->stream_memblock);
|
||||||
char fixed_buffer[GMIO_STLA_READ_STRING_MAX_LEN];
|
char fixed_buffer[GMIO_STLA_READ_STRING_MAX_LEN];
|
||||||
struct gmio_stla_parse_data parse_data;
|
struct gmio_stla_parse_data parse_data;
|
||||||
|
|
||||||
@ -164,8 +164,8 @@ int gmio_stla_read(struct gmio_stl_read_args* args)
|
|||||||
parse_data.strstream_cookie.is_stop_requested = GMIO_FALSE;
|
parse_data.strstream_cookie.is_stop_requested = GMIO_FALSE;
|
||||||
|
|
||||||
parse_data.strstream.stream = core_args->stream;
|
parse_data.strstream.stream = core_args->stream;
|
||||||
parse_data.strstream.strbuff.ptr = core_args->memblock.ptr;
|
parse_data.strstream.strbuff.ptr = core_args->stream_memblock.ptr;
|
||||||
parse_data.strstream.strbuff.max_len = core_args->memblock.size;
|
parse_data.strstream.strbuff.max_len = core_args->stream_memblock.size;
|
||||||
parse_data.strstream.cookie = &parse_data.strstream_cookie;
|
parse_data.strstream.cookie = &parse_data.strstream_cookie;
|
||||||
parse_data.strstream.func_stream_read_hook = gmio_stringstream_stla_read_hook;
|
parse_data.strstream.func_stream_read_hook = gmio_stringstream_stla_read_hook;
|
||||||
gmio_stringstream_init(&parse_data.strstream);
|
gmio_stringstream_init(&parse_data.strstream);
|
||||||
|
@ -75,10 +75,10 @@ int gmio_stlb_read(
|
|||||||
{
|
{
|
||||||
/* Variables */
|
/* Variables */
|
||||||
struct gmio_memblock_helper mblock_helper =
|
struct gmio_memblock_helper mblock_helper =
|
||||||
gmio_memblock_helper(&args->core.memblock);
|
gmio_memblock_helper(&args->core.stream_memblock);
|
||||||
struct gmio_rwargs* core_args = &args->core;
|
struct gmio_rwargs* core_args = &args->core;
|
||||||
struct gmio_stl_mesh_creator* mesh_creator = &args->mesh_creator;
|
struct gmio_stl_mesh_creator* mesh_creator = &args->mesh_creator;
|
||||||
void* mblock_ptr = core_args->memblock.ptr;
|
void* mblock_ptr = core_args->stream_memblock.ptr;
|
||||||
struct gmio_stlb_readwrite_helper rparams = {0};
|
struct gmio_stlb_readwrite_helper rparams = {0};
|
||||||
struct gmio_stlb_header header;
|
struct gmio_stlb_header header;
|
||||||
uint32_t total_facet_count = 0; /* Facet count, as declared in the stream */
|
uint32_t total_facet_count = 0; /* Facet count, as declared in the stream */
|
||||||
@ -86,7 +86,7 @@ int gmio_stlb_read(
|
|||||||
/* Constants */
|
/* Constants */
|
||||||
const uint32_t max_facet_count_per_read =
|
const uint32_t max_facet_count_per_read =
|
||||||
gmio_size_to_uint32(
|
gmio_size_to_uint32(
|
||||||
args->core.memblock.size / GMIO_STLB_TRIANGLE_RAWSIZE);
|
args->core.stream_memblock.size / GMIO_STLB_TRIANGLE_RAWSIZE);
|
||||||
|
|
||||||
/* Check validity of input parameters */
|
/* Check validity of input parameters */
|
||||||
if (!gmio_stlb_check_params(&error, core_args, byte_order))
|
if (!gmio_stlb_check_params(&error, core_args, byte_order))
|
||||||
|
@ -39,13 +39,13 @@ const char* test_stl_internal__rw_common()
|
|||||||
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
||||||
UTEST_ASSERT(error == GMIO_ERROR_NULL_MEMBLOCK);
|
UTEST_ASSERT(error == GMIO_ERROR_NULL_MEMBLOCK);
|
||||||
|
|
||||||
rwargs.memblock = gmio_memblock(&buff[0], 0, NULL);
|
rwargs.stream_memblock = gmio_memblock(&buff[0], 0, NULL);
|
||||||
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
||||||
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
||||||
|
|
||||||
/* Verify that gmio_check_transfer() doesn't touch error when in case of
|
/* Verify that gmio_check_transfer() doesn't touch error when in case of
|
||||||
* success */
|
* success */
|
||||||
rwargs.memblock = gmio_memblock(&buff[0], sizeof(buff), NULL);
|
rwargs.stream_memblock = gmio_memblock(&buff[0], sizeof(buff), NULL);
|
||||||
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
UTEST_ASSERT(!gmio_check_rwargs(&error, &rwargs));
|
||||||
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
||||||
|
|
||||||
@ -88,12 +88,14 @@ const char* test_stl_internal__rw_common()
|
|||||||
UTEST_ASSERT(error == GMIO_ERROR_NULL_RWARGS);
|
UTEST_ASSERT(error == GMIO_ERROR_NULL_RWARGS);
|
||||||
|
|
||||||
error = GMIO_ERROR_OK;
|
error = GMIO_ERROR_OK;
|
||||||
rwargs.memblock = gmio_memblock(&buff[0], GMIO_STLB_MIN_CONTENTS_SIZE / 2, NULL);
|
rwargs.stream_memblock =
|
||||||
|
gmio_memblock(&buff[0], GMIO_STLB_MIN_CONTENTS_SIZE / 2, NULL);
|
||||||
UTEST_ASSERT(!gmio_stlb_check_params(&error, &rwargs, GMIO_ENDIANNESS_HOST));
|
UTEST_ASSERT(!gmio_stlb_check_params(&error, &rwargs, GMIO_ENDIANNESS_HOST));
|
||||||
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
UTEST_ASSERT(error == GMIO_ERROR_INVALID_MEMBLOCK_SIZE);
|
||||||
|
|
||||||
error = GMIO_ERROR_OK;
|
error = GMIO_ERROR_OK;
|
||||||
rwargs.memblock = gmio_memblock(&buff[0], sizeof(buff), NULL);
|
rwargs.stream_memblock =
|
||||||
|
gmio_memblock(&buff[0], sizeof(buff), NULL);
|
||||||
UTEST_ASSERT(gmio_stlb_check_params(&error, &rwargs, GMIO_ENDIANNESS_HOST));
|
UTEST_ASSERT(gmio_stlb_check_params(&error, &rwargs, GMIO_ENDIANNESS_HOST));
|
||||||
UTEST_ASSERT(error == GMIO_ERROR_OK);
|
UTEST_ASSERT(error == GMIO_ERROR_OK);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user