From 62bb33bae33b4c4479c92be78496c83169e50bb7 Mon Sep 17 00:00:00 2001 From: Rebekah Rowe Date: Tue, 5 Apr 2022 12:06:16 -0400 Subject: [PATCH] Removed vector.c/h vec234.h and utf8-utils.c/h --- ftgl/CMakeLists.txt | 5 - ftgl/utf8-utils.c | 88 --------------- ftgl/utf8-utils.h | 66 ----------- ftgl/vec234.h | 221 ------------------------------------ ftgl/vector.c | 270 -------------------------------------------- ftgl/vector.h | 270 -------------------------------------------- 6 files changed, 920 deletions(-) delete mode 100644 ftgl/utf8-utils.c delete mode 100644 ftgl/utf8-utils.h delete mode 100644 ftgl/vec234.h delete mode 100644 ftgl/vector.c delete mode 100644 ftgl/vector.h diff --git a/ftgl/CMakeLists.txt b/ftgl/CMakeLists.txt index 2e6a5b0..f167006 100644 --- a/ftgl/CMakeLists.txt +++ b/ftgl/CMakeLists.txt @@ -3,9 +3,6 @@ target_sources(glez PRIVATE "${CMAKE_CURRENT_LIST_DIR}/mat4.h" "${CMAKE_CURRENT_LIST_DIR}/texture-atlas.h" "${CMAKE_CURRENT_LIST_DIR}/texture-font.h" - "${CMAKE_CURRENT_LIST_DIR}/utf8-utils.h" - "${CMAKE_CURRENT_LIST_DIR}/vec234.h" - "${CMAKE_CURRENT_LIST_DIR}/vector.h" "${CMAKE_CURRENT_LIST_DIR}/vertex-attribute.h" "${CMAKE_CURRENT_LIST_DIR}/vertex-buffer.h") @@ -13,7 +10,5 @@ target_sources(glez PRIVATE "${CMAKE_CURRENT_LIST_DIR}/mat4.c" "${CMAKE_CURRENT_LIST_DIR}/texture-atlas.c" "${CMAKE_CURRENT_LIST_DIR}/texture-font.c" - "${CMAKE_CURRENT_LIST_DIR}/utf8-utils.c" - "${CMAKE_CURRENT_LIST_DIR}/vector.c" "${CMAKE_CURRENT_LIST_DIR}/vertex-attribute.c" "${CMAKE_CURRENT_LIST_DIR}/vertex-buffer.c") \ No newline at end of file diff --git a/ftgl/utf8-utils.c b/ftgl/utf8-utils.c deleted file mode 100644 index 677680a..0000000 --- a/ftgl/utf8-utils.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Freetype GL - A C OpenGL Freetype engine - * - * Distributed under the OSI-approved BSD 2-Clause License. See accompanying - * file `LICENSE` for more details. - */ -#include -#include "utf8-utils.h" - -// ----------------------------------------------------- utf8_surrogate_len --- -size_t utf8_surrogate_len(const char *character) -{ - size_t result = 0; - char test_char; - - if (!character) - return 0; - - test_char = character[0]; - - if ((test_char & 0x80) == 0) - return 1; - - while (test_char & 0x80) - { - test_char <<= 1; - result++; - } - - return result; -} - -// ------------------------------------------------------------ utf8_strlen --- -size_t utf8_strlen(const char *string) -{ - const char *ptr = string; - size_t result = 0; - - while (*ptr) - { - ptr += utf8_surrogate_len(ptr); - result++; - } - - return result; -} - -uint32_t utf8_to_utf32(const char *character) -{ - uint32_t result = -1; - - if (!character) - { - return result; - } - - if ((character[0] & 0x80) == 0x0) - { - result = character[0]; - } - - if ((character[0] & 0xC0) == 0xC0) - { - result = ((character[0] & 0x3F) << 6) | (character[1] & 0x3F); - } - - if ((character[0] & 0xE0) == 0xE0) - { - result = ((character[0] & 0x1F) << (6 + 6)) | - ((character[1] & 0x3F) << 6) | (character[2] & 0x3F); - } - - if ((character[0] & 0xF0) == 0xF0) - { - result = ((character[0] & 0x0F) << (6 + 6 + 6)) | - ((character[1] & 0x3F) << (6 + 6)) | - ((character[2] & 0x3F) << 6) | (character[3] & 0x3F); - } - - if ((character[0] & 0xF8) == 0xF8) - { - result = ((character[0] & 0x07) << (6 + 6 + 6 + 6)) | - ((character[1] & 0x3F) << (6 + 6 + 6)) | - ((character[2] & 0x3F) << (6 + 6)) | - ((character[3] & 0x3F) << 6) | (character[4] & 0x3F); - } - - return result; -} diff --git a/ftgl/utf8-utils.h b/ftgl/utf8-utils.h deleted file mode 100644 index 268b166..0000000 --- a/ftgl/utf8-utils.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Freetype GL - A C OpenGL Freetype engine - * - * Distributed under the OSI-approved BSD 2-Clause License. See accompanying - * file `LICENSE` for more details. - */ -#ifndef __UTF8_UTILS_H__ -#define __UTF8_UTILS_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { - -namespace ftgl -{ -#endif - -/** - * @file utf8-utils.h - * @author Marcel Metz - * - * defgroup utf8-utils UTF-8 Utilities - * - * @{ - */ - -/** - * Returns the size in bytes of a given UTF-8 encoded character surrogate - * - * @param character An UTF-8 encoded character - * - * @return The length of the surrogate in bytes. - */ -size_t utf8_surrogate_len(const char *character); - -/** - * Return the length of the given UTF-8 encoded and - * NULL terminated string. - * - * @param string An UTF-8 encoded string - * - * @return The length of the string in characters. - */ -size_t utf8_strlen(const char *string); - -/** - * Converts a given UTF-8 encoded character to its UTF-32 LE equivalent - * - * @param character An UTF-8 encoded character - * - * @return The equivalent of the given character in UTF-32 LE - * encoding. - */ -uint32_t utf8_to_utf32(const char *character); - -/** - * @} - */ - -#ifdef __cplusplus -} -} -#endif - -#endif /* #define __UTF8_UTILS_H__ */ diff --git a/ftgl/vec234.h b/ftgl/vec234.h deleted file mode 100644 index 289a365..0000000 --- a/ftgl/vec234.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Freetype GL - A C OpenGL Freetype engine - * - * Distributed under the OSI-approved BSD 2-Clause License. See accompanying - * file `LICENSE` for more details. - */ -#ifndef __VEC234_H__ -#define __VEC234_H__ - -#ifdef __cplusplus -extern "C" { -namespace ftgl -{ -#endif - -/** - * Tuple of 4 ints. - * - * Each field can be addressed using several aliases: - * - First component: x, r, red or vstart - * - Second component: y, g, green or vcount - * - Third component: z, b, blue, width or - * istart - * - Fourth component: w, a, alpha, height or - * icount - * - */ -typedef union { - int data[4]; /**< All compoments at once */ - struct - { - int x; /**< Alias for first component */ - int y; /**< Alias for second component */ - int z; /**< Alias for third component */ - int w; /**< Alias for fourht component */ - }; - struct - { - int x_; /**< Alias for first component */ - int y_; /**< Alias for second component */ - int width; /**< Alias for third component */ - int height; /**< Alias for fourth component */ - }; - struct - { - int r; /**< Alias for first component */ - int g; /**< Alias for second component */ - int b; /**< Alias for third component */ - int a; /**< Alias for fourth component */ - }; - struct - { - int red; /**< Alias for first component */ - int green; /**< Alias for second component */ - int blue; /**< Alias for third component */ - int alpha; /**< Alias for fourth component */ - }; - struct - { - int vstart; /**< Alias for first component */ - int vcount; /**< Alias for second component */ - int istart; /**< Alias for third component */ - int icount; /**< Alias for fourth component */ - }; -} ivec4; - -/** - * Tuple of 3 ints. - * - * Each field can be addressed using several aliases: - * - First component: x, r or red - * - Second component: y, g or green - * - Third component: z, b or blue - * - */ -typedef union { - int data[3]; /**< All compoments at once */ - struct - { - int x; /**< Alias for first component */ - int y; /**< Alias for second component */ - int z; /**< Alias for third component */ - }; - struct - { - int r; /**< Alias for first component */ - int g; /**< Alias for second component */ - int b; /**< Alias for third component */ - }; - struct - { - int red; /**< Alias for first component */ - int green; /**< Alias for second component */ - int blue; /**< Alias for third component */ - }; -} ivec3; - -/** - * Tuple of 2 ints. - * - * Each field can be addressed using several aliases: - * - First component: x, s or start - * - Second component: y, t or end - * - */ -typedef union { - int data[2]; /**< All compoments at once */ - struct - { - int x; /**< Alias for first component */ - int y; /**< Alias for second component */ - }; - struct - { - int s; /**< Alias for first component */ - int t; /**< Alias for second component */ - }; - struct - { - int start; /**< Alias for first component */ - int end; /**< Alias for second component */ - }; -} ivec2; - -/** - * Tuple of 4 floats. - * - * Each field can be addressed using several aliases: - * - First component: x, left, r or red - * - Second component: y, top, g or green - * - Third component: z, width, b or blue - * - Fourth component: w, height, a or alpha - */ -typedef union { - float data[4]; /**< All compoments at once */ - struct - { - float x; /**< Alias for first component */ - float y; /**< Alias for second component */ - float z; /**< Alias for third component */ - float w; /**< Alias for fourth component */ - }; - struct - { - float left; /**< Alias for first component */ - float top; /**< Alias for second component */ - float width; /**< Alias for third component */ - float height; /**< Alias for fourth component */ - }; - struct - { - float r; /**< Alias for first component */ - float g; /**< Alias for second component */ - float b; /**< Alias for third component */ - float a; /**< Alias for fourth component */ - }; - struct - { - float red; /**< Alias for first component */ - float green; /**< Alias for second component */ - float blue; /**< Alias for third component */ - float alpha; /**< Alias for fourth component */ - }; -} vec4; - -/** - * Tuple of 3 floats - * - * Each field can be addressed using several aliases: - * - First component: x, r or red - * - Second component: y, g or green - * - Third component: z, b or blue - */ -typedef union { - float data[3]; /**< All compoments at once */ - struct - { - float x; /**< Alias for first component */ - float y; /**< Alias fo second component */ - float z; /**< Alias fo third component */ - }; - struct - { - float r; /**< Alias for first component */ - float g; /**< Alias fo second component */ - float b; /**< Alias fo third component */ - }; - struct - { - float red; /**< Alias for first component */ - float green; /**< Alias fo second component */ - float blue; /**< Alias fo third component */ - }; -} vec3; - -/** - * Tuple of 2 floats - * - * Each field can be addressed using several aliases: - * - First component: x or s - * - Second component: y or t - */ -typedef union { - float data[2]; /**< All components at once */ - struct - { - float x; /**< Alias for first component */ - float y; /**< Alias for second component */ - }; - struct - { - float s; /**< Alias for first component */ - float t; /**< Alias for second component */ - }; -} vec2; - -#ifdef __cplusplus -} -} -#endif - -#endif /* __VEC234_H__ */ diff --git a/ftgl/vector.c b/ftgl/vector.c deleted file mode 100644 index c07cf8a..0000000 --- a/ftgl/vector.c +++ /dev/null @@ -1,270 +0,0 @@ -/* Freetype GL - A C OpenGL Freetype engine - * - * Distributed under the OSI-approved BSD 2-Clause License. See accompanying - * file `LICENSE` for more details. - */ -#include -#include -#include -#include -#include "vector.h" - -// ------------------------------------------------------------- vector_new --- -vector_t *vector_new(size_t item_size) -{ - vector_t *self = (vector_t *) malloc(sizeof(vector_t)); - assert(item_size); - - if (!self) - { - fprintf(stderr, "line %d: No more memory for allocating data\n", - __LINE__); - exit(EXIT_FAILURE); - } - self->item_size = item_size; - self->size = 0; - self->capacity = 1; - self->items = malloc(self->item_size * self->capacity); - return self; -} - -// ---------------------------------------------------------- vector_delete --- -void vector_delete(vector_t *self) -{ - assert(self); - - free(self->items); - free(self); -} - -// ------------------------------------------------------------- vector_get --- -const void *vector_get(const vector_t *self, size_t index) -{ - assert(self); - assert(self->size); - assert(index < self->size); - - return (char *) (self->items) + index * self->item_size; -} - -// ----------------------------------------------------------- vector_front --- -const void *vector_front(const vector_t *self) -{ - assert(self); - assert(self->size); - - return vector_get(self, 0); -} - -// ------------------------------------------------------------ vector_back --- -const void *vector_back(const vector_t *self) -{ - assert(self); - assert(self->size); - - return vector_get(self, self->size - 1); -} - -// -------------------------------------------------------- vector_contains --- -int vector_contains(const vector_t *self, const void *item, - int (*cmp)(const void *, const void *)) -{ - size_t i; - assert(self); - - for (i = 0; i < self->size; ++i) - { - if ((*cmp)(item, vector_get(self, i)) == 0) - { - return 1; - } - } - return 0; -} - -// ----------------------------------------------------------- vector_empty --- -int vector_empty(const vector_t *self) -{ - assert(self); - - return self->size == 0; -} - -// ------------------------------------------------------------ vector_size --- -size_t vector_size(const vector_t *self) -{ - assert(self); - - return self->size; -} - -// --------------------------------------------------------- vector_reserve --- -void vector_reserve(vector_t *self, const size_t size) -{ - assert(self); - - if (self->capacity < size) - { - self->items = realloc(self->items, size * self->item_size); - self->capacity = size; - } -} - -// -------------------------------------------------------- vector_capacity --- -size_t vector_capacity(const vector_t *self) -{ - assert(self); - - return self->capacity; -} - -// ---------------------------------------------------------- vector_shrink --- -void vector_shrink(vector_t *self) -{ - assert(self); - - if (self->capacity > self->size) - { - self->items = realloc(self->items, self->size * self->item_size); - } - self->capacity = self->size; -} - -// ----------------------------------------------------------- vector_clear --- -void vector_clear(vector_t *self) -{ - assert(self); - - self->size = 0; -} - -// ------------------------------------------------------------- vector_set --- -void vector_set(vector_t *self, const size_t index, const void *item) -{ - assert(self); - assert(self->size); - assert(index < self->size); - - memcpy((char *) (self->items) + index * self->item_size, item, - self->item_size); -} - -// ---------------------------------------------------------- vector_insert --- -void vector_insert(vector_t *self, const size_t index, const void *item) -{ - assert(self); - assert(index <= self->size); - - if (self->capacity <= self->size) - { - vector_reserve(self, 2 * self->capacity); - } - if (index < self->size) - { - memmove((char *) (self->items) + (index + 1) * self->item_size, - (char *) (self->items) + (index + 0) * self->item_size, - (self->size - index) * self->item_size); - } - self->size++; - vector_set(self, index, item); -} - -// ----------------------------------------------------- vector_erase_range --- -void vector_erase_range(vector_t *self, const size_t first, const size_t last) -{ - assert(self); - assert(first < self->size); - assert(last < self->size + 1); - assert(first < last); - - memmove((char *) (self->items) + first * self->item_size, - (char *) (self->items) + last * self->item_size, - (self->size - last) * self->item_size); - self->size -= (last - first); -} - -// ----------------------------------------------------------- vector_erase --- -void vector_erase(vector_t *self, const size_t index) -{ - assert(self); - assert(index < self->size); - - vector_erase_range(self, index, index + 1); -} - -// ------------------------------------------------------- vector_push_back --- -void vector_push_back(vector_t *self, const void *item) -{ - vector_insert(self, self->size, item); -} - -// -------------------------------------------------------- vector_pop_back --- -void vector_pop_back(vector_t *self) -{ - assert(self); - assert(self->size); - - self->size--; -} - -// ---------------------------------------------------------- vector_resize --- -void vector_resize(vector_t *self, const size_t size) -{ - assert(self); - - if (size > self->capacity) - { - vector_reserve(self, size); - self->size = self->capacity; - } - else - { - self->size = size; - } -} - -// -------------------------------------------------- vector_push_back_data --- -void vector_push_back_data(vector_t *self, const void *data, const size_t count) -{ - assert(self); - assert(data); - assert(count); - - if (self->capacity < (self->size + count)) - { - vector_reserve(self, self->size + count); - } - memmove((char *) (self->items) + self->size * self->item_size, data, - count * self->item_size); - self->size += count; -} - -// ----------------------------------------------------- vector_insert_data --- -void vector_insert_data(vector_t *self, const size_t index, const void *data, - const size_t count) -{ - assert(self); - assert(index < self->size); - assert(data); - assert(count); - - if (self->capacity < (self->size + count)) - { - vector_reserve(self, self->size + count); - } - memmove((char *) (self->items) + (index + count) * self->item_size, - (char *) (self->items) + (index) *self->item_size, - count * self->item_size); - memmove((char *) (self->items) + index * self->item_size, data, - count * self->item_size); - self->size += count; -} - -// ------------------------------------------------------------ vector_sort --- -void vector_sort(vector_t *self, int (*cmp)(const void *, const void *)) -{ - assert(self); - assert(self->size); - - qsort(self->items, self->size, self->item_size, cmp); -} diff --git a/ftgl/vector.h b/ftgl/vector.h deleted file mode 100644 index ec60116..0000000 --- a/ftgl/vector.h +++ /dev/null @@ -1,270 +0,0 @@ -/* Freetype GL - A C OpenGL Freetype engine - * - * Distributed under the OSI-approved BSD 2-Clause License. See accompanying - * file `LICENSE` for more details. - */ -#ifndef __VECTOR_H__ -#define __VECTOR_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef __cplusplus -namespace ftgl -{ -#endif - -/** - * @file vector.h - * @author Nicolas Rougier (Nicolas.Rougier@inria.fr) - * - * @defgroup vector Vector - * - * The vector structure and accompanying functions loosely mimic the STL C++ - * vector class. It is used by @ref texture-atlas (for storing nodes), @ref - * texture-font (for storing glyphs) and @ref font-manager (for storing fonts). - * More information at http://www.cppreference.com/wiki/container/vector/start - * - * Example Usage: - * @code - * #include "vector.h" - * - * int main( int arrgc, char *argv[] ) - * { - * int i,j = 1; - * vector_t * vector = vector_new( sizeof(int) ); - * vector_push_back( &i ); - * - * j = * (int *) vector_get( vector, 0 ); - * vector_delete( vector); - * - * return 0; - * } - * @endcode - * - * @{ - */ - -/** - * Generic vector structure. - * - * @memberof vector - */ -typedef struct vector_t -{ - /** Pointer to dynamically allocated items. */ - void *items; - - /** Number of items that can be held in currently allocated storage. */ - size_t capacity; - - /** Number of items. */ - size_t size; - - /** Size (in bytes) of a single item. */ - size_t item_size; -} vector_t; - -/** - * Creates a new empty vector. - * - * @param item_size item size in bytes - * @return a new empty vector - * - */ -vector_t *vector_new(size_t item_size); - -/** - * Deletes a vector. - * - * @param self a vector structure - * - */ -void vector_delete(vector_t *self); - -/** - * Returns a pointer to the item located at specified index. - * - * @param self a vector structure - * @param index the index of the item to be returned - * @return pointer on the specified item - */ -const void *vector_get(const vector_t *self, size_t index); - -/** - * Returns a pointer to the first item. - * - * @param self a vector structure - * @return pointer on the first item - */ -const void *vector_front(const vector_t *self); - -/** - * Returns a pointer to the last item - * - * @param self a vector structure - * @return pointer on the last item - */ -const void *vector_back(const vector_t *self); - -/** - * Check if an item is contained within the vector. - * - * @param self a vector structure - * @param item item to be searched in the vector - * @param cmp a pointer a comparison function - * @return 1 if item is contained within the vector, 0 otherwise - */ -int vector_contains(const vector_t *self, const void *item, - int (*cmp)(const void *, const void *)); - -/** - * Checks whether the vector is empty. - * - * @param self a vector structure - * @return 1 if the vector is empty, 0 otherwise - */ -int vector_empty(const vector_t *self); - -/** - * Returns the number of items - * - * @param self a vector structure - * @return number of items - */ -size_t vector_size(const vector_t *self); - -/** - * Reserve storage such that it can hold at last size items. - * - * @param self a vector structure - * @param size the new storage capacity - */ -void vector_reserve(vector_t *self, const size_t size); - -/** - * Returns current storage capacity - * - * @param self a vector structure - * @return storage capacity - */ -size_t vector_capacity(const vector_t *self); - -/** - * Decrease capacity to fit actual size. - * - * @param self a vector structure - */ -void vector_shrink(vector_t *self); - -/** - * Removes all items. - * - * @param self a vector structure - */ -void vector_clear(vector_t *self); - -/** - * Replace an item. - * - * @param self a vector structure - * @param index the index of the item to be replaced - * @param item the new item - */ -void vector_set(vector_t *self, const size_t index, const void *item); - -/** - * Erase an item. - * - * @param self a vector structure - * @param index the index of the item to be erased - */ -void vector_erase(vector_t *self, const size_t index); - -/** - * Erase a range of items. - * - * @param self a vector structure - * @param first the index of the first item to be erased - * @param last the index of the last item to be erased - */ -void vector_erase_range(vector_t *self, const size_t first, const size_t last); - -/** - * Appends given item to the end of the vector. - * - * @param self a vector structure - * @param item the item to be inserted - */ -void vector_push_back(vector_t *self, const void *item); - -/** - * Removes the last item of the vector. - * - * @param self a vector structure - */ -void vector_pop_back(vector_t *self); - -/** - * Resizes the vector to contain size items - * - * If the current size is less than size, additional items are appended and - * initialized with value. If the current size is greater than size, the - * vector is reduced to its first size elements. - * - * @param self a vector structure - * @param size the new size - */ -void vector_resize(vector_t *self, const size_t size); - -/** - * Insert a single item at specified index. - * - * @param self a vector structure - * @param index location before which to insert item - * @param item the item to be inserted - */ -void vector_insert(vector_t *self, const size_t index, const void *item); - -/** - * Insert raw data at specified index. - * - * @param self a vector structure - * @param index location before which to insert item - * @param data a pointer to the items to be inserted - * @param count the number of items to be inserted - */ -void vector_insert_data(vector_t *self, const size_t index, const void *data, - const size_t count); - -/** - * Append raw data to the end of the vector. - * - * @param self a vector structure - * @param data a pointer to the items to be inserted - * @param count the number of items to be inserted - */ -void vector_push_back_data(vector_t *self, const void *data, - const size_t count); - -/** - * Sort vector items according to cmp function. - * - * @param self a vector structure - * @param cmp a pointer a comparison function - */ -void vector_sort(vector_t *self, int (*cmp)(const void *, const void *)); - -/** @} */ - -#ifdef __cplusplus -} -} -#endif - -#endif /* __VECTOR_H__ */