Skip to content

Commit

Permalink
chore: reduce warning on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-takeuchi committed May 2, 2019
1 parent 5c9246e commit 35de59b
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 697 deletions.
351 changes: 58 additions & 293 deletions src/DlibDotNet.Native/dlib/matrix/matrix_op/op_std_vect_to_mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,328 +7,93 @@
#include <dlib/matrix.h>
#include <dlib/image_processing/generic_image.h>
#include <dlib/image_transforms/colormaps.h>
#include "../../template.h"
#include "../../shared.h"

using namespace dlib;
using namespace std;

#pragma region template

#define ELEMENT_IN element
#undef ELEMENT_IN
#define matrix_op_op_std_vect_to_mat_delete_template(__TYPE__, error, __ELEMENT_TYPE__, __ROWS__, __COLUMNS__, ...) \
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<__TYPE__, __ROWS__, __COLUMNS__>, allocator<matrix<__TYPE__, __ROWS__, __COLUMNS__>>>>>*>(obj);\
delete mat;\

#define matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns) \
do {\
if (templateRows == 0 && templateColumns == 0)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN>, allocator<matrix<ELEMENT_IN>>>>>*>(obj);\
delete mat;\
}\
else if (templateRows == 0 && templateColumns == 1)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN, 0, 1>, allocator<matrix<ELEMENT_IN, 0, 1>>>>>*>(obj);\
delete mat;\
}\
} while (0)
#define matrix_op_op_std_vect_to_mat_nc_template(__TYPE__, error, __ELEMENT_TYPE__, __ROWS__, __COLUMNS__, ...) \
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<__TYPE__, __ROWS__, __COLUMNS__>, allocator<matrix<__TYPE__, __ROWS__, __COLUMNS__>>>>>*>(obj);\
*ret = mat->nc();\

#define matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret) \
do {\
if (templateRows == 0 && templateColumns == 0)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN>, allocator<matrix<ELEMENT_IN>>>>>*>(obj);\
*ret = mat->nc();\
}\
else if (templateRows == 0 && templateColumns == 1)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN, 0, 1>, allocator<matrix<ELEMENT_IN, 0, 1>>>>>*>(obj);\
*ret = mat->nc();\
}\
} while (0)
#define matrix_op_op_std_vect_to_mat_nr_template(__TYPE__, error, __ELEMENT_TYPE__, __ROWS__, __COLUMNS__, ...) \
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<__TYPE__, __ROWS__, __COLUMNS__>, allocator<matrix<__TYPE__, __ROWS__, __COLUMNS__>>>>>*>(obj);\
*ret = mat->nr();\

#define matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret) \
do {\
if (templateRows == 0 && templateColumns == 0)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN>, allocator<matrix<ELEMENT_IN>>>>>*>(obj);\
*ret = mat->nr();\
}\
else if (templateRows == 0 && templateColumns == 1)\
{\
auto mat = static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN, 0, 1>, allocator<matrix<ELEMENT_IN, 0, 1>>>>>*>(obj);\
*ret = mat->nr();\
}\
} while (0)

#define matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream) \
do {\
if (templateRows == 0 && templateColumns == 0)\
{\
matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN>, allocator<matrix<ELEMENT_IN>>>>>& mat = *(static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN>, allocator<matrix<ELEMENT_IN>>>>>*>(obj));\
*stream << mat;\
}\
else if (templateRows == 0 && templateColumns == 1)\
{\
matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN, 0, 1>, allocator<matrix<ELEMENT_IN, 0, 1>>>>>& mat = *(static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<ELEMENT_IN, 0, 1>, allocator<matrix<ELEMENT_IN, 0, 1>>>>>*>(obj));\
*stream << mat;\
}\
} while (0)
#define matrix_op_op_std_vect_to_mat_operator_left_shift_template(__TYPE__, error, __ELEMENT_TYPE__, __ROWS__, __COLUMNS__, ...) \
auto& mat = *(static_cast<matrix_op<op_std_vect_to_mat<std::vector<matrix<__TYPE__, __ROWS__, __COLUMNS__>, allocator<matrix<__TYPE__, __ROWS__, __COLUMNS__>>>>>*>(obj));\
*stream << mat;\

#pragma endregion template

