Browse Source

Remove extra escape characters thanks to new cakelisp

* Reformatted some code
* Cakelisp was updated to have a vastly improved tokenize-push, which
removed the need for extra escape characters
windows-imgui
Macoy Madson 9 months ago
parent
commit
7efcad15b0
  1. 12
      src/Dependencies.cake
  2. 78
      src/Math.cake
  3. 9
      src/Ogre.cake
  4. 20
      src/OgreInitialize.cake
  5. 2
      src/SDL.cake
  6. 15
      src/Tracy.cake

12
src/Dependencies.cake

@ -22,7 +22,7 @@
(run-process-sequential-or
("git" "checkout" "--track" (token-splice-addr remote-branch)
:in-directory (token-splice output-directory))
(Logf "error: failed to check out %s branch %s\\n"
(Logf "error: failed to check out %s branch %s\n"
(token-splice output-directory) (token-splice-addr remote-branch))
(return false))))
@ -31,18 +31,18 @@
(unless (fileExists (token-splice output-directory))
(comptime-cond
('Dependencies-Clone-Only
(Logf "%s: Cloning from %s. Will NOT be tracked as a submodule\\n\\n"
(Logf "%s: Cloning from %s. Will NOT be tracked as a submodule\n\n"
(token-splice output-directory) (token-splice repository-url))
(run-process-sequential-or
("git" "clone" (token-splice repository-url) (token-splice output-directory))
(Logf "error: failed to clone %s\\n" (token-splice output-directory))
(Logf "error: failed to clone %s\n" (token-splice output-directory))
(return false)))
(true
(Logf "%s: Automatically adding as submodule from %s\\n\\n"
(Logf "%s: Automatically adding as submodule from %s\n\n"
(token-splice output-directory) (token-splice repository-url))
(run-process-sequential-or
("git" "submodule" "add" (token-splice repository-url) (token-splice output-directory))
(Logf "error: failed to add %s as a git submodule dependency. Are you in a git repository?\\n"
(Logf "error: failed to add %s as a git submodule dependency. Are you in a git repository?\n"
(token-splice output-directory))
(return false))))
@ -52,7 +52,7 @@
(run-process-sequential-or
("git" "submodule" "update" "--init" "--recursive"
:in-directory (token-splice output-directory))
(Logf "error: failed to initialize submodules belonging to %s\\n"
(Logf "error: failed to initialize submodules belonging to %s\n"
(token-splice output-directory))
(return false)))
(return true))

78
src/Math.cake

@ -120,42 +120,42 @@
;; TODO: Change to any, prevent multiple eval?
(defmacro vec-xy (vec symbol)
(tokenize-push output
(field (token-splice vec) X)
(field (token-splice vec) Y))
(field (token-splice vec) X)
(field (token-splice vec) Y))
(return true))
;; Expand vector to each of its components
;; TODO: Change to any, prevent multiple eval?
(defmacro vec-xyz (vec symbol)
(tokenize-push output
(field (token-splice vec) X)
(field (token-splice vec) Y)
(field (token-splice vec) Z))
(field (token-splice vec) X)
(field (token-splice vec) Y)
(field (token-splice vec) Z))
(return true))
;; Expand vector to each of its components
;; TODO: Change to any, prevent multiple eval?
(defmacro vec-xyzw (vec symbol)
(tokenize-push output
(field (token-splice vec) X)
(field (token-splice vec) Y)
(field (token-splice vec) Z)
(field (token-splice vec) W))
(field (token-splice vec) X)
(field (token-splice vec) Y)
(field (token-splice vec) Z)
(field (token-splice vec) W))
(return true))
(defmacro vec-x (vec any)
(tokenize-push output
(field (token-splice vec) X))
(field (token-splice vec) X))
(return true))
(defmacro vec-y (vec any)
(tokenize-push output
(field (token-splice vec) Y))
(field (token-splice vec) Y))
(return true))
(defmacro vec-z (vec any)
(tokenize-push output
(field (token-splice vec) Z))
(field (token-splice vec) Z))
(return true))
;;
@ -198,18 +198,18 @@
;; TODO: Inline?
(defun mat4-transform-vec3 (mat mat4 vec vec3 &return vec3)
(var temp-vec4 vec4
(mat4-multiply-vec4 mat
(vec4-create (vec-xyz vec) 1.f)))
(mat4-multiply-vec4 mat
(vec4-create (vec-xyz vec) 1.f)))
(var converted-vec3 vec3 (array (vec-xyz temp-vec4)))
(return converted-vec3))
;; TODO: Change to any, prevent multiple eval
(defmacro mat4-xyzw (mat symbol vec-index symbol)
(tokenize-push output
(at (token-splice vec-index) 0 (token-splice mat))
(at (token-splice vec-index) 1 (token-splice mat))
(at (token-splice vec-index) 2 (token-splice mat))
(at (token-splice vec-index) 3 (token-splice mat)))
(at (token-splice vec-index) 0 (token-splice mat))
(at (token-splice vec-index) 1 (token-splice mat))
(at (token-splice vec-index) 2 (token-splice mat))
(at (token-splice vec-index) 3 (token-splice mat)))
(return true))
;; This prints in "column major", "column vector" notation.
@ -237,11 +237,11 @@
;;
(defgenerator c-define-local (define-name symbol)
(var define-statement (const ([] CStatementOperation))
(array
(array Keyword "#define" -1)
(array Expression null 1)
;; Bit of a hack
(array Keyword "\n" -1)))
(array
(array Keyword "#define" -1)
(array Expression null 1)
;; Bit of a hack
(array Keyword "\n" -1)))
(return (CStatementOutput environment context tokens startTokenIndex
define-statement (array-size define-statement)
output)))
@ -259,7 +259,7 @@
(def-type-alias FunctionAliasMap (<> std::unordered_map std::string std::string))
(var alias-func-pair (in FunctionAliasMap iterator)
(call-on-ptr find c-function-aliases invocation-name))
(call-on-ptr find c-function-aliases invocation-name))
(unless (!= alias-func-pair (call-on-ptr end c-function-aliases))
(ErrorAtToken (at (+ 1 startTokenIndex) tokens)
"unknown function alias. This is likely a code error, as it should never have " \
@ -272,22 +272,22 @@
(if arguments
(block
(var invocation-statement (const ([] CStatementOperation))
(array
(array KeywordNoSpace (call-on c_str underlying-func-name) -1)
(array OpenParen null -1)
(array ExpressionList null 1)
(array CloseParen null -1)
(array SmartEndStatement null -1)))
(array
(array KeywordNoSpace (call-on c_str underlying-func-name) -1)
(array OpenParen null -1)
(array ExpressionList null 1)
(array CloseParen null -1)
(array SmartEndStatement null -1)))
(return (CStatementOutput environment context tokens startTokenIndex
invocation-statement (array-size invocation-statement)
output)))
(block
(var invocation-statement (const ([] CStatementOperation))
(array
(array KeywordNoSpace (call-on c_str underlying-func-name) -1)
(array OpenParen null -1)
(array CloseParen null -1)
(array SmartEndStatement null -1)))
(array
(array KeywordNoSpace (call-on c_str underlying-func-name) -1)
(array OpenParen null -1)
(array CloseParen null -1)
(array SmartEndStatement null -1)))
(return (CStatementOutput environment context tokens startTokenIndex
invocation-statement (array-size invocation-statement)
output)))))
@ -309,8 +309,8 @@
;; In case the function already has references, resolve them now. Future invocations will be
;; handled immediately (because it'll be in the generators list)
(var evaluated-success bool
(registerEvaluateGenerator environment (call-on c_str (field alias contents))
(at "output-aliased-c-function-invocation" (field environment generators))))
(registerEvaluateGenerator environment (call-on c_str (field alias contents))
(at "output-aliased-c-function-invocation" (field environment generators))))
(return evaluated-success))
@ -341,8 +341,8 @@
;; order is reversed
(printf "\n45 degrees about the Y axis, then translate:\n")
(var transformation-mat mat4
(mat4-multiply (mat4-translate (array 1.f 2.f 3.f))
(mat4-rotate-degrees 45.f g-up-axis)))
(mat4-multiply (mat4-translate (array 1.f 2.f 3.f))
(mat4-rotate-degrees 45.f g-up-axis)))
(mat4-print transformation-mat)
(var transformed-vec vec3 (mat4-transform-vec3 transformation-mat (array 1.f 0.f 0.f)))

