Browse Source

Move declare-extern into cakelisp, small cleanup

master
Macoy Madson 3 weeks ago
parent
commit
088741dd00
  1. 26
      src/DataBundle.cake
  2. 10
      src/Introspection.cake
  3. 3
      tools/gamelib.el

26
src/DataBundle.cake

@ -3,16 +3,6 @@
;; string or you'll get garbage at the end
(import "CHelpers.cake" "CppHelpers.cake" "ComptimeHelpers.cake" "BuildTools.cake")
;; I don't want to expose this until I've determined a clean way to do this.
(defgenerator declare-extern (statement-token (arg-index array))
(var statement (const ([] CStatementOperation))
(array
(array Keyword "extern" -1)
(array Statement null statement-token)))
(return (c-statement-out statement))
(return true))
;; Do not change these arguments without also changing usage of them in data-bundle-invocations
(defmacro bundle-file (start-var-name symbol end-var-name symbol var-base-type array
filename-token string)
@ -49,10 +39,10 @@
(token-contents-snprintf data-var-name-end-token "%s_end" data-var-name)
(tokenize-push output
(declare-extern (var (token-splice-addr data-var-name-start-token)
(token-splice var-base-type)))
(declare-extern (var (token-splice-addr data-var-name-end-token)
(token-splice var-base-type)))
(declare-external (var (token-splice-addr data-var-name-start-token)
(token-splice var-base-type)))
(declare-external (var (token-splice-addr data-var-name-end-token)
(token-splice var-base-type)))
(var (token-splice start-var-name) (* (token-splice var-base-type))
(addr (token-splice-addr data-var-name-start-token)))
(var (token-splice end-var-name) (* (token-splice var-base-type))
@ -212,10 +202,10 @@
(data-bundle-get-resource (token-splice-addr resource-name-token)))
(unless (field resource start-resource)
(return false))
(declare-extern (var (token-splice start-var-name-token)
(* (token-splice base-type-start-token))))
(declare-extern (var (token-splice end-var-name-token)
(* (token-splice base-type-start-token))))
(declare-external (var (token-splice start-var-name-token)
(* (token-splice base-type-start-token))))
(declare-external (var (token-splice end-var-name-token)
(* (token-splice base-type-start-token))))
(set (token-splice start-var-name-token)
(type-cast (field resource start-resource) (* (token-splice base-type-start-token))))
(set (token-splice end-var-name-token)

10
src/Introspection.cake

@ -820,20 +820,20 @@
write-introspect-struct-default
write-introspect-struct-add-newline)
;; When optional-limit-length is zero, write the string until a null terminator is encountered.
;; When optional-length is zero, write the string until a null terminator is encountered.
;; Otherwise, only write the given length.
(def-function-signature-global write-introspect-function (write-string (* (const char))
optional-limit-length (unsigned int)
optional-length (unsigned int)
userdata (* void)
&return bool))
(defun write-introspect-struct-file-writer (write-string (* (const char))
optional-limit-length (unsigned int)
optional-length (unsigned int)
userdata (* void)
&return bool)
(var-cast-to output-file (* FILE) userdata)
(if optional-limit-length
(fwrite write-string optional-limit-length 1 output-file)
(if optional-length
(fwrite write-string optional-length 1 output-file)
(fprintf output-file "%s" write-string))
(return true))

3
tools/gamelib.el

@ -18,6 +18,7 @@
(put 'introspect-field-dispatch 'lisp-indent-function 2)
(put 'introspect-override-register-handler 'lisp-indent-function 3)
(put 'def-introspect-struct 'lisp-indent-function 1))
(put 'def-introspect-struct 'lisp-indent-function 1)
(put 'define-remote-command 'lisp-indent-function 'defun))
(add-hook 'cakelisp-mode-hook 'gamelib-cakelisp-mode)

Loading…
Cancel
Save