1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# cstack.tcl --
#
# Low-level stack data structure. With wrapping usable as
# a Tcl-level stack.
#
# Copyright (c) 2008-2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# Example of exporting a C-level stubs API through critcl v3, with a
# package header file containing public type definitions, macros,
# etc., and internal C companion files.
# # ## ### ##### ######## ############# #####################
## Requirements
package require Tcl 8.4
package require critcl 3 ;# stubs management
# # ## ### ##### ######## ############# #####################
## Administrivia
critcl::license {Andreas Kupries} BSD
critcl::summary {A C-level abstract datatype for stacks}
critcl::description {
This package implements an abstract
data type for stacks, at the C-level.
No Tcl-binding is provided. See package
'stackc' for that.
}
critcl::subject stack
critcl::subject {data structure}
critcl::subject structure
critcl::subject {abstract data structure}
critcl::subject {generic data structure}
# # ## ### ##### ######## ############# #####################
## Configuration
critcl::api header cstack.h
critcl::cheaders cstackInt.h
# # ## ### ##### ######## ############# #####################
## Exported API
#
# Notes
# - push -- Item allocation is responsibility of caller.
# Stack takes ownership of the item.
# - pop -- Stack frees allocated item.
# - trim -- Ditto
# - top -- Provides top item, no transfer of ownership.
# - del -- Releases stack, cell array, and items, if any.
# - drop -- Like pop, but doesn't free, assumes that caller
# is taking ownership of the pointer.
#
critcl::api function CSTACK cstack_new {CSTACK_CELL_FREE freeCell void* clientdata}
critcl::api function void cstack_del {CSTACK s}
critcl::api function {long int} cstack_size {CSTACK s}
critcl::api function void* cstack_top {CSTACK s}
critcl::api function void cstack_push {CSTACK s void* item}
critcl::api function void cstack_pop {CSTACK s {long int} n}
critcl::api function void cstack_trim {CSTACK s {long int} n}
critcl::api function void cstack_drop {CSTACK s {long int} n}
critcl::api function void cstack_rol {CSTACK s {long int} n {long int} step}
critcl::api function void cstack_get {CSTACK s {long int} n CSTACK_DIRECTION dir CSTACK_SLICE* slice}
critcl::api function void cstack_move {CSTACK s CSTACK src}
critcl::api function void cstack_clientdata_set {CSTACK s void* clientdata}
critcl::api function void* cstack_clientdata_get {CSTACK s}
# # ## ### ##### ######## ############# #####################
## Implementation.
critcl::csources cstack.c
critcl::ccode {} ; # Fake the 'nothing to build detector'
# ### ### ### ######### ######### #########
## Ready
package provide cstack 1
|