helper functions to create vector & matrix definitions */
| 2729 | |
| 2730 | /* helper functions to create vector & matrix definitions */ |
| 2731 | bv_object_info* lib_add_vec(bv_library* lib, const char* name, u8 comp, u8 logNot) |
| 2732 | { |
| 2733 | bv_object_info* vec = bv_object_info_create(name); |
| 2734 | |
| 2735 | if (comp >= 1) bv_object_info_add_property(vec, "x"); |
| 2736 | if (comp >= 2) bv_object_info_add_property(vec, "y"); |
| 2737 | if (comp >= 3) bv_object_info_add_property(vec, "z"); |
| 2738 | if (comp >= 4) bv_object_info_add_property(vec, "w"); |
| 2739 | |
| 2740 | bv_object_info_add_ext_method(vec, name, lib_common_vec_constructor); |
| 2741 | |
| 2742 | bv_object_info_add_ext_method(vec, "==", lib_common_vec_operator_equal); |
| 2743 | bv_object_info_add_ext_method(vec, "+", lib_common_vec_operator_add); |
| 2744 | bv_object_info_add_ext_method(vec, "-", lib_common_vec_operator_minus); |
| 2745 | bv_object_info_add_ext_method(vec, ">", lib_common_vec_operator_greater); |
| 2746 | bv_object_info_add_ext_method(vec, "/", lib_common_vec_operator_divide); |
| 2747 | bv_object_info_add_ext_method(vec, "*", lib_common_vec_operator_multiply); |
| 2748 | bv_object_info_add_ext_method(vec, "++", lib_common_vec_operator_increment); |
| 2749 | bv_object_info_add_ext_method(vec, "--", lib_common_vec_operator_decrement); |
| 2750 | bv_object_info_add_ext_method(vec, "[]", lib_common_vec_operator_array_get); |
| 2751 | bv_object_info_add_ext_method(vec, "[]=", lib_common_vec_operator_array_set); |
| 2752 | if (logNot) bv_object_info_add_ext_method(vec, "!", lib_common_vec_operator_logical_not); |
| 2753 | |
| 2754 | bv_library_add_object_info(lib, vec); |
| 2755 | |
| 2756 | return vec; |
| 2757 | } |
| 2758 | bv_object_info* lib_add_mat(bv_library* lib, const char* name) |
| 2759 | { |
| 2760 | bv_object_info* mat = bv_object_info_create(name); |