consistent naming of structs and their typedefs

Thu, 12 Jun 2025 22:44:49 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 12 Jun 2025 22:44:49 +0200
changeset 145
a3231310d66d
parent 144
43636d6a6e25
child 146
bd62381be983

consistent naming of structs and their typedefs

fixes #664

src/ascension/camera.h file | annotate | diff | comparison | revisions
src/ascension/context.h file | annotate | diff | comparison | revisions
src/ascension/glcontext.h file | annotate | diff | comparison | revisions
src/ascension/input.h file | annotate | diff | comparison | revisions
src/ascension/mesh.h file | annotate | diff | comparison | revisions
src/ascension/scene.h file | annotate | diff | comparison | revisions
src/ascension/shader.h file | annotate | diff | comparison | revisions
src/ascension/sprite.h file | annotate | diff | comparison | revisions
src/ascension/texture.h file | annotate | diff | comparison | revisions
src/ascension/ui/font.h file | annotate | diff | comparison | revisions
src/ascension/ui/text.h file | annotate | diff | comparison | revisions
src/ascension/window.h file | annotate | diff | comparison | revisions
src/mesh.c file | annotate | diff | comparison | revisions
src/sprite.c file | annotate | diff | comparison | revisions
--- a/src/ascension/camera.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/camera.h	Thu Jun 12 22:44:49 2025 +0200
@@ -30,12 +30,12 @@
 
 #include "datatypes.h"
 
-typedef struct AscCamera AscCamera;
+typedef struct asc_camera_s AscCamera;
 
 typedef asc_recti(*asc_camera_viewport_update_func)(asc_vec2u window_size);
 typedef void(*asc_camera_projection_update_func)(AscCamera*, asc_vec2u window_size);
 
