Skip to content

Commit

Permalink
Fixed some mistakes in makefile and defines.h
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Feb 10, 2022
1 parent c50ac99 commit 43d01b5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
13 changes: 2 additions & 11 deletions include/hpml/defines.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

#pragma once

#ifdef __cplusplus
# include <cstdint>
# include <cstdio>
#else
# include <stdint.h>
# include <stdio.h>
#endif
#include <stdint.h>
#include <stdio.h>

typedef uint16_t u16;
typedef int16_t s16;
Expand All @@ -21,10 +16,6 @@ typedef int64_t s64;
typedef uint8_t u8;
typedef int8_t s8;

#ifndef __cplusplus
#define nullptr NULL
#endif

#define IGNORE_CONST(type, value) *(type*)(&value)

#ifdef GLOBAL_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion include/hpml/vec2/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ HPML_API vec2_t(T) vec2(T)(T x, T y)\
/* See: vec2_null
*/
#define instantiate_implementation_vec2_zero(T) instantiate_implementation_vec2_null(T)
HPML_API

/* vec2_null: Creates a vector2 object in memory having x = 0, and y = 0
* returns: vec2_t(T) vector having x = 0, y = 0
*/
Expand Down
14 changes: 13 additions & 1 deletion include/hpml/vec4/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef struct\
/*vec4_right*/
#define vec4_right(T) c_template(vec4_right, T)
#define instantiate_declaration_vec4_right(T) HPML_API vec4_t(T) vec4_right(T)()
#define instantiate_implementation_vec4_right(T) HPML_API vec4_t(T) vec4_right(T)() { return (vec4_t(T)) { -1, 0, 0, 0 }; }
#define instantiate_implementation_vec4_right(T) HPML_API vec4_t(T) vec4_right(T)() { return (vec4_t(T)) { 1, 0, 0, 0 }; }

/*vec4_left*/
#define vec4_left(T) c_template(vec4_left, T)
Expand All @@ -70,6 +70,11 @@ typedef struct\
#define instantiate_declaration_vec4_back(T) HPML_API vec4_t(T) vec4_back(T)()
#define instantiate_implementation_vec4_back(T) HPML_API vec4_t(T) vec4_back(T)() { return (vec4_t(T)) { 0, 0, 1, 0 }; }

/*vec4_one*/
#define vec4_one(T) c_template(vec4_one, T)
#define instantiate_declaration_vec4_one(T) HPML_API vec4_t(T) vec4_one(T)()
#define instantiate_implementation_vec4_one(T) HPML_API vec4_t(T) vec4_one(T)() { return (vec4_t(T)) { 1, 1, 1, 1 }; }


/*ARITHMETIC*/
/*vec4_add*/
Expand Down Expand Up @@ -363,6 +368,13 @@ EXCEPTION_BLOCK\
return (v.x == 0) && (v.y == 0) && (v.z == 0) && (v.w == 0);\
}

#define vec4_is_equal(T) c_template(vec4_is_equal, T)
#define instantiate_declaration_vec4_is_equal(T) HPML_API bool vec4_is_equal(T)(vec4_t(T) v1, vec4_t(T) v2)
#define instantiate_implementation_vec4_is_equal(T) HPML_API bool vec4_is_equal(T)(vec4_t(T) v1, vec4_t(T) v2)\
{\
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);\
}

/*DEBUGGING*/

/*vec4_print*/
Expand Down
17 changes: 16 additions & 1 deletion include/hpml/vec4/template_instantiations.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C" {
instantiate_vec4_struct(int);
instantiate_declaration_vec4(int);
instantiate_declaration_vec4_zero(int);
instantiate_declaration_vec4_one(int);
instantiate_declaration_vec4_add(int);
instantiate_declaration_vec4_sub(int);
instantiate_declaration_vec4_mul(int);
Expand All @@ -26,11 +27,14 @@ instantiate_declaration_vec4_right(int);
instantiate_declaration_vec4_forward(int);
instantiate_declaration_vec4_back(int);
instantiate_declaration_vec4_is_null(int);
instantiate_declaration_vec4_is_equal(int);

instantiate_declaration_vec4_print(int);
instantiate_declaration_vec4_normalize(int);
instantiate_declaration_vec4_magnitude(int);
instantiate_declaration_vec4_sqrmagnitude(int);
instantiate_declaration_vec4_angle(int);
instantiate_declaration_vec4_unit_angle(int);
instantiate_declaration_vec4_scale(int);
instantiate_declaration_vec4_dot(int);
instantiate_declaration_vec4_cross(int);
Expand All @@ -41,11 +45,11 @@ instantiate_declaration_vec4_axis_rotate(int);
instantiate_declaration_vec4_box(int);
instantiate_declaration_vec4_project(int);
instantiate_declaration_vec4_unit_project(int);
instantiate_declaration_vec4_is_null(int);