DLLEXPORT void matrix_op_op_std_vect_to_mat_delete(matrix_element_type type, void* obj, const int templateRows, const int templateColumns)
{
switch(type)
{
case matrix_element_type::UInt8:
#define ELEMENT_IN uint8_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt16:
#define ELEMENT_IN uint16_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt32:
#define ELEMENT_IN uint32_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::Int8:
#define ELEMENT_IN int8_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::Int16:
#define ELEMENT_IN int16_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::Int32:
#define ELEMENT_IN int32_t
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::Float:
#define ELEMENT_IN float
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::Double:
#define ELEMENT_IN double
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbPixel:
#define ELEMENT_IN rgb_pixel
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::HsiPixel:
#define ELEMENT_IN hsi_pixel
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbAlphaPixel:
#define ELEMENT_IN rgb_alpha_pixel
matrix_op_op_std_vect_to_mat_delete_template(obj, templateRows, templateColumns);
#undef ELEMENT_IN
break;
}
int error = ERR_OK;

matrix_template(type,
error,
matrix_template_size_template,
matrix_op_op_std_vect_to_mat_delete_template,
templateRows,
templateColumns,
obj);
}

DLLEXPORT int matrix_op_op_std_vect_to_mat_nc(matrix_element_type type, void* obj, const int templateRows, const int templateColumns, int* ret)
{
int err = ERR_OK;
switch(type)
{
case matrix_element_type::UInt8:
#define ELEMENT_IN uint8_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt16:
#define ELEMENT_IN uint16_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt32:
#define ELEMENT_IN uint32_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int8:
#define ELEMENT_IN int8_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int16:
#define ELEMENT_IN int16_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int32:
#define ELEMENT_IN int32_t
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Float:
#define ELEMENT_IN float
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Double:
#define ELEMENT_IN double
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbPixel:
#define ELEMENT_IN rgb_pixel
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::HsiPixel:
#define ELEMENT_IN hsi_pixel
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbAlphaPixel:
#define ELEMENT_IN rgb_alpha_pixel
matrix_op_op_std_vect_to_mat_nc_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
default:
err = ERR_MATRIX_ELEMENT_TYPE_NOT_SUPPORT;
break;
}

return err;
int error = ERR_OK;

matrix_template(type,
error,
matrix_template_size_template,
matrix_op_op_std_vect_to_mat_nc_template,
templateRows,
templateColumns,
obj,
ret);

return error;
}

DLLEXPORT int matrix_op_op_std_vect_to_mat_nr(matrix_element_type type, void* obj, const int templateRows, const int templateColumns, int* ret)
{
int err = ERR_OK;
switch(type)
{
case matrix_element_type::UInt8:
#define ELEMENT_IN uint8_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt16:
#define ELEMENT_IN uint16_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt32:
#define ELEMENT_IN uint32_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int8:
#define ELEMENT_IN int8_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int16:
#define ELEMENT_IN int16_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Int32:
#define ELEMENT_IN int32_t
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Float:
#define ELEMENT_IN float
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::Double:
#define ELEMENT_IN double
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbPixel:
#define ELEMENT_IN rgb_pixel
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::HsiPixel:
#define ELEMENT_IN hsi_pixel
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbAlphaPixel:
#define ELEMENT_IN rgb_alpha_pixel
matrix_op_op_std_vect_to_mat_nr_template(obj, templateRows, templateColumns, ret);
#undef ELEMENT_IN
break;
default:
err = ERR_MATRIX_ELEMENT_TYPE_NOT_SUPPORT;
break;
}

return err;
int error = ERR_OK;

matrix_template(type,
error,
matrix_template_size_template,
matrix_op_op_std_vect_to_mat_nr_template,
templateRows,
templateColumns,
obj,
ret);

return error;
}

#pragma region operator

DLLEXPORT int matrix_op_op_std_vect_to_mat_operator_left_shift(matrix_element_type type, void* obj, const int templateRows, const int templateColumns, std::ostringstream* stream)
{
int err = ERR_OK;
switch(type)
{
case matrix_element_type::UInt8:
#define ELEMENT_IN uint8_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt16:
#define ELEMENT_IN uint16_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::UInt32:
#define ELEMENT_IN uint32_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::Int8:
#define ELEMENT_IN int8_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::Int16:
#define ELEMENT_IN int16_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::Int32:
#define ELEMENT_IN int32_t
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::Float:
#define ELEMENT_IN float
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::Double:
#define ELEMENT_IN double
matrix_op_op_std_vect_to_mat_operator_left_shift_template(obj, templateRows, templateColumns, stream);
#undef ELEMENT_IN
break;
case matrix_element_type::RgbPixel:
case matrix_element_type::HsiPixel:
case matrix_element_type::RgbAlphaPixel:
default:
err = ERR_MATRIX_ELEMENT_TYPE_NOT_SUPPORT;
break;
}

return err;
int error = ERR_OK;

matrix_numeric_template(type,
error,
matrix_template_size_template,
matrix_op_op_std_vect_to_mat_operator_left_shift_template,
templateRows,
templateColumns,
obj,
stream);

return error;
}

#pragma endregion oprator
Expand Down
Loading

0 comments on commit 35de59b

Please sign in to comment.