Skip to content

Commit

Permalink
Fixed template and typename keyword conflict with c++
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Feb 6, 2022
1 parent c265a2b commit e42c580
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 172 deletions.
36 changes: 18 additions & 18 deletions include/hpml/affine_transformation/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
/*Begin: Template Definitions*/

/* Begin: template signatures*/
#define mat4_mul_vec4(T) template(mat4_mul_vec4, T)
#define mat4_translation(T) template(mat4_translation, T)
#define mat4_scale(T) template(mat4_scale, T)
#define mat4_axis_rotation(T) template(mat4_axis_rotation, T)
#define mat4_mul_vec4(T) c_template(mat4_mul_vec4, T)
#define mat4_translation(T) c_template(mat4_translation, T)
#define mat4_scale(T) c_template(mat4_scale, T)
#define mat4_axis_rotation(T) c_template(mat4_axis_rotation, T)

/*mat4_rotation*/
#define mat4_rotation(T) template(mat4_rotation, T)
#define mat4_rotation(T) c_template(mat4_rotation, T)
#define instantiate_declaration_mat4_rotation(T) HPML_API mat4_t(T) mat4_rotation(T)(T x, T y, T z)
#define instantiate_implementation_mat4_rotation(T) HPML_API mat4_t(T) mat4_rotation(T)(T x, T y, T z)\
{\
return mat4_mul(T)(3, mat4_rotation_x(T)(x), mat4_rotation_y(T)(y), mat4_rotation_z(T)(z));\
}

/*mat4_ortho_projection*/
#define mat4_ortho_projection(T) template(mat4_ortho_projection, T)
#define mat4_ortho_projection(T) c_template(mat4_ortho_projection, T)
#define instantiate_declaration_mat4_ortho_projection(T) HPML_API mat4_t(T) mat4_ortho_projection(T)(float nearClipPlane, float farClipPlane, float height, float aspectRatio)
#define instantiate_implementation_mat4_ortho_projection(T) HPML_API mat4_t(T) mat4_ortho_projection(T)(float nearClipPlane, float farClipPlane, float height, float aspectRatio)\
{\
Expand Down Expand Up @@ -59,7 +59,7 @@ EXCEPTION_BLOCK\

/*mat4_persp_projection*/
//TODO: This matrix doesn't give correct depth values in the range [-1, 1], to be fixed
#define mat4_persp_projection(T) template(mat4_persp_projection, T)
#define mat4_persp_projection(T) c_template(mat4_persp_projection, T)
#define instantiate_declaration_mat4_persp_projection(T) HPML_API mat4_t(T) mat4_persp_projection(T)(float nearClipPlane, float farClipPlane, float fieldOfView, float aspectRatio)
#define instantiate_implementation_mat4_persp_projection(T) HPML_API mat4_t(T) mat4_persp_projection(T)(float nearClipPlane, float farClipPlane, float fieldOfView, float aspectRatio)\
{\
Expand Down Expand Up @@ -92,17 +92,17 @@ EXCEPTION_BLOCK\
};\
}

#define mat4_shear(T) template(mat4_shear, T)
#define mat4_reflection(T) template(mat4_reflection, T)
#define mat4_shear_xy(T) template(mat4_shear_xy, T)
#define mat4_shear_yx(T) template(mat4_shear_yx, T)
#define mat4_shear_zx(T) template(mat4_shear_zx, T)
#define mat4_shear_xz(T) template(mat4_shear_xz, T)
#define mat4_shear_yz(T) template(mat4_shear_yz, T)
#define mat4_shear_zy(T) template(mat4_shear_zy, T)
#define mat4_rotation_x(T) template(mat4_rotation_x, T)
#define mat4_rotation_y(T) template(mat4_rotation_y, T)
#define mat4_rotation_z(T) template(mat4_rotation_z, T)
#define mat4_shear(T) c_template(mat4_shear, T)
#define mat4_reflection(T) c_template(mat4_reflection, T)
#define mat4_shear_xy(T) c_template(mat4_shear_xy, T)
#define mat4_shear_yx(T) c_template(mat4_shear_yx, T)
#define mat4_shear_zx(T) c_template(mat4_shear_zx, T)
#define mat4_shear_xz(T) c_template(mat4_shear_xz, T)
#define mat4_shear_yz(T) c_template(mat4_shear_yz, T)
#define mat4_shear_zy(T) c_template(mat4_shear_zy, T)
#define mat4_rotation_x(T) c_template(mat4_rotation_x, T)
#define mat4_rotation_y(T) c_template(mat4_rotation_y, T)
#define mat4_rotation_z(T) c_template(mat4_rotation_z, T)
/* End: template signatures*/


