本文整理汇总了C++中DUK_HBUFFER_HAS_DYNAMIC函数的典型用法代码示例。如果您正苦于以下问题:C++ DUK_HBUFFER_HAS_DYNAMIC函数的具体用法?C++ DUK_HBUFFER_HAS_DYNAMIC怎么用?C++ DUK_HBUFFER_HAS_DYNAMIC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DUK_HBUFFER_HAS_DYNAMIC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: duk_hbuffer_append_byte
void duk_hbuffer_append_byte(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_uint8_t byte) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
duk_hbuffer_insert_bytes(thr, buf, DUK_HBUFFER_GET_SIZE(buf), &byte, 1);
}
示例2: duk_hbuffer_insert_byte
void duk_hbuffer_insert_byte(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t offset, duk_uint8_t byte) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
duk_hbuffer_insert_bytes(thr, buf, offset, &byte, 1);
}
示例3: duk_hbuffer_reset
void duk_hbuffer_reset(duk_hthread *thr, duk_hbuffer_dynamic *buf) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
duk_hbuffer_resize(thr, buf, 0, 0);
}
示例4: duk_bi_duktape_object_line
duk_ret_t duk_bi_duktape_object_line(duk_context *ctx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_activation *act_caller;
duk_hobject *h_func;
duk_hbuffer_fixed *pc2line;
duk_uint_fast32_t pc;
duk_uint_fast32_t line;
if (thr->callstack_top < 2) {
return 0;
}
act_caller = thr->callstack + thr->callstack_top - 2;
h_func = act_caller->func;
DUK_ASSERT(h_func != NULL);
if (!DUK_HOBJECT_HAS_COMPILEDFUNCTION(h_func)) {
return 0;
}
/* FIXME: shared helper */
duk_push_hobject(ctx, h_func);
duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_PC2LINE);
if (duk_is_buffer(ctx, -1)) {
pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(ctx, -1);
DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line));
pc = (duk_uint_fast32_t) act_caller->pc;
line = duk_hobject_pc2line_query(pc2line, (duk_uint_fast32_t) pc);
} else {
line = 0;
}
duk_push_int(ctx, (int) line); /* FIXME: typing */
return 1;
}
示例5: DUK_ASSERT
DUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hbuffer_dynamic *h;
void *ptr;
duk_size_t sz;
DUK_ASSERT(ctx != NULL);
h = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, index);
DUK_ASSERT(h != NULL);
if (!DUK_HBUFFER_HAS_DYNAMIC(h)) {
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_BUFFER_NOT_DYNAMIC);
}
/* Forget the previous allocation, setting size to 0 and alloc to
* NULL. Caller is responsible for freeing the previous allocation.
* Getting the allocation and clearing it is done in the same API
* call to avoid any chance of a realloc.
*/
ptr = DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);
sz = DUK_HBUFFER_DYNAMIC_GET_SIZE(h);
if (out_size) {
*out_size = sz;
}
DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(thr->heap, h);
DUK_HBUFFER_DYNAMIC_SET_SIZE(h, 0);
DUK_HBUFFER_DYNAMIC_SET_ALLOC_SIZE(h, 0);
return ptr;
}
示例6: duk_hbuffer_remove_slice
void duk_hbuffer_remove_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t offset, size_t length) {
char *p;
size_t end_offset;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(offset >= 0); /* always true */
DUK_ASSERT(offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT(length >= 0); /* always true */
DUK_ASSERT(offset + length <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
if (length == 0) {
return;
}
p = (char *) DUK_HBUFFER_DYNAMIC_GET_CURR_DATA_PTR(buf);
end_offset = offset + length;
if (end_offset < DUK_HBUFFER_GET_SIZE(buf)) {
/* not strictly from end of buffer; need to shuffle data */
DUK_MEMMOVE(p + offset,
p + end_offset,
DUK_HBUFFER_GET_SIZE(buf) - end_offset); /* always > 0 */
}
DUK_MEMSET(p + DUK_HBUFFER_GET_SIZE(buf) - length,
0,
length); /* always > 0 */
buf->size -= length;
/* Note: no shrink check, intentional */
}
示例7: duk_hbuffer_append_bytes
void duk_hbuffer_append_bytes(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_uint8_t *data, size_t length) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(data != NULL);
duk_hbuffer_insert_bytes(thr, buf, DUK_HBUFFER_GET_SIZE(buf), data, length);
}
示例8: duk_hbuffer_compact
void duk_hbuffer_compact(duk_hthread *thr, duk_hbuffer_dynamic *buf) {
size_t curr_size;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
curr_size = DUK_HBUFFER_GET_SIZE(buf);
duk_hbuffer_resize(thr, buf, curr_size, curr_size);
}
示例9: duk_free_hbuffer_inner
DUK_INTERNAL void duk_free_hbuffer_inner(duk_heap *heap, duk_hbuffer *h) {
DUK_ASSERT(heap != NULL);
DUK_ASSERT(h != NULL);
if (DUK_HBUFFER_HAS_DYNAMIC(h)) {
duk_hbuffer_dynamic *g = (duk_hbuffer_dynamic *) h;
DUK_DDD(DUK_DDDPRINT("free dynamic buffer %p", (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(g)));
DUK_FREE(heap, DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(g));
}
}
示例10: duk__free_hbuffer_inner
static void duk__free_hbuffer_inner(duk_heap *heap, duk_hbuffer *h) {
DUK_ASSERT(heap != NULL);
DUK_ASSERT(h != NULL);
if (DUK_HBUFFER_HAS_DYNAMIC(h)) {
duk_hbuffer_dynamic *g = (duk_hbuffer_dynamic *) h;
DUK_DDD(DUK_DDDPRINT("free dynamic buffer %p", g->curr_alloc));
DUK_FREE(heap, g->curr_alloc);
}
}
示例11: duk_bi_duktape_object_act
duk_ret_t duk_bi_duktape_object_act(duk_context *ctx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_activation *act;
duk_hobject *h_func;
duk_hbuffer_fixed *pc2line;
duk_uint_fast32_t pc;
duk_uint_fast32_t line;
duk_int_t level;
/* -1 = top callstack entry, callstack[callstack_top - 1]
* -callstack_top = bottom callstack entry, callstack[0]
*/
level = duk_to_int(ctx, 0);
if (level >= 0 || -level > (duk_int_t) thr->callstack_top) {
return 0;
}
DUK_ASSERT(level >= -((duk_int_t) thr->callstack_top) && level <= -1);
act = thr->callstack + thr->callstack_top + level;
duk_push_object(ctx);
h_func = act->func;
DUK_ASSERT(h_func != NULL);
duk_push_hobject(ctx, h_func);
pc = (duk_uint_fast32_t) act->pc;
duk_push_int(ctx, (int) pc); /* FIXME: typing */
duk_get_prop_stridx(ctx, -2, DUK_STRIDX_INT_PC2LINE);
if (duk_is_buffer(ctx, -1)) {
pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(ctx, -1);
DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line));
pc = (duk_uint_fast32_t) act->pc;
line = duk_hobject_pc2line_query(pc2line, (duk_uint_fast32_t) pc);
} else {
line = 0;
}
duk_pop(ctx);
duk_push_int(ctx, (int) line); /* FIXME: typing */
/* Providing access to e.g. act->lex_env would be dangerous: these
* internal structures must never be accessible to the application.
* Duktape relies on them having consistent data, and this consistency
* is only asserted for, not checked for.
*/
/* [ level obj func pc line ] */
/* FIXME: version specific array format instead? */
duk_def_prop_stridx(ctx, -4, DUK_STRIDX_LINE_NUMBER, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx(ctx, -3, DUK_STRIDX_PC, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_LC_FUNCTION, DUK_PROPDESC_FLAGS_WEC);
return 1;
}
示例12: duk_hbuffer_append_cstring
size_t duk_hbuffer_append_cstring(duk_hthread *thr, duk_hbuffer_dynamic *buf, const char *str) {
size_t len;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(str != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
len = DUK_STRLEN(str);
duk_hbuffer_insert_bytes(thr, buf, DUK_HBUFFER_GET_SIZE(buf), (duk_uint8_t *) str, len);
return len;
}
示例13: duk_hbuffer_append_hstring
size_t duk_hbuffer_append_hstring(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_hstring *str) {
size_t len;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(str != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
len = DUK_HSTRING_GET_BYTELEN(str);
duk_hbuffer_insert_bytes(thr, buf, DUK_HBUFFER_GET_SIZE(buf), (duk_uint8_t *) DUK_HSTRING_GET_DATA(str), len);
return len;
}
示例14: duk_hbuffer_insert_cstring
size_t duk_hbuffer_insert_cstring(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t offset, const char *str) {
size_t len;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(str != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
len = strlen(str);
duk_hbuffer_insert_bytes(thr, buf, offset, (duk_uint8_t *) str, len);
return len;
}
示例15: duk_hbuffer_append_slice
void duk_hbuffer_append_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t src_offset, size_t length) {
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT_DISABLE(src_offset >= 0); /* always true */
DUK_ASSERT(src_offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT_DISABLE(length >= 0); /* always true */
DUK_ASSERT(src_offset + length <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
duk_hbuffer_insert_slice(thr,
buf,
DUK_HBUFFER_GET_SIZE(buf),
src_offset,
length);
}