summaryrefslogtreecommitdiff
path: root/iup/srclua5/il_mask.c
blob: f4712427874df763299b233f481629ec3d2ab451 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/** \file
 * \brief iupmask binding for Lua 5.
 *
 * See Copyright Notice in "iup.h"
 */

#include <lua.h>
#include <lauxlib.h>

#include "iup.h"
#include "iupmask.h"

#include "iuplua.h"
#include "il.h"
#include "il_controls.h"


static int cfMaskRemove (lua_State *L)
{
  iupmaskRemove(iuplua_checkihandle(L,1));
  return 0;
}

static int cfMaskMatRemove(lua_State *L)
{
  iupmaskMatRemove(iuplua_checkihandle(L,1),
                   luaL_checkint(L,2),
                   luaL_checkint(L,3));
  return 0;
}

static int cfMaskSet (lua_State *L)
{
  iupmaskSet(iuplua_checkihandle(L,1),
             (char*)luaL_checkstring(L,2),
             luaL_checkint(L,3),
             luaL_checkint(L,4));
  return 0;
}

static int cfMaskMatSet(lua_State *L)
{
  iupmaskMatSet(iuplua_checkihandle(L,1),
                (char*)luaL_checkstring(L,2),
                luaL_checkint(L,3),
                luaL_checkint(L,4),
                luaL_checkint(L,5),
                luaL_checkint(L,6));
  return 0;
}

static int cfMaskSetInt(lua_State *L)
{
  iupmaskSetInt(iuplua_checkihandle(L,1),
                luaL_checkint(L,2),
                luaL_checkint(L,3),
                luaL_checkint(L,4));
  return 0;
}

static int cfMaskSetFloat(lua_State *L)
{
  iupmaskSetFloat(iuplua_checkihandle(L,1),
                  luaL_checkint(L,2),
                  (float)luaL_checknumber(L,3),
                  (float)luaL_checknumber(L,4));
  return 0;
}

static int cfMaskMatSetInt (lua_State *L)
{
  iupmaskMatSetInt(iuplua_checkihandle(L,1),
                   luaL_checkint(L,2),
                   luaL_checkint(L,3),
                   luaL_checkint(L,4),
                   luaL_checkint(L,5),
                   luaL_checkint(L,6));
  return 0;
}

static int cfMaskMatSetFloat (lua_State *L)
{
  iupmaskMatSetFloat(iuplua_checkihandle(L,1),
                     luaL_checkint(L,2),
                     (float)luaL_checknumber(L,3),
                     (float)luaL_checknumber(L,4),
                     luaL_checkint(L,5),
                     luaL_checkint(L,6));
  return 0;
}

static int cfMaskCheck (lua_State *L)
{
  iupmaskCheck(iuplua_checkihandle(L,1));
  return 0;
}

static int cfMaskMatCheck (lua_State *L)
{
  iupmaskMatCheck(iuplua_checkihandle(L,1),
                  luaL_checkint(L,2),
                  luaL_checkint(L,3));
  return 0;
}

static int match_cb (Ihandle *handle)
{
  lua_State *L = iuplua_call_start(handle, "match_cb");
  return iuplua_call(L, 0);
}

void iupmasklua_open(lua_State *L)
{
  iuplua_regstring(L, IUP_MASK_FLOAT, "MASK_FLOAT");
  iuplua_regstring(L, IUP_MASK_UFLOAT, "MASK_UFLOAT");
  iuplua_regstring(L, IUP_MASK_EFLOAT, "MASK_EFLOAT");
  iuplua_regstring(L, IUP_MASK_INT, "MASK_INT");
  iuplua_regstring(L, IUP_MASK_UINT, "MASK_UINT");

  iuplua_register(L, cfMaskRemove, "maskRemove");
  iuplua_register(L, cfMaskMatRemove, "maskMatRemove");
  iuplua_register(L, cfMaskSet, "maskSet");
  iuplua_register(L, cfMaskMatSet, "maskMatSet");
  iuplua_register(L, cfMaskSetInt, "maskSetInt");
  iuplua_register(L, cfMaskSetFloat, "maskSetFloat");
  iuplua_register(L, cfMaskMatSetInt, "maskMatSetInt");
  iuplua_register(L, cfMaskMatSetFloat, "maskMatSetFloat");
  iuplua_register(L, cfMaskCheck, "maskCheck");
  iuplua_register(L, cfMaskMatCheck, "maskMatCheck");

  iuplua_register_cb(L, "MATCH_CB", (lua_CFunction)match_cb, NULL);
}