mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 16:27:35 +02:00
Emit strings with char/byte lengths
This commit is contained in:
parent
42507606a5
commit
cfdec73d78
1 changed files with 13 additions and 1 deletions
|
@ -521,7 +521,15 @@
|
|||
(string-append "&" cvar-name) ; Code is just the variable name
|
||||
(list ; Allocate integer on the C stack
|
||||
(string-append
|
||||
"make_string(" cvar-name ", " (->cstr exp) ");")))))
|
||||
"make_utf8_string_with_len("
|
||||
cvar-name
|
||||
", "
|
||||
(->cstr exp)
|
||||
", "
|
||||
(number->string (string-byte-length exp))
|
||||
", "
|
||||
(number->string (string-length exp))
|
||||
");")))))
|
||||
;TODO: not good enough, need to store new symbols in a table so they can
|
||||
;be inserted into the C program
|
||||
((symbol? exp)
|
||||
|
@ -536,6 +544,10 @@
|
|||
(define (->cstr str)
|
||||
(string-append "\"" (cstr:escape-chars str) "\""))
|
||||
|
||||
(define-c string-byte-length
|
||||
"(void *data, int argc, closure _, object k, object s)"
|
||||
" return_closcall1(data, k, Cyc_string_byte_length(data, s)); ")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Primitives
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue