added hcl_htonoow/hcl_ntohoow and the like
This commit is contained in:
parent
b926b1a658
commit
2243a1357d
@ -226,7 +226,6 @@ redo:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hcl_oow_t hcl_countcnodecons (hcl_t* hcl, hcl_cnode_t* cons)
|
hcl_oow_t hcl_countcnodecons (hcl_t* hcl, hcl_cnode_t* cons)
|
||||||
{
|
{
|
||||||
/* this function ignores the last cdr */
|
/* this function ignores the last cdr */
|
||||||
|
@ -2177,7 +2177,7 @@ static hcl_oop_lambda_t find_cmethod_noseterr (hcl_t* hcl, hcl_oop_class_t class
|
|||||||
val = HCL_CONS_CDR(ass);
|
val = HCL_CONS_CDR(ass);
|
||||||
if (HCL_IS_CONS(hcl, val) && !HCL_IS_NIL(hcl, HCL_CONS_CAR(val)))
|
if (HCL_IS_CONS(hcl, val) && !HCL_IS_NIL(hcl, HCL_CONS_CAR(val)))
|
||||||
{
|
{
|
||||||
/* TODO: futher check if it's a method block? */
|
/* TODO: further check if it's a method block? */
|
||||||
*owner = class_;
|
*owner = class_;
|
||||||
/* ivaroff isn't useful for a clas smethod but is useful for class instatiation method
|
/* ivaroff isn't useful for a clas smethod but is useful for class instatiation method
|
||||||
* (INSTA bit on in the mask field) */
|
* (INSTA bit on in the mask field) */
|
||||||
@ -2227,7 +2227,7 @@ static hcl_oop_lambda_t find_imethod_noseterr (hcl_t* hcl, hcl_oop_class_t class
|
|||||||
val = HCL_CONS_CDR(ass);
|
val = HCL_CONS_CDR(ass);
|
||||||
if (HCL_IS_CONS(hcl, val) && !HCL_IS_NIL(hcl, HCL_CONS_CDR(val)))
|
if (HCL_IS_CONS(hcl, val) && !HCL_IS_NIL(hcl, HCL_CONS_CDR(val)))
|
||||||
{
|
{
|
||||||
/* TODO: futher check if it's a method block? */
|
/* TODO: further check if it's a method block? */
|
||||||
*owner = class_;
|
*owner = class_;
|
||||||
*ivaroff = HCL_OOP_TO_SMOOI(class_->nivars_super);
|
*ivaroff = HCL_OOP_TO_SMOOI(class_->nivars_super);
|
||||||
return (hcl_oop_lambda_t)HCL_CONS_CDR(val); /* car - class method, cdr - instance method */
|
return (hcl_oop_lambda_t)HCL_CONS_CDR(val); /* car - class method, cdr - instance method */
|
||||||
|
@ -213,6 +213,20 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HCL_HAVE_SIZEOF_UINT16_T) && (HCL_SIZEOF_OF_UINT16_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define HCL_CONST_NTOHOOW(x) HCL_CONST_NTOH16(x)
|
||||||
|
# define HCL_CONST_HTONOOW(x) HCL_CONST_HTON16(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT32_T) && (HCL_SIZEOF_OF_UINT32_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define HCL_CONST_NTOHOOW(x) HCL_CONST_NTOH32(x)
|
||||||
|
# define HCL_CONST_HTONOOW(x) HCL_CONST_HTON32(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT64_T) && (HCL_SIZEOF_OF_UINT64_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define HCL_CONST_NTOHOOW(x) HCL_CONST_NTOH64(x)
|
||||||
|
# define HCL_CONST_HTONOOW(x) HCL_CONST_HTON64(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT128_T) && (HCL_SIZEOF_OF_UINT128_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define HCL_CONST_NTOHOOW(x) HCL_CONST_NTOH128(x)
|
||||||
|
# define HCL_CONST_HTONOOW(x) HCL_CONST_HTON128(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* HASH
|
* HASH
|
||||||
* ========================================================================= */
|
* ========================================================================= */
|
||||||
@ -1052,7 +1066,6 @@ static HCL_INLINE hcl_uint128_t hcl_bswap128 (hcl_uint128_t x)
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(HCL_HAVE_UINT128_T)
|
# if defined(HCL_HAVE_UINT128_T)
|
||||||
|
|
||||||
# define hcl_hton128(x) hcl_bswap128(x)
|
# define hcl_hton128(x) hcl_bswap128(x)
|
||||||
# define hcl_ntoh128(x) hcl_bswap128(x)
|
# define hcl_ntoh128(x) hcl_bswap128(x)
|
||||||
# define hcl_htobe128(x) hcl_bswap128(x)
|
# define hcl_htobe128(x) hcl_bswap128(x)
|
||||||
@ -1103,6 +1116,20 @@ static HCL_INLINE hcl_uint128_t hcl_bswap128 (hcl_uint128_t x)
|
|||||||
# error UNKNOWN ENDIAN
|
# error UNKNOWN ENDIAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HCL_HAVE_SIZEOF_UINT16_T) && (HCL_SIZEOF_OF_UINT16_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define hcl_ntohoow(x) hcl_ntoh16(x)
|
||||||
|
# define hcl_htonoow(x) hcl_hton16(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT32_T) && (HCL_SIZEOF_OF_UINT32_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define hcl_ntohoow(x) hcl_ntoh32(x)
|
||||||
|
# define hcl_htonoow(x) hcl_hton32(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT64_T) && (HCL_SIZEOF_OF_UINT64_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define hcl_ntohoow(x) hcl_ntoh64(x)
|
||||||
|
# define hcl_htonoow(x) hcl_hton64(x)
|
||||||
|
#elif defined(HCL_HAVE_SIZEOF_UINT128_T) && (HCL_SIZEOF_OF_UINT128_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define hcl_ntohoow(x) hcl_ntoh128(x)
|
||||||
|
# define hcl_htonoow(x) hcl_hton128(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* BIT POSITION
|
* BIT POSITION
|
||||||
* ========================================================================= */
|
* ========================================================================= */
|
||||||
|
11
lib/hcl.h
11
lib/hcl.h
@ -1199,6 +1199,7 @@ enum hcl_io_cmd_t
|
|||||||
HCL_IO_OPEN,
|
HCL_IO_OPEN,
|
||||||
HCL_IO_CLOSE,
|
HCL_IO_CLOSE,
|
||||||
HCL_IO_READ,
|
HCL_IO_READ,
|
||||||
|
HCL_IO_READ_BYTES,
|
||||||
HCL_IO_WRITE,
|
HCL_IO_WRITE,
|
||||||
HCL_IO_WRITE_BYTES,
|
HCL_IO_WRITE_BYTES,
|
||||||
HCL_IO_FLUSH
|
HCL_IO_FLUSH
|
||||||
@ -1284,10 +1285,14 @@ struct hcl_io_udiarg_t
|
|||||||
/**
|
/**
|
||||||
* [OUT] place data here for #HCL_IO_READ
|
* [OUT] place data here for #HCL_IO_READ
|
||||||
*/
|
*/
|
||||||
hcl_ooch_t buf[2048]; /* TODO: resize this if necessary */
|
union {
|
||||||
|
hcl_ooch_t c[2048]; /* TODO: resize this if necessary */
|
||||||
|
hcl_uint8_t b[2048 * HCL_SIZEOF(hcl_ooch_t)]; /* TODO: resize this if necessary */
|
||||||
|
} buf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [OUT] place the number of characters read here for #HCL_IO_READ
|
* [OUT] place the number of characters read here for
|
||||||
|
* #HCL_IO_READ or #HCL_IO_READ_BYTES
|
||||||
*/
|
*/
|
||||||
hcl_oow_t xlen;
|
hcl_oow_t xlen;
|
||||||
};
|
};
|
||||||
@ -1318,7 +1323,7 @@ struct hcl_io_udoarg_t
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [OUT] place the number of characters/bytes written here for
|
* [OUT] place the number of characters/bytes written here for
|
||||||
* HCL_IO_WRITE or HCL_IO_WRITE_BYTES
|
* #HCL_IO_WRITE or #HCL_IO_WRITE_BYTES
|
||||||
*/
|
*/
|
||||||
hcl_oow_t xlen;
|
hcl_oow_t xlen;
|
||||||
};
|
};
|
||||||
|
56
lib/std.c
56
lib/std.c
@ -3398,6 +3398,9 @@ static int cci_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
|
|||||||
/* no effect on an input stream */
|
/* no effect on an input stream */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case HCL_IO_READ_BYTES: /* byte input prohibited */
|
||||||
|
case HCL_IO_WRITE: /* character output prohibit */
|
||||||
|
case HCL_IO_WRITE_BYTES: /* byte output prohibit */
|
||||||
default:
|
default:
|
||||||
hcl_seterrnum (hcl, HCL_EINTERN);
|
hcl_seterrnum (hcl, HCL_EINTERN);
|
||||||
return -1;
|
return -1;
|
||||||
@ -3490,8 +3493,8 @@ static HCL_INLINE int read_udi_stream (hcl_t* hcl, hcl_io_udiarg_t* arg)
|
|||||||
|
|
||||||
#if defined(HCL_OOCH_IS_UCH)
|
#if defined(HCL_OOCH_IS_UCH)
|
||||||
bcslen = bb->len;
|
bcslen = bb->len;
|
||||||
ucslen = HCL_COUNTOF(arg->buf);
|
ucslen = HCL_COUNTOF(arg->buf.c);
|
||||||
x = hcl_convbtooochars(hcl, bb->buf, &bcslen, arg->buf, &ucslen);
|
x = hcl_convbtooochars(hcl, bb->buf, &bcslen, arg->buf.c, &ucslen);
|
||||||
if (x <= -1 && ucslen <= 0) return -1;
|
if (x <= -1 && ucslen <= 0) return -1;
|
||||||
/* if ucslen is greater than 0, i assume that some characters have been
|
/* if ucslen is greater than 0, i assume that some characters have been
|
||||||
* converted properly. as the loop above reads an entire line if not too
|
* converted properly. as the loop above reads an entire line if not too
|
||||||
@ -3499,9 +3502,9 @@ static HCL_INLINE int read_udi_stream (hcl_t* hcl, hcl_io_udiarg_t* arg)
|
|||||||
* successful conversion of at least 1 ooch character. so no explicit
|
* successful conversion of at least 1 ooch character. so no explicit
|
||||||
* check for the incomplete sequence error is required */
|
* check for the incomplete sequence error is required */
|
||||||
#else
|
#else
|
||||||
bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf);
|
bcslen = (bb->len < HCL_COUNTOF(arg->buf.c))? bb->len: HCL_COUNTOF(arg->buf.c);
|
||||||
ucslen = bcslen;
|
ucslen = bcslen;
|
||||||
hcl_copy_bchars (arg->buf, bb->buf, bcslen);
|
hcl_copy_bchars (arg->buf.c, bb->buf, bcslen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
remlen = bb->len - bcslen;
|
remlen = bb->len - bcslen;
|
||||||
@ -3512,6 +3515,44 @@ static HCL_INLINE int read_udi_stream (hcl_t* hcl, hcl_io_udiarg_t* arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HCL_INLINE int read_udi_stream_bytes (hcl_t* hcl, hcl_io_udiarg_t* arg)
|
||||||
|
{
|
||||||
|
/*xtn_t* xtn = GET_XTN(hcl);*/
|
||||||
|
bb_t* bb;
|
||||||
|
hcl_oow_t bcslen, ucslen, remlen;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
bb = (bb_t*)arg->handle;
|
||||||
|
HCL_ASSERT (hcl, bb != HCL_NULL && bb->fp != HCL_NULL);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
x = fgetc(bb->fp);
|
||||||
|
if (x == EOF)
|
||||||
|
{
|
||||||
|
if (ferror((FILE*)bb->fp))
|
||||||
|
{
|
||||||
|
hcl_seterrnum (hcl, HCL_EIOERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bb->buf[bb->len++] = x;
|
||||||
|
}
|
||||||
|
while (bb->len < HCL_COUNTOF(bb->buf) && x != '\r' && x != '\n');
|
||||||
|
|
||||||
|
bcslen = (bb->len < HCL_COUNTOF(arg->buf.b))? bb->len: HCL_COUNTOF(arg->buf.b);
|
||||||
|
ucslen = bcslen;
|
||||||
|
hcl_copy_bchars (arg->buf.b, bb->buf, bcslen);
|
||||||
|
|
||||||
|
remlen = bb->len - bcslen;
|
||||||
|
if (remlen > 0) HCL_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen);
|
||||||
|
bb->len = remlen;
|
||||||
|
|
||||||
|
arg->xlen = ucslen;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int udi_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
|
static int udi_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
@ -3525,6 +3566,9 @@ static int udi_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
|
|||||||
case HCL_IO_READ:
|
case HCL_IO_READ:
|
||||||
return read_udi_stream(hcl, (hcl_io_udiarg_t*)arg);
|
return read_udi_stream(hcl, (hcl_io_udiarg_t*)arg);
|
||||||
|
|
||||||
|
case HCL_IO_READ_BYTES:
|
||||||
|
return read_udi_stream_bytes(hcl, (hcl_io_udiarg_t*)arg);
|
||||||
|
|
||||||
case HCL_IO_FLUSH:
|
case HCL_IO_FLUSH:
|
||||||
/* no effect on an input stream */
|
/* no effect on an input stream */
|
||||||
return 0;
|
return 0;
|
||||||
@ -3613,7 +3657,7 @@ static HCL_INLINE int write_udo_stream (hcl_t* hcl, hcl_io_udoarg_t* arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HCL_INLINE int write_bytes_udo_stream (hcl_t* hcl, hcl_io_udoarg_t* arg)
|
static HCL_INLINE int write_udo_stream_bytes (hcl_t* hcl, hcl_io_udoarg_t* arg)
|
||||||
{
|
{
|
||||||
/*xtn_t* xtn = GET_XTN(hcl);*/
|
/*xtn_t* xtn = GET_XTN(hcl);*/
|
||||||
const hcl_uint8_t* ptr;
|
const hcl_uint8_t* ptr;
|
||||||
@ -3655,7 +3699,7 @@ static int udo_handler (hcl_t* hcl, hcl_io_cmd_t cmd, void* arg)
|
|||||||
return write_udo_stream(hcl, (hcl_io_udoarg_t*)arg);
|
return write_udo_stream(hcl, (hcl_io_udoarg_t*)arg);
|
||||||
|
|
||||||
case HCL_IO_WRITE_BYTES:
|
case HCL_IO_WRITE_BYTES:
|
||||||
return write_bytes_udo_stream(hcl, (hcl_io_udoarg_t*)arg);
|
return write_udo_stream_bytes(hcl, (hcl_io_udoarg_t*)arg);
|
||||||
|
|
||||||
case HCL_IO_FLUSH:
|
case HCL_IO_FLUSH:
|
||||||
return flush_udo_stream(hcl, (hcl_io_udoarg_t*)arg);
|
return flush_udo_stream(hcl, (hcl_io_udoarg_t*)arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user