~ubuntu-branches/ubuntu/utopic/critcl/utopic

« back to all changes in this revision

Viewing changes to examples/stack/cstack.tcl

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura
  • Date: 2013-05-11 00:08:06 UTC
  • Revision ID: package-import@ubuntu.com-20130511000806-7hq1zc3fnn0gat79
Tags: upstream-3.1.9
ImportĀ upstreamĀ versionĀ 3.1.9

Show diffs side-by-side

added added

removed removed

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