instantiate_vec4_struct(float);
instantiate_declaration_vec4(float);
instantiate_declaration_vec4_zero(float);
instantiate_declaration_vec4_one(float);
instantiate_declaration_vec4_add(float);
instantiate_declaration_vec4_sub(float);
instantiate_declaration_vec4_mul(float);
Expand All @@ -61,11 +65,14 @@ instantiate_declaration_vec4_right(float);
instantiate_declaration_vec4_forward(float);
instantiate_declaration_vec4_back(float);
instantiate_declaration_vec4_is_null(float);
instantiate_declaration_vec4_is_equal(float);

instantiate_declaration_vec4_print(float);
instantiate_declaration_vec4_normalize(float);
instantiate_declaration_vec4_magnitude(float);
instantiate_declaration_vec4_sqrmagnitude(float);
instantiate_declaration_vec4_angle(float);
instantiate_declaration_vec4_unit_angle(float);
instantiate_declaration_vec4_scale(float);
instantiate_declaration_vec4_dot(float);
instantiate_declaration_vec4_cross(float);
Expand All @@ -80,6 +87,7 @@ instantiate_declaration_vec4_unit_project(float);
#if defined(IMPLEMENTATION)
instantiate_implementation_vec4(int);
instantiate_implementation_vec4_zero(int);
instantiate_implementation_vec4_one(int);
instantiate_implementation_vec4_add(int);
instantiate_implementation_vec4_sub(int);
instantiate_implementation_vec4_mul(int);
Expand All @@ -95,11 +103,14 @@ instantiate_implementation_vec4_right(int);
instantiate_implementation_vec4_forward(int);
instantiate_implementation_vec4_back(int);
instantiate_implementation_vec4_is_null(int);
instantiate_implementation_vec4_is_equal(int);

HPML_API void vec4_print(int)(vec4_t(int) v) { printf("vec4_t(int): { %d, %d, %d, %d }\n", v.x, v.y, v.z, v.w); }
instantiate_implementation_vec4_normalize(int);
instantiate_implementation_vec4_magnitude(int);
instantiate_implementation_vec4_sqrmagnitude(int);
instantiate_implementation_vec4_angle(int);
instantiate_implementation_vec4_unit_angle(int);
instantiate_implementation_vec4_scale(int);
instantiate_implementation_vec4_dot(int);
instantiate_implementation_vec4_cross(int);
Expand All @@ -113,6 +124,7 @@ instantiate_implementation_vec4_unit_project(int);

instantiate_implementation_vec4(float);
instantiate_implementation_vec4_zero(float);
instantiate_implementation_vec4_one(float);
instantiate_implementation_vec4_add(float);
instantiate_implementation_vec4_sub(float);
instantiate_implementation_vec4_mul(float);
Expand All @@ -128,11 +140,14 @@ instantiate_implementation_vec4_right(float);
instantiate_implementation_vec4_forward(float);
instantiate_implementation_vec4_back(float);
instantiate_implementation_vec4_is_null(float);
instantiate_implementation_vec4_is_equal(float);

HPML_API void vec4_print(float)(vec4_t(float) v) { printf("vec4_t(float): { %f, %f, %f, %f }\n", v.x, v.y, v.z, v.w); }
instantiate_implementation_vec4_normalize(float);
instantiate_implementation_vec4_magnitude(float);
instantiate_implementation_vec4_sqrmagnitude(float);
instantiate_implementation_vec4_angle(float);
instantiate_implementation_vec4_unit_angle(float);
instantiate_implementation_vec4_scale(float);
instantiate_implementation_vec4_dot(float);
instantiate_implementation_vec4_cross(float);
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ lib-dynamic-release: $(TARGET_DYNAMIC_LIB)
lib-static-dynamic: lib-static-dynamic-release
lib-static-dynamic-debug: DEFINES += $(DEBUG_DEFINES) -DBUILD_DYNAMIC_LIBRARY
lib-static-dynamic-debug: __STATIC_LIB_COMMAND = lib-static-dynamic-debug
lib-static-dynamic-debug: COMPILER_FLAGS += -g
lib-static-dynamic-debug: COMPILER_FLAGS += -g -fPIC
lib-static-dynamic-debug: $(TARGET_STATIC_LIB)
lib-static-dynamic-release: DEFINES += $(RELEASE_DEFINES) -DBUILD_DYNAMIC_LIBRARY
lib-static-dynamic-release: __STATIC_LIB_COMMAND = lib-static-dynamic-release
lib-static-dynamic-release: COMPILER_FLAGS += -g
lib-static-dynamic-release: COMPILER_FLAGS += -fPIC
lib-static-dynamic-release: $(TARGET_STATIC_LIB)

release: DEFINES += $(RELEASE_DEFINES) -DBUILD_EXECUTABLE
Expand Down

0 comments on commit 43d01b5

Please sign in to comment.