utf8/string functions

This commit is contained in:
Justin Ethier 2016-03-29 00:32:50 -04:00
parent f2f5e191bd
commit 8ef3cb7e61
6 changed files with 40 additions and 3 deletions

View file

@ -360,6 +360,8 @@ extern const object primitive_vector_91set_67;
extern const object primitive_bytevector;
extern const object primitive_bytevector_91append;
extern const object primitive_Cyc_91bytevector_91copy;
extern const object primitive_Cyc_string_91_125utf8;
extern const object primitive_Cyc_utf8_91_125string;
extern const object primitive_bytevector_91u8_91ref;
extern const object primitive_bytevector_91u8_91set_67;
extern const object primitive_string_91ref;

View file

@ -2068,6 +2068,14 @@ void _Cyc_91bytevector_91copy(void *data, object cont, object args) {
object argc = Cyc_length(data, args);
Cyc_check_num_args(data, "Cyc-bytevector-copy", 3, args);
Cyc_bytevector_copy(data, cont, car(args), cadr(args), caddr(args)); }
void _Cyc_string_91_125utf8(void *data, object cont, object args) {
object argc = Cyc_length(data, args);
Cyc_check_num_args(data, "Cyc-string->utf8", 3, args);
Cyc_string2utf8(data, cont, car(args), cadr(args), caddr(args)); }
void _Cyc_utf8_91_125string(void *data, object cont, object args) {
object argc = Cyc_length(data, args);
Cyc_check_num_args(data, "Cyc-utf8->string", 3, args);
Cyc_utf82string(data, cont, car(args), cadr(args), caddr(args)); }
void _vector_91length(void *data, object cont, object args){
Cyc_check_num_args(data, "vector_91length", 1, args);
{ object obj = Cyc_vector_length(data, car(args));
@ -2904,7 +2912,8 @@ static primitive_type bytevector_91append_primitive = {{0}, primitive_tag, "byte
static primitive_type Cyc_91bytevector_91copy_primitive = {{0}, primitive_tag, "Cyc-bytevector-copy", &_Cyc_91bytevector_91copy};
static primitive_type bytevector_91u8_91ref_primitive = {{0}, primitive_tag, "bytevector-u8-ref", &_bytevector_91u8_91ref};
static primitive_type bytevector_91u8_91set_67_primitive = {{0}, primitive_tag, "bytevector-u8-set!", &_bytevector_91u8_91set_67};
static primitive_type Cyc_string_91_125utf8_primitive = {{0}, primitive_tag, "Cyc-string->utf8", &_Cyc_string_91_125utf8};
static primitive_type Cyc_utf8_91_125string_primitive = {{0}, primitive_tag, "Cyc-utf8->string", &_Cyc_utf8_91_125string};
static primitive_type make_91vector_primitive = {{0}, primitive_tag, "make-vector", &_make_91vector};
static primitive_type vector_91ref_primitive = {{0}, primitive_tag, "vector-ref", &_vector_91ref};
static primitive_type vector_91set_67_primitive = {{0}, primitive_tag, "vector-set!", &_vector_91set_67};
@ -3034,6 +3043,8 @@ const object primitive_bytevector_91append = &bytevector_91append_primitive;
const object primitive_Cyc_91bytevector_91copy = &Cyc_91bytevector_91copy_primitive;
const object primitive_bytevector_91u8_91ref = &bytevector_91u8_91ref_primitive;
const object primitive_bytevector_91u8_91set_67 = &bytevector_91u8_91set_67_primitive;
const object primitive_Cyc_string_91_125utf8 = & Cyc_string_91_125utf8_primitive;
const object primitive_Cyc_utf8_91_125string = &Cyc_utf8_91_125string_primitive;
const object primitive_list_91_125vector = &list_91_125vector_primitive;
const object primitive_boolean_127 = &boolean_127_primitive;
const object primitive_char_127 = &char_127_primitive;

View file

@ -153,6 +153,8 @@
eof-object
syntax-error
bytevector-copy
utf8->string
string->utf8
;;;;
; Possibly missing functions:
@ -168,10 +170,8 @@
;
; : No unicode support at this time
; peek-u8
; string->utf8
; read-u8
; u8-ready?
; utf8->string
; write-u8
;
; ; No complex or rational numbers at this time
@ -698,6 +698,16 @@
(start (if (> (length opts) 0) (car opts) 0))
(end (if (> (length opts) 1) (cadr opts) len)))
(Cyc-bytevector-copy bv start end)))
(define (utf8->string bv . opts)
(letrec ((len (bytevector-length bv))
(start (if (> (length opts) 0) (car opts) 0))
(end (if (> (length opts) 1) (cadr opts) len)))
(Cyc-utf8->string bv start end)))
(define (string->utf8 str . opts)
(letrec ((len (string-length str))
(start (if (> (length opts) 0) (car opts) 0))
(end (if (> (length opts) 1) (cadr opts) len)))
(Cyc-string->utf8 str start end)))
(define (vector->string vec . opts)
(let ((lst (apply vector->list (cons vec opts))))
(list->string lst)))

View file

@ -575,6 +575,8 @@
((eq? p 'bytevector) "Cyc_bytevector")
((eq? p 'bytevector-append) "Cyc_bytevector_append")
((eq? p 'Cyc-bytevector-copy) "Cyc_bytevector_copy")
((eq? p 'Cyc-utf8->string) "Cyc_utf82string")
((eq? p 'Cyc-string->utf8) "Cyc_string2utf8")
((eq? p 'bytevector-u8-ref) "Cyc_bytevector_u8_ref")
((eq? p 'bytevector-u8-set!) "Cyc_bytevector_u8_set")
((eq? p 'make-vector) "Cyc_make_vector")
@ -664,6 +666,8 @@
bytevector-length
bytevector-append
Cyc-bytevector-copy
Cyc-utf8->string
Cyc-string->utf8
bytevector
bytevector-u8-ref
bytevector-u8-set!
@ -722,6 +726,8 @@
((eq? p 'bytevector) "object")
((eq? p 'bytevector-append) "object")
((eq? p 'Cyc-bytevector-copy) "object")
((eq? p 'Cyc-utf8->string) "object")
((eq? p 'Cyc-string->utf8) "object")
((eq? p 'make-vector) "object")
((eq? p 'list->string) "object")
((eq? p 'list->vector) "object")
@ -744,6 +750,8 @@
bytevector
bytevector-append
Cyc-bytevector-copy
Cyc-utf8->string
Cyc-string->utf8
make-vector list->vector
symbol->string number->string
substring
@ -763,6 +771,8 @@
make-bytevector
bytevector-append
Cyc-bytevector-copy
Cyc-utf8->string
Cyc-string->utf8
bytevector
bytevector-u8-ref
bytevector-u8-set!

View file

@ -518,6 +518,8 @@
bytevector
bytevector-append
Cyc-bytevector-copy
Cyc-utf8->string
Cyc-string->utf8
bytevector-u8-ref
bytevector-u8-set!
bytevector?

View file

@ -248,6 +248,8 @@
(list 'bytevector-length bytevector-length)
(list 'bytevector-append bytevector-append)
(list 'Cyc-bytevector-copy Cyc-bytevector-copy)
;(list 'Cyc-utf8->string Cyc-utf8->string)
;(list 'Cyc-string->utf8 Cyc-string->utf8)
(list 'bytevector bytevector)
(list 'bytevector-u8-ref bytevector-u8-ref)
(list 'bytevector-u8-set! bytevector-u8-set!)