9
src/Ogre.cake

@ -221,11 +221,10 @@
(call-on-ptr setPosition particle-emitter (array x y z))))
(defmacro var-cast-to (var-name symbol type any expression-to-cast any)
(tokenize-push
output
(var (token-splice var-name) (token-splice type)
(type-cast (token-splice expression-to-cast)
(token-splice type))))
(tokenize-push output
(var (token-splice var-name) (token-splice type)
(type-cast (token-splice expression-to-cast)
(token-splice type))))
(return true))
;; e.g. (negate 1) outputs (-1)

20
src/OgreInitialize.cake

@ -294,16 +294,16 @@
(defmacro use-ogre-build-options ()
(tokenize-push output
(add-build-options "-DOGRE_DEBUG_MODE=1"
;; Ignore an annoyingly long error in Ogre's code
"-Wno-gnu-inline-cpp-without-extern")
(add-c-search-directory-module
"Dependencies/ogre-next/OgreMain/include"
"Dependencies/ogre-next/Components/Hlms/Common/include"
"Dependencies/ogre-next/Components/Hlms/Pbs/include"
"Dependencies/ogre-next/Components/Hlms/Unlit/include"
"Dependencies/ogre-next/build/Debug/include"
"Dependencies/ogre-next/Components/Overlay/include"))
(add-build-options "-DOGRE_DEBUG_MODE=1"
;; Ignore an annoyingly long error in Ogre's code
"-Wno-gnu-inline-cpp-without-extern")
(add-c-search-directory-module
"Dependencies/ogre-next/OgreMain/include"
"Dependencies/ogre-next/Components/Hlms/Common/include"
"Dependencies/ogre-next/Components/Hlms/Pbs/include"
"Dependencies/ogre-next/Components/Hlms/Unlit/include"
"Dependencies/ogre-next/build/Debug/include"
"Dependencies/ogre-next/Components/Overlay/include"))
(return true))
(use-ogre-build-options)

2
src/SDL.cake

@ -293,7 +293,7 @@ Note that you can also build SDL manually. This can be useful if you are porting
;; For now, an easy way to build files which include SDL headers
(defmacro module-use-sdl-build-options ()
(tokenize-push output
(add-c-search-directory-module "Dependencies/SDL/buildSDLBuild/include/SDL2"))
(add-c-search-directory-module "Dependencies/SDL/buildSDLBuild/include/SDL2"))
(return true))
(module-use-sdl-build-options)

15
src/Tracy.cake

@ -26,11 +26,10 @@
(return 0))
(defmacro scope-timed (scope-label string &rest body any)
(tokenize-push
output
(scope
(ZoneScopedN (token-splice scope-label))
(token-splice-rest body tokens)))
(tokenize-push output
(scope
(ZoneScopedN (token-splice scope-label))
(token-splice-rest body tokens)))
(return true))
;;
@ -66,9 +65,9 @@
;; For now, an easy way to build files which include necessary headers
(defmacro module-use-tracy-build-options ()
(tokenize-push output
(add-build-options "-DTRACY_ENABLE")
;; (add-build-options "-DTRACY_CALLSTACK=10") ;; TODO: Causes exit code 134, failing in tracy alloc
(add-c-search-directory-module "Dependencies/tracy"))
(add-build-options "-DTRACY_ENABLE")
;; (add-build-options "-DTRACY_CALLSTACK=10") ;; TODO: Causes exit code 134, failing in tracy alloc
(add-c-search-directory-module "Dependencies/tracy"))
(return true))
(module-use-tracy-build-options)

Loading…
Cancel
Save