From 792834623c3d78b533ed0dc019607c1dcf84254a Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 26 Sep 2018 17:54:12 -0700 Subject: [PATCH] api: more modular helper functions; --- src/api.h | 26 -------------------------- src/api/data.c | 1 + src/api/data.h | 11 +++++++++++ src/api/event.c | 1 + src/api/event.h | 4 ++++ src/api/graphics.c | 2 ++ src/api/graphics.h | 9 +++++++++ src/api/math.c | 1 + src/api/math.h | 5 +++++ src/api/types/channel.c | 1 + src/api/types/mesh.c | 1 + src/api/types/randomGenerator.c | 2 ++ src/api/types/shader.c | 1 + src/api/types/shaderBlock.c | 1 + src/api/types/vertexData.c | 1 + 15 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 src/api/data.h create mode 100644 src/api/event.h create mode 100644 src/api/graphics.h create mode 100644 src/api/math.h diff --git a/src/api.h b/src/api.h index 134849ba..b36b5349 100644 --- a/src/api.h +++ b/src/api.h @@ -1,11 +1,4 @@ #include "luax.h" -#include "data/blob.h" -#include "event/event.h" -#include "graphics/canvas.h" -#include "graphics/mesh.h" -#include "math/math.h" -#include "math/randomGenerator.h" -#include "physics/physics.h" // Module loaders int l_lovrInit(lua_State* L); @@ -104,22 +97,3 @@ extern const char* UniformAccesses[]; extern const char* VerticalAligns[]; extern const char* Windings[]; extern const char* WrapModes[]; - -// Shared helpers -int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices); -bool luax_checkvertexformat(lua_State* L, int index, VertexFormat* format); -int luax_pushvertexformat(lua_State* L, VertexFormat* format); -int luax_pushvertexattribute(lua_State* L, VertexPointer* vertex, Attribute attribute); -int luax_pushvertex(lua_State* L, VertexPointer* vertex, VertexFormat* format); -void luax_setvertexattribute(lua_State* L, int index, VertexPointer* vertex, Attribute attribute); -void luax_setvertex(lua_State* L, int index, VertexPointer* vertex, VertexFormat* format); -int luax_readtransform(lua_State* L, int index, mat4 transform, int scaleComponents); -Blob* luax_readblob(lua_State* L, int index, const char* debug); -Seed luax_checkrandomseed(lua_State* L, int index); -void luax_checkvariant(lua_State* L, int index, Variant* variant); -int luax_pushvariant(lua_State* L, Variant* variant); -int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug); -void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components); -int luax_optmipmap(lua_State* L, int index, Texture* texture); -Texture* luax_checktexture(lua_State* L, int index); -void luax_readattachments(lua_State* L, int index, Attachment* attachments, int* count); diff --git a/src/api/data.c b/src/api/data.c index baece53f..c1633190 100644 --- a/src/api/data.c +++ b/src/api/data.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/data.h" #include "data/audioStream.h" #include "data/modelData.h" #include "data/rasterizer.h" diff --git a/src/api/data.h b/src/api/data.h new file mode 100644 index 00000000..b4120c15 --- /dev/null +++ b/src/api/data.h @@ -0,0 +1,11 @@ +#include "data/blob.h" +#include "data/vertexData.h" + +int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices); +bool luax_checkvertexformat(lua_State* L, int index, VertexFormat* format); +int luax_pushvertexformat(lua_State* L, VertexFormat* format); +int luax_pushvertexattribute(lua_State* L, VertexPointer* vertex, Attribute attribute); +int luax_pushvertex(lua_State* L, VertexPointer* vertex, VertexFormat* format); +void luax_setvertexattribute(lua_State* L, int index, VertexPointer* vertex, Attribute attribute); +void luax_setvertex(lua_State* L, int index, VertexPointer* vertex, VertexFormat* format); +Blob* luax_readblob(lua_State* L, int index, const char* debug); diff --git a/src/api/event.c b/src/api/event.c index ddffba8e..b4a15efd 100644 --- a/src/api/event.c +++ b/src/api/event.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/event.h" #include "event/event.h" const char* EventTypes[] = { diff --git a/src/api/event.h b/src/api/event.h new file mode 100644 index 00000000..d177f2e7 --- /dev/null +++ b/src/api/event.h @@ -0,0 +1,4 @@ +#include "event/event.h" + +void luax_checkvariant(lua_State* L, int index, Variant* variant); +int luax_pushvariant(lua_State* L, Variant* variant); diff --git a/src/api/graphics.c b/src/api/graphics.c index 9f43f999..62150c32 100644 --- a/src/api/graphics.c +++ b/src/api/graphics.c @@ -1,4 +1,6 @@ #include "api.h" +#include "api/data.h" +#include "api/graphics.h" #include "graphics/graphics.h" #include "graphics/animator.h" #include "graphics/canvas.h" diff --git a/src/api/graphics.h b/src/api/graphics.h new file mode 100644 index 00000000..c3bf1139 --- /dev/null +++ b/src/api/graphics.h @@ -0,0 +1,9 @@ +#include "graphics/canvas.h" +#include "graphics/shader.h" +#include "graphics/texture.h" + +int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug); +void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components); +int luax_optmipmap(lua_State* L, int index, Texture* texture); +Texture* luax_checktexture(lua_State* L, int index); +void luax_readattachments(lua_State* L, int index, Attachment* attachments, int* count); diff --git a/src/api/math.c b/src/api/math.c index c4746f1d..76bb55b3 100644 --- a/src/api/math.c +++ b/src/api/math.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/math.h" #include "math/math.h" #include "math/mat4.h" #include "math/quat.h" diff --git a/src/api/math.h b/src/api/math.h new file mode 100644 index 00000000..372147db --- /dev/null +++ b/src/api/math.h @@ -0,0 +1,5 @@ +#include "math/mat4.h" +#include "math/randomGenerator.h" + +int luax_readtransform(lua_State* L, int index, mat4 transform, int scaleComponents); +Seed luax_checkrandomseed(lua_State* L, int index); diff --git a/src/api/types/channel.c b/src/api/types/channel.c index 03e4484f..8a908c71 100644 --- a/src/api/types/channel.c +++ b/src/api/types/channel.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/event.h" #include "thread/channel.h" static void luax_checktimeout(lua_State* L, int index, double* timeout) { diff --git a/src/api/types/mesh.c b/src/api/types/mesh.c index 2fc98d00..5bcf7a91 100644 --- a/src/api/types/mesh.c +++ b/src/api/types/mesh.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/data.h" #include "graphics/graphics.h" #include diff --git a/src/api/types/randomGenerator.c b/src/api/types/randomGenerator.c index 8bbfe01c..412f69c2 100644 --- a/src/api/types/randomGenerator.c +++ b/src/api/types/randomGenerator.c @@ -1,5 +1,7 @@ #include "api.h" +#include "api/math.h" #include "math/randomGenerator.h" +#include static double luax_checkrandomseedpart(lua_State* L, int index) { double x = luaL_checknumber(L, index); diff --git a/src/api/types/shader.c b/src/api/types/shader.c index 3678b700..21ffc65c 100644 --- a/src/api/types/shader.c +++ b/src/api/types/shader.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/graphics.h" #include "graphics/shader.h" #include "math/transform.h" diff --git a/src/api/types/shaderBlock.c b/src/api/types/shaderBlock.c index 293f4402..71db1605 100644 --- a/src/api/types/shaderBlock.c +++ b/src/api/types/shaderBlock.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/graphics.h" #include "graphics/shader.h" #include "math/transform.h" diff --git a/src/api/types/vertexData.c b/src/api/types/vertexData.c index f6031d17..cb9cc9d7 100644 --- a/src/api/types/vertexData.c +++ b/src/api/types/vertexData.c @@ -1,4 +1,5 @@ #include "api.h" +#include "api/data.h" int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices) { uint32_t count = lua_objlen(L, index);