Expand Down
36 changes: 18 additions & 18 deletions include/hpml/mat2/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@

/*Begin: Template Definitions*/
/*template signatures*/
#define mat2_t(T) template(mat2_t, T)
#define mat2(T) template(mat2, T)
#define mat2_add(T) template(mat2_add, T)
#define mat2_sub(T) template(mat2_sub, T)
#define mat2_mul(T) template(mat2_mul, T)
#define mat2_mul_component_wise(T) template(mat2_mul_component_wise, T)
#define mat2_div(T) template(mat2_div, T)
#define mat2_is_null(T) template(mat2_is_null, T)
#define mat2_is_equal(T) template(mat2_is_equal, T)
#define mat2_t(T) c_template(mat2_t, T)
#define mat2(T) c_template(mat2, T)
#define mat2_add(T) c_template(mat2_add, T)
#define mat2_sub(T) c_template(mat2_sub, T)
#define mat2_mul(T) c_template(mat2_mul, T)
#define mat2_mul_component_wise(T) c_template(mat2_mul_component_wise, T)
#define mat2_div(T) c_template(mat2_div, T)
#define mat2_is_null(T) c_template(mat2_is_null, T)
#define mat2_is_equal(T) c_template(mat2_is_equal, T)
#define mat2_null(T) mat2(T)(0, 0, 0, 0)
#define mat2_zero(T) mat2_null(T)
#define mat2_print(T) template(mat2_print, T)
#define mat2_negate(T) template(mat2_negate, T)
#define mat2_identity(T) template(mat2_identity, T)
#define mat2_lerp(T) template(mat2_lerp, T)
#define mat2_mul_with_scalar(T) template(mat2_mul_with_scalar, T)
#define mat2_inverse(T) template(mat2_inverse, T)
#define mat2_transpose(T) template(mat2_transpose, T)
#define mat2_trace(T) template(mat2_trace, T)
#define mat2_rotation(T) template(mat2_rotation, T)
#define mat2_print(T) c_template(mat2_print, T)
#define mat2_negate(T) c_template(mat2_negate, T)
#define mat2_identity(T) c_template(mat2_identity, T)
#define mat2_lerp(T) c_template(mat2_lerp, T)
#define mat2_mul_with_scalar(T) c_template(mat2_mul_with_scalar, T)
#define mat2_inverse(T) c_template(mat2_inverse, T)
#define mat2_transpose(T) c_template(mat2_transpose, T)
#define mat2_trace(T) c_template(mat2_trace, T)
#define mat2_rotation(T) c_template(mat2_rotation, T)

#define instantiate_mat2_struct(T)\
typedef struct mat2_t(T)\
Expand Down
44 changes: 22 additions & 22 deletions include/hpml/mat4/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/*Begin: Template Definitions*/
/*template signatures*/
#define mat4_t(T) template(mat4_t, T)
#define mat4(T) template(mat4, T)
#define mat4_t(T) c_template(mat4_t, T)
#define mat4(T) c_template(mat4, T)


/*mat4_data*/
#define __mat4_data(T) template(__mat4_data, T)
#define __mat4_data(T) c_template(__mat4_data, T)
#define mat4_data(T) __mat4_data(T)
#define instantiate_declaration_mat4_data(T) HPML_API T* const* const __mat4_data(T)(mat4_t(T)* m)
#define instantiate_implementation_mat4_data(T)\
Expand All @@ -43,7 +43,7 @@ HPML_API T* const* const __mat4_data(T)(mat4_t(T)* m)\
#define instantiate_implementation_mat4_copy(T) instantiate_implementation_copy(mat4_t(T))