-struct AscCamera {
+struct asc_camera_s {
     asc_mat4f projection;
     asc_mat4f view;
     asc_recti viewport;
--- a/src/ascension/context.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/context.h	Thu Jun 12 22:44:49 2025 +0200
@@ -50,7 +50,7 @@
 /**
  * The global ascension context.
  */
-typedef struct AscContext {
+typedef struct asc_context_s {
     unsigned int flags;
     CxBuffer error_buffer;
     cxmutstr font_path;
--- a/src/ascension/glcontext.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/glcontext.h	Thu Jun 12 22:44:49 2025 +0200
@@ -32,14 +32,14 @@
 
 #include <cx/list.h>
 
-typedef struct AscGLContextSettings {
+typedef struct asc_gl_context_settings_s {
     int gl_major_version;
     int gl_minor_version;
     int vsync;
     int depth_size;
 } AscGLContextSettings;
 
-typedef struct AscGLContext {
+typedef struct asc_gl_context_s {
     SDL_Window *window;
     SDL_GLContext glctx;
     /**
--- a/src/ascension/input.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/input.h	Thu Jun 12 22:44:49 2025 +0200
@@ -30,9 +30,7 @@
 
 #include <SDL2/SDL_scancode.h>
 
-typedef struct AscInput AscInput;
-
-struct AscInput {
+typedef struct asc_input_s {
     /**
      * The last X position of the mouse in \c mouse_window.
      */
@@ -61,7 +59,7 @@
      * @see asc_key_up()
      */
     unsigned char keys[SDL_NUM_SCANCODES];
-};
+} AscInput;
 
 #define ASC_KEY_DOWN_FLAG     1u
 #define ASC_KEY_PRESS_FLAG    2u
--- a/src/ascension/mesh.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/mesh.h	Thu Jun 12 22:44:49 2025 +0200
@@ -37,7 +37,7 @@
     ASC_MESH_3D_COLORED,
 };
 
-typedef struct AscMesh {
+typedef struct asc_mesh_s {
     // TODO: for batched rendering, VAO and VBO must not be part of the mesh
     unsigned vbo;
     unsigned vao;
@@ -47,27 +47,27 @@
     float *vtx_data;
 } AscMesh;
 
-typedef struct AscMeshVertex2d {
+typedef struct asc_vertex2d {
     asc_vec2f pos;
     asc_vec2f uv;
-} AscMeshVertex2d;
+} asc_vertex2d;
 
-typedef struct AscMeshVertex2dColored {
+typedef struct asc_vertex2d_col {
     asc_vec2f pos;
     asc_vec2f uv;
     asc_col4f color;
-} AscMeshVertex2dColored;
+} asc_vertex2d_col;
 
-typedef struct AscMeshVertex3d {
+typedef struct asc_vertex3d {
     asc_vec3f pos;
     asc_vec2f uv;
-} AscMeshVertex3d;
+} asc_vertex3d;
 
-typedef struct AscMeshVertex3dColored {
+typedef struct asc_vertex3d_col {
     asc_vec3f pos;
     asc_vec2f uv;
     asc_col4f color;
-} AscMeshVertex3dColored;
+} asc_vertex3d_col;
 
 
 void asc_mesh_destroy(AscMesh *mesh);
--- a/src/ascension/scene.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/scene.h	Thu Jun 12 22:44:49 2025 +0200
@@ -33,7 +33,7 @@
 
 #include <cx/list.h>
 
-typedef struct {
+typedef struct asc_scene_s {
     AscCamera camera;
     AscSceneNode *root;
     struct {
--- a/src/ascension/shader.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/shader.h	Thu Jun 12 22:44:49 2025 +0200
@@ -57,7 +57,7 @@
     struct asc_shader_code_defines_s defines;
 } AscShaderCodeInfo;
 
-typedef struct AscShaderCodes {
+typedef struct asc_shader_codes_s {
     char *vtx;
     char *frag;
     /**
@@ -70,7 +70,7 @@
     const char *frag_pp;
 } AscShaderCodes;
 
-typedef struct AscShaderProgram {
+typedef struct asc_shader_program_s {
     unsigned int id;
     unsigned int gl_id;
     int model;
--- a/src/ascension/sprite.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/sprite.h	Thu Jun 12 22:44:49 2025 +0200
@@ -33,7 +33,7 @@
 #include "texture.h"
 #include "camera.h"
 
-typedef struct AscSprite {
+typedef struct asc_sprite_s {
     AscSceneNode data;
     AscMesh mesh;
     unsigned width;
--- a/src/ascension/texture.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/texture.h	Thu Jun 12 22:44:49 2025 +0200
@@ -32,9 +32,7 @@
 
 #include <SDL2/SDL_surface.h>
 
-typedef struct AscTexture AscTexture;
-
-struct AscTexture {
+typedef struct asc_texture_s {
     /**
      * OpenGL texture target.
      * Not to be confused with asc_texture_target!
@@ -45,7 +43,7 @@
     unsigned height;
     unsigned refcount;
     // TODO: add support for texture atlas - idea: rects are defined in AscTexture and can be indexed
-};
+} AscTexture;
 
 enum asc_texture_target {
     ASC_TEXTURE_RECTANGLE,
--- a/src/ascension/ui/font.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/ui/font.h	Thu Jun 12 22:44:49 2025 +0200
@@ -37,7 +37,7 @@
     ASC_FONT_BOLD_ITALIC,
 };
 
-typedef struct AscFont {
+typedef struct asc_font_s {
     /**
      * Style of the font.
      */
--- a/src/ascension/ui/text.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/ui/text.h	Thu Jun 12 22:44:49 2025 +0200
@@ -33,7 +33,7 @@
 
 #include <cx/string.h>
 
-typedef struct AscText {
+typedef struct asc_text_s {
     // TODO: try to remove the explicit dependency to a sprite
     AscSprite base;
     cxmutstr text;
--- a/src/ascension/window.h	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/ascension/window.h	Thu Jun 12 22:44:49 2025 +0200
@@ -44,14 +44,14 @@
 #define ASC_MAX_SCENES 8u
 #endif // ASC_MAX_SCENES
 
-typedef struct AscWindowSettings {
+typedef struct asc_window_settings_s {
     AscGLContextSettings glsettings;
     asc_vec2i dimensions;
     char const* title;
     bool fullscreen;
 } AscWindowSettings;
 
-typedef struct AscWindow {
+typedef struct asc_window_s {
     Uint32 id;
     bool resized;
     bool focused;
--- a/src/mesh.c	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/mesh.c	Thu Jun 12 22:44:49 2025 +0200
@@ -82,7 +82,7 @@
         asc_mesh_allocate_buffers(mesh, 1);
     }
 
-    unsigned required_memory = 4 * sizeof(AscMeshVertex2d);
+    unsigned required_memory = 4 * sizeof(asc_vertex2d);
 
     // free any previous data
     if (mesh->vtx_data && mesh->vtx_data_size < required_memory) {
@@ -91,14 +91,14 @@
     }
 
     // allocate memory
-    AscMeshVertex2d *data;
+    asc_vertex2d *data;
     if (mesh->vtx_data == NULL) {
         asc_dprintf("Create plane in VBO %u and VAO %u", mesh->vbo, mesh->vao);
         mesh->vtx_data_size = required_memory;
         data = cxMallocDefault(mesh->vtx_data_size);
         mesh->vtx_data = (float*) data;
     } else {
-        data = (AscMeshVertex2d*) mesh->vtx_data;
+        data = (asc_vertex2d*) mesh->vtx_data;
     }
     mesh->vtx_count = 4;
 
@@ -124,8 +124,8 @@
     glBufferData(GL_ARRAY_BUFFER, mesh->vtx_data_size, mesh->vtx_data, GL_STATIC_DRAW);
     // TODO: this should not be repeated for every adjustment - but it will be moved to the batch renderer anyway
     glBindVertexArray(mesh->vao);
-    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(AscMeshVertex2d), (void*)offsetof(AscMeshVertex2d, pos));
+    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(asc_vertex2d), (void*)offsetof(asc_vertex2d, pos));
     glEnableVertexAttribArray(0);
-    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(AscMeshVertex2d), (void*)offsetof(AscMeshVertex2d, uv));
+    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(asc_vertex2d), (void*)offsetof(asc_vertex2d, uv));
     glEnableVertexAttribArray(1);
 }
--- a/src/sprite.c	Wed Jun 11 23:38:55 2025 +0200
+++ b/src/sprite.c	Thu Jun 12 22:44:49 2025 +0200
@@ -37,12 +37,10 @@
 #include <GL/glew.h>
 
 
-struct asc_sprite_shader_s {
+typedef struct asc_sprite_shader_s {
     AscShaderProgram program;
     int tex;
-};
-
-typedef struct asc_sprite_shader_s AscSpriteShader;
+} AscSpriteShader;
 
 static void *asc_sprite_shader_create(bool rect) {
     AscShaderCodes codes;

mercurial