bind/objc: add read/write Int and BOOL values.
Change-Id: I9e1d0c62acfa43cfc1b0dd79ff25b89b43a891cb Reviewed-on: https://go-review.googlesource.com/10710 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Родитель
1927b21e90
Коммит
b24fa8f869
|
@ -37,6 +37,8 @@ typedef struct GoSeq {
|
|||
// go_seq_free releases resources of the GoSeq.
|
||||
extern void go_seq_free(GoSeq *seq);
|
||||
|
||||
extern BOOL go_seq_readBool(GoSeq *seq);
|
||||
extern int go_seq_readInt(GoSeq *seq);
|
||||
extern int8_t go_seq_readInt8(GoSeq *seq);
|
||||
extern int16_t go_seq_readInt16(GoSeq *seq);
|
||||
extern int32_t go_seq_readInt32(GoSeq *seq);
|
||||
|
@ -47,6 +49,8 @@ extern GoSeqRef *go_seq_readRef(GoSeq *seq);
|
|||
extern NSString *go_seq_readUTF8(GoSeq *seq);
|
||||
extern NSData *go_seq_readByteArray(GoSeq *seq);
|
||||
|
||||
extern void go_seq_writeBool(GoSeq *seq, BOOL v);
|
||||
extern void go_seq_writeInt(GoSeq *seq, int v);
|
||||
extern void go_seq_writeInt8(GoSeq *seq, int8_t v);
|
||||
extern void go_seq_writeInt16(GoSeq *seq, int16_t v);
|
||||
extern void go_seq_writeInt32(GoSeq *seq, int32_t v);
|
||||
|
|
|
@ -90,6 +90,24 @@ void go_seq_free(GoSeq *m) {
|
|||
#define MEM_READ(seq, ty) ((ty *)mem_read(seq, sizeof(ty), sizeof(ty)))
|
||||
#define MEM_WRITE(seq, ty) (*(ty *)mem_write(seq, sizeof(ty), sizeof(ty)))
|
||||
|
||||
int go_seq_readInt(GoSeq *seq) {
|
||||
int64_t v = go_seq_readInt64(seq);
|
||||
return v; // Assume that Go-side used WriteInt to encode 'int' value.
|
||||
}
|
||||
|
||||
void go_seq_writeInt(GoSeq *seq, int v) {
|
||||
go_seq_writeInt64(seq, v);
|
||||
}
|
||||
|
||||
BOOL go_seq_readBool(GoSeq *seq) {
|
||||
int8_t v = go_seq_readInt8(seq);
|
||||
return v ? YES : NO;
|
||||
}
|
||||
|
||||
void go_seq_writeBool(GoSeq *seq, BOOL v) {
|
||||
go_seq_writeInt8(seq, v ? 1 : 0);
|
||||
}
|
||||
|
||||
int8_t go_seq_readInt8(GoSeq *seq) {
|
||||
int8_t *v = MEM_READ(seq, int8_t);
|
||||
return v == NULL ? 0 : *v;
|
||||
|
|
Загрузка…
Ссылка в новой задаче