File: wxh.tcl

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (63 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download | duplicates (2)
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
## -*- tcl -*-
# ### ### ### ######### ######### #########
## Support declarations

# ### ### ### ######### ######### #########
## Type definitions

critcl::resulttype wxh {
    Tcl_SetObjResult(interp, wxh_box (interp, &rv));
    return TCL_OK;
} wxh

critcl::argtype wxh {
    if (wxh_unbox (interp, @@, &@A) != TCL_OK) return TCL_ERROR;
} wxh wxh

# ### ### ### ######### ######### #########
## Support implementation

critcl::ccode {
    typedef struct wxh {
	double w;
	double h;
    } wxh;

    static int
    wxh_unbox (Tcl_Interp* interp, Tcl_Obj* obj, wxh* p)
    {
	Tcl_Size  lc;
	Tcl_Obj** lv;

	if (Tcl_ListObjGetElements (interp, obj, &lc, &lv) != TCL_OK)  /* OK tcl9 */
	    return TCL_ERROR;
	if (lc != 2) {
	    Tcl_SetErrorCode (interp, "MAP", "SLIPPY", "INVALID", "WXH", NULL);
	    Tcl_AppendResult (interp, "Bad WxH, expected list of 2", NULL);
	    return TCL_ERROR;
	}

	double h;
	double w;

	if (Tcl_GetDoubleFromObj (interp, lv[0], &w) != TCL_OK) return TCL_ERROR;
	if (Tcl_GetDoubleFromObj (interp, lv[1], &h) != TCL_OK) return TCL_ERROR;

	p->h = h;
	p->w = w;

	return TCL_OK;
    }

    static Tcl_Obj*
    wxh_box (Tcl_Interp* interp, wxh* p)
    {
	Tcl_Obj* cl[2];
	cl [0] = Tcl_NewDoubleObj (p->w);
	cl [1] = Tcl_NewDoubleObj (p->h);
	return Tcl_NewListObj(2, cl); /* OK tcl9 */
    }
}

# ### ### ### ######### ######### #########
return