Mercurial > repos > tabletprog
view modules/string.tp @ 130:6a1a716bb8c6
Some CSS tweaks for tablet browsers
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 06 Aug 2013 00:53:03 -0700 |
parents | 474f17ebaaa0 |
children | 4c96a393103e |
line wrap: on
line source
#{ llProperty: len withType: uint32_t llProperty: bytes withType: uint32_t llProperty: data withType: (char ptr) llMessage: length withVars: { intret <- (obj_int32 ptr) } andCode: { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 intret num!: len intret } llMessage: byte_length withVars: { intret <- (obj_int32 ptr) } andCode: { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 intret num!: bytes intret } llMessage: EQ_ withVars: { argb <- (string ptr) } andCode: :argb { if: len = (argb len) && bytes = (argb bytes) && (not: (memcmp: data (argb data) bytes)) { true } } llMessage: NEQ_ withVars: { argb <- (string ptr) } andCode: :argb { if: len != (argb len) || bytes != (argb bytes) || (memcmp: data (argb data) bytes) { true } } llMessage: print withVars: {} andCode: { fwrite: data 1 bytes stdout self } llMessage: string withVars: {} andCode: { self } llMessage: CAT_ withVars: { argbo <- (object ptr) argb <- (string ptr) out <- (string ptr) } andCode: :argbo { argb <- mcall: string 1 argbo out <- make_object: (addr_of: string_meta) NULL 0 out bytes!: bytes + (argb bytes) out len!: len + (argb len) out data!: (GC_MALLOC_ATOMIC: (out bytes) + 1) memcpy: (out data) data bytes memcpy: (out data) + bytes (argb data) (argb bytes) + 1 out } llMessage: byte withVars: { index <- (obj_int32 ptr) intret <- (obj_int32 ptr) } andCode: :index { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 intret num!: (if: (index num) < bytes { data get: (index num) } else: {0}) intret } llMessage: int32 withVars: { intret <- (obj_int32 ptr) } andCode: { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 intret num!: (atoi: data) intret } llMessage: hash withVars: { intret <- (obj_int32 ptr) i <- uint32_t } andCode: { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 intret num!: 0 if: bytes { intret num!: (data get: 0) * 128 i <- 0 while: { i < bytes } do: { intret num!: (1000003 * (intret num)) xor (data get: i) i <- i + 1 } intret num!: (intret num) xor bytes } intret } }