File: sets_c.tcl

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (93 lines) | stat: -rw-r--r-- 3,264 bytes parent folder | download | duplicates (7)
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
84
85
86
87
88
89
90
91
92
93
#----------------------------------------------------------------------
#
# sets_tcl.tcl --
#
#       Definitions for the processing of sets. C implementation.
#
# Copyright (c) 2007 by Andreas Kupries.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: sets_c.tcl,v 1.3 2008/03/25 07:15:34 andreas_kupries Exp $
#
#----------------------------------------------------------------------

package require critcl
# @sak notprovided struct_setc
package provide struct_setc 2.1.1
package require Tcl 8.4

namespace eval ::struct {
    # Supporting code for the main command.

    catch {
        #critcl::cheaders -g
        #critcl::debug memory symbols
    }

    critcl::cheaders sets/*.h
    critcl::csources sets/*.c

    critcl::ccode {
        /* -*- c -*- */

        #include <m.h>
    }

    # Main command, set creation.

    critcl::ccommand set_critcl {dummy interp objc objv} {
	/* Syntax - dispatcher to the sub commands.
	 */

        static CONST char* methods [] = {
            "add",      "contains",     "difference",   "empty",
            "equal","exclude",  "include",      "intersect",
            "intersect3",       "size", "subsetof",     "subtract",
            "symdiff",  "union",
            NULL
        };
        enum methods {
            S_add,      S_contains,     S_difference,   S_empty,
            S_equal,S_exclude,  S_include,      S_intersect,
            S_intersect3,       S_size, S_subsetof,     S_subtract,
            S_symdiff,  S_union
        };

	int m;

        if (objc < 2) {
            Tcl_WrongNumArgs (interp, objc, objv, "cmd ?arg ...?");
            return TCL_ERROR;
        } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option",
            0, &m) != TCL_OK) {
            return TCL_ERROR;
        }

        /* Dispatch to methods. They check the #args in detail before performing
         * the requested functionality
         */

        switch (m) {
            case S_add:        return sm_ADD        (NULL, interp, objc, objv);
            case S_contains:   return sm_CONTAINS   (NULL, interp, objc, objv);
            case S_difference: return sm_DIFFERENCE (NULL, interp, objc, objv);
            case S_empty:      return sm_EMPTY      (NULL, interp, objc, objv);
            case S_equal:      return sm_EQUAL      (NULL, interp, objc, objv);
            case S_exclude:    return sm_EXCLUDE    (NULL, interp, objc, objv);
            case S_include:    return sm_INCLUDE    (NULL, interp, objc, objv);
            case S_intersect:  return sm_INTERSECT  (NULL, interp, objc, objv);
            case S_intersect3: return sm_INTERSECT3 (NULL, interp, objc, objv);
            case S_size:       return sm_SIZE       (NULL, interp, objc, objv);
            case S_subsetof:   return sm_SUBSETOF   (NULL, interp, objc, objv);
            case S_subtract:   return sm_SUBTRACT   (NULL, interp, objc, objv);
            case S_symdiff:    return sm_SYMDIFF    (NULL, interp, objc, objv);
            case S_union:      return sm_UNION      (NULL, interp, objc, objv);
        }
        /* Not coming to this place */
    }
}

# ### ### ### ######### ######### #########
## Ready