/*mat4_determinant*/
#define mat4_det(T) template(mat4_det, T)
#define mat4_det(T) c_template(mat4_det, T)
#define mat4_determinant(T) mat4_det(T)
#define instantiate_declaration_mat4_det(T) HPML_API T mat4_det(T)(mat4_t(T) m)
#define instantiate_implementation_mat4_det(T)\
Expand All @@ -61,8 +61,8 @@ HPML_API T mat4_det(T)(mat4_t(T) m)\
* mat4_t(T) m2: right side matrix in mulitplication
* returns: mat4_t(T) resultant matrix
*/
#define mat4_mul(T) template(mat4_mul, T)
#define __mat4_mul(T) template(__mat4_mul, T)
#define mat4_mul(T) c_template(mat4_mul, T)
#define __mat4_mul(T) c_template(__mat4_mul, T)
#define instantiate_declaration_mat4_mul(T)\
HPML_API mat4_t(T) __mat4_mul(T)(mat4_t(T) m1, mat4_t(T) m2);\
HPML_API mat4_t(T) mat4_mul(T)(uint32_t count, ...)
Expand Down Expand Up @@ -104,7 +104,7 @@ HPML_API mat4_t(T) mat4_mul(T)(uint32_t count, ...)\
return result;\
}

#define mat4_build_cofactor(T) template(mat4_build_cofactor, T)
#define mat4_build_cofactor(T) c_template(mat4_build_cofactor, T)
// #define mat4_build_cofactor(m, out_mptr, row, column) mat4_build_cofactor(mat4_data(&m), __mat4_data(out_mptr), 4, row, column)
#define instantiate_declaration_mat4_build_cofactor(T) HPML_API void mat4_build_cofactor(T)(mat4_t(T) m, T* const* const cofactorMatrix, u32 row, u32 column)
#define instantiate_implementation_mat4_build_cofactor(T) HPML_API void mat4_build_cofactor(T)(mat4_t(T) m, T* const* const cofactorMatrix, u32 row, u32 column)\
Expand All @@ -122,23 +122,23 @@ HPML_API mat4_t(T) mat4_mul(T)(uint32_t count, ...)\
}


#define mat4_add(T) template(mat4_add, T)
#define mat4_sub(T) template(mat4_sub, T)
#define mat4_mul_component_wise(T) template(mat4_mul_component_wise, T)
#define mat4_div(T) template(mat4_div, T)
#define mat4_is_null(T) template(mat4_is_null, T)
#define mat4_is_equal(T) template(mat4_is_equal, T)
#define mat4_add(T) c_template(mat4_add, T)
#define mat4_sub(T) c_template(mat4_sub, T)
#define mat4_mul_component_wise(T) c_template(mat4_mul_component_wise, T)
#define mat4_div(T) c_template(mat4_div, T)
#define mat4_is_null(T) c_template(mat4_is_null, T)
#define mat4_is_equal(T) c_template(mat4_is_equal, T)
#define mat4_null(T) mat4(T)(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
#define mat4_zero(T) mat4_null(T)
#define mat4_print(T) template(mat4_print, T)
#define mat4_negate(T) template(mat4_negate, T)
#define mat4_identity(T) template(mat4_identity, T)
#define mat4_lerp(T) template(mat4_lerp, T)
#define mat4_mul_scalar(T) template(mat4_mul_scalar, T)
#define mat4_inverse(T) template(mat4_inverse, T)
#define mat4_transpose(T) template(mat4_transpose, T)
#define mat4_trace(T) template(mat4_trace, T)
#define mat4_diagonal(T) template(mat4_diagonal, T)
#define mat4_print(T) c_template(mat4_print, T)
#define mat4_negate(T) c_template(mat4_negate, T)
#define mat4_identity(T) c_template(mat4_identity, T)
#define mat4_lerp(T) c_template(mat4_lerp, T)
#define mat4_mul_scalar(T) c_template(mat4_mul_scalar, T)
#define mat4_inverse(T) c_template(mat4_inverse, T)
#define mat4_transpose(T) c_template(mat4_transpose, T)
#define mat4_trace(T) c_template(mat4_trace, T)
#define mat4_diagonal(T) c_template(mat4_diagonal, T)

#define instantiate_mat4_struct(T)\
typedef struct mat4_t(T)\
Expand Down
2 changes: 1 addition & 1 deletion include/hpml/memory/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define EXTERN_C
#endif

#define move(T) template(move, T)
#define move(T) c_template(move, T)
#define instantiate_declaration_move(T) EXTERN_C HPML_API void move(T)(T* dst, T src)
#define instantiate_implementation_move(T)\
EXTERN_C HPML_API void move(T)(T* dst, T src)\
Expand Down
16 changes: 8 additions & 8 deletions include/hpml/quat/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include <math.h>

/* Begin: template signatures*/
#define quat_t(T) template(quat_t, T)
#define quat(T) template(quat, T)
#define quat_add(T) template(quat_add, T)
#define quat_sub(T) template(quat_sub, T)
#define quat_mul(T) template(quat_mul, T)
#define quat_div(T) template(quat_div, T)
#define quat_mul_component_wise(T) template(quat_mul_component_wise, T)
#define quat_t(T) c_template(quat_t, T)
#define quat(T) c_template(quat, T)
#define quat_add(T) c_template(quat_add, T)
#define quat_sub(T) c_template(quat_sub, T)
#define quat_mul(T) c_template(quat_mul, T)
#define quat_div(T) c_template(quat_div, T)
#define quat_mul_component_wise(T) c_template(quat_mul_component_wise, T)
#define quat_identity(T) NOT_IMPLEMENTED
#define quat_inverse(T) template(quat_inverse, T)
#define quat_inverse(T) c_template(quat_inverse, T)
/* End: template signatures*/

/* Begin: template declarations*/
Expand Down
2 changes: 1 addition & 1 deletion include/hpml/template_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __HPML_TEMPLATE_SYSTEM_H__
#define __HPML_TEMPLATE_SYSTEM_H__

#define template(typename, T) typename##_##T
#define c_template(c_typename, T) c_typename##_##T


#endif/*__HPML_TEMPLATE_SYSTEM_H__*/
66 changes: 33 additions & 33 deletions include/hpml/vec2/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@

/*Begin: Template Definitions*/
/*template signatures*/
#define vec2_t(T) template(vec2_t, T)
#define vec2(T) template(vec2, T)
#define vec2_add(T) template(vec2_add, T)
#define vec2_sub(T) template(vec2_sub, T)
#define vec2_mul(T) template(vec2_mul, T)
#define vec2_div(T) template(vec2_div, T)
#define vec2_is_null(T) template(vec2_is_null, T)
#define vec2_is_equal(T) template(vec2_is_equal, T)
#define vec2_null(T) template(vec2_null, T)
#define vec2_t(T) c_template(vec2_t, T)
#define vec2(T) c_template(vec2, T)
#define vec2_add(T) c_template(vec2_add, T)
#define vec2_sub(T) c_template(vec2_sub, T)
#define vec2_mul(T) c_template(vec2_mul, T)
#define vec2_div(T) c_template(vec2_div, T)
#define vec2_is_null(T) c_template(vec2_is_null, T)
#define vec2_is_equal(T) c_template(vec2_is_equal, T)
#define vec2_null(T) c_template(vec2_null, T)
#define vec2_zero(T) vec2_null(T)
#define vec2_print(T) template(vec2_print, T)
#define vec2_dot(T) template(vec2_dot, T)
// #define vec2_cross(T) template(vec2_cross, T)
#define vec2_magnitude(T) template(vec2_magnitude, T)
#define vec2_sqrmagnitude(T) template(vec2_sqrmagnitude, T)
#define vec2_negate(T) template(vec2_negate, T)
#define vec2_normalize(T) template(vec2_normalize, T)
#define vec2_rotate(T) template(vec2_rotate, T)
#define vec2_angle(T) template(vec2_angle, T)
#define vec2_abs(T) template(vec2_abs, T)
#define vec2_up(T) template(vec2_up, T)
#define vec2_down(T) template(vec2_down, T)
#define vec2_left(T) template(vec2_left, T)
#define vec2_right(T) template(vec2_right, T)
#define vec2_project(T) template(vec2_project, T)
#define vec2_lerp(T) template(vec2_lerp, T)
#define vec2_slerp(T) template(vec2_slerp, T) NOT_IMPLEMENTED
#define vec2_scale(T) template(vec2_scale, T) //vec2_transform(T)(vec2_t(T) v, mat22_t(T) transform)
#define vec2_transform(T) template(vec2_transform, T) NOT_IMPLEMENTED
#define vec2_internal_division(T) template(vec2_internal_division, T)
#define vec2_external_division(T) template(vec2_external_division, T)
#define vec2_normal_anticlockwise(T) template(vec2_normal_anticlockwise, T)
#define vec2_normal_clockwise(T) template(vec2_normal_clockwise, T)
#define vec2_direction_ratios(T) template(vec2_direction_ratios, T) NOT_IMPLEMENTED
#define vec2_print(T) c_template(vec2_print, T)
#define vec2_dot(T) c_template(vec2_dot, T)
// #define vec2_cross(T) c_template(vec2_cross, T)
#define vec2_magnitude(T) c_template(vec2_magnitude, T)
#define vec2_sqrmagnitude(T) c_template(vec2_sqrmagnitude, T)
#define vec2_negate(T) c_template(vec2_negate, T)
#define vec2_normalize(T) c_template(vec2_normalize, T)
#define vec2_rotate(T) c_template(vec2_rotate, T)
#define vec2_angle(T) c_template(vec2_angle, T)
#define vec2_abs(T) c_template(vec2_abs, T)
#define vec2_up(T) c_template(vec2_up, T)
#define vec2_down(T) c_template(vec2_down, T)
#define vec2_left(T) c_template(vec2_left, T)
#define vec2_right(T) c_template(vec2_right, T)
#define vec2_project(T) c_template(vec2_project, T)
#define vec2_lerp(T) c_template(vec2_lerp, T)
#define vec2_slerp(T) c_template(vec2_slerp, T) NOT_IMPLEMENTED
#define vec2_scale(T) c_template(vec2_scale, T) //vec2_transform(T)(vec2_t(T) v, mat22_t(T) transform)
#define vec2_transform(T) c_template(vec2_transform, T) NOT_IMPLEMENTED
#define vec2_internal_division(T) c_template(vec2_internal_division, T)
#define vec2_external_division(T) c_template(vec2_external_division, T)
#define vec2_normal_anticlockwise(T) c_template(vec2_normal_anticlockwise, T)
#define vec2_normal_clockwise(T) c_template(vec2_normal_clockwise, T)
#define vec2_direction_ratios(T) c_template(vec2_direction_ratios, T) NOT_IMPLEMENTED


#define instantiate_vec2_struct(T) \
Expand Down
66 changes: 33 additions & 33 deletions include/hpml/vec3/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@

/*Begin: Template Definitions*/
/*template signatures*/
#define vec3_t(T) template(vec3_t, T)
#define vec3(T) template(vec3, T)
#define vec3_add(T) template(vec3_add, T)
#define vec3_sub(T) template(vec3_sub, T)
#define vec3_mul(T) template(vec3_mul, T)
#define vec3_div(T) template(vec3_div, T)
#define vec3_is_null(T) template(vec3_is_null, T)
#define vec3_is_equal(T) template(vec3_is_equal, T)
#define vec3_null(T) template(vec3_null, T)
#define vec3_t(T) c_template(vec3_t, T)
#define vec3(T) c_template(vec3, T)
#define vec3_add(T) c_template(vec3_add, T)
#define vec3_sub(T) c_template(vec3_sub, T)
#define vec3_mul(T) c_template(vec3_mul, T)
#define vec3_div(T) c_template(vec3_div, T)
#define vec3_is_null(T) c_template(vec3_is_null, T)
#define vec3_is_equal(T) c_template(vec3_is_equal, T)
#define vec3_null(T) c_template(vec3_null, T)
#define vec3_zero(T) vec3_null(T)
#define vec3_print(T) template(vec3_print, T)
#define vec3_dot(T) template(vec3_dot, T)
#define vec3_cross(T) template(vec3_cross, T)
#define vec3_magnitude(T) template(vec3_magnitude, T)
#define vec3_negate(T) template(vec3_negate, T)
#define vec3_normalize(T) template(vec3_normalize, T)
#define vec3_rotate(T) template(vec3_rotate, T) NOT_IMPLEMENTED
#define vec3_angle(T) template(vec3_angle, T)
#define vec3_abs(T) template(vec3_abs, T)
#define vec3_up(T) template(vec3_up, T)
#define vec3_down(T) template(vec3_down, T)
#define vec3_left(T) template(vec3_left, T)
#define vec3_right(T) template(vec3_right, T)
#define vec3_forward(T) template(vec3_forward, T)
#define vec3_backward(T) template(vec3_backward, T)
#define vec3_project(T) template(vec3_project, T)
#define vec3_lerp(T) template(vec3_lerp, T)
#define vec3_slerp(T) template(vec3_slerp, T)
#define vec3_scale(T) template(vec3_scale, T) //vec3_transform(T)(vec3_t(T) v, mat33_t(T) transform)
#define vec3_transform(T) template(vec3_transform, T) NOT_IMPLEMENTED
#define vec3_internal_division(T) template(vec3_internal_division, T)
#define vec3_external_division(T) template(vec3_external_division, T)
#define vec3_direction_ratios(T) template(vec3_direction_ratios, T) NOT_IMPLEMENTED
#define vec3_box(T) template(vec3_box, T) NOT_IMPLEMENTED
#define vec3_print(T) c_template(vec3_print, T)
#define vec3_dot(T) c_template(vec3_dot, T)
#define vec3_cross(T) c_template(vec3_cross, T)
#define vec3_magnitude(T) c_template(vec3_magnitude, T)
#define vec3_negate(T) c_template(vec3_negate, T)
#define vec3_normalize(T) c_template(vec3_normalize, T)
#define vec3_rotate(T) c_template(vec3_rotate, T) NOT_IMPLEMENTED
#define vec3_angle(T) c_template(vec3_angle, T)
#define vec3_abs(T) c_template(vec3_abs, T)
#define vec3_up(T) c_template(vec3_up, T)
#define vec3_down(T) c_template(vec3_down, T)
#define vec3_left(T) c_template(vec3_left, T)
#define vec3_right(T) c_template(vec3_right, T)
#define vec3_forward(T) c_template(vec3_forward, T)
#define vec3_backward(T) c_template(vec3_backward, T)
#define vec3_project(T) c_template(vec3_project, T)
#define vec3_lerp(T) c_template(vec3_lerp, T)
#define vec3_slerp(T) c_template(vec3_slerp, T)
#define vec3_scale(T) c_template(vec3_scale, T) //vec3_transform(T)(vec3_t(T) v, mat33_t(T) transform)
#define vec3_transform(T) c_template(vec3_transform, T) NOT_IMPLEMENTED
#define vec3_internal_division(T) c_template(vec3_internal_division, T)
#define vec3_external_division(T) c_template(vec3_external_division, T)
#define vec3_direction_ratios(T) c_template(vec3_direction_ratios, T) NOT_IMPLEMENTED
#define vec3_box(T) c_template(vec3_box, T) NOT_IMPLEMENTED

#define instantiate_vec3_struct(T) \
typedef struct vec3_t(T)\
Expand Down
Loading

0 comments on commit e42c580

Please sign in to comment.