summaryrefslogtreecommitdiff
path: root/im/src/lua5/imlua_aux.h
blob: 2dc44663a58d93abefba4214c466044d01d079df (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
/** \file
 * \brief IM Lua 5 Binding
 *
 * See Copyright Notice in im_lib.h
 * $Id: imlua_aux.h,v 1.1 2008/10/17 06:16:32 scuri Exp $
 */

#ifndef __IMLUA_AUX_H
#define __IMLUA_AUX_H

#if	defined(__cplusplus)
extern "C" {
#endif


/********************************/
/* exported from "imlua_aux.c". */
/********************************/

/* get table size */

int imlua_getn(lua_State *L, int index);

/* array */

int imlua_newarrayint(lua_State *L, int *value, int count, int start);
int imlua_newarrayulong(lua_State *L, unsigned long *value, int count, int start);
int imlua_newarrayfloat(lua_State *L, float *value, int count, int start);

int *imlua_toarrayint(lua_State *L, int index, int *count, int start);
unsigned long *imlua_toarrayulong (lua_State *L, int index, int *count, int start);
float *imlua_toarrayfloat(lua_State *L, int index, int *count, int start);

/* other parameter checking */

unsigned char imlua_checkmask(lua_State *L, int index);

void imlua_checktype(lua_State *L, int index, imImage *image, int color_space, int data_type);
void imlua_checkdatatype(lua_State *L, int index, imImage *image, int data_type);
void imlua_checkcolorspace(lua_State *L, int index, imImage *image, int color_space);

void imlua_matchsize(lua_State *L, imImage *image1, imImage *image2);
void imlua_matchcolor(lua_State *L, imImage *image1, imImage *image2);
void imlua_matchdatatype(lua_State *L, imImage *image1, imImage *image2);
void imlua_matchcolorspace(lua_State *L, imImage *image1, imImage *image2);
void imlua_match(lua_State *L, imImage *image1, imImage *image2);

/* used only when comparing two images */
#define imlua_matchcheck(L, cond, extramsg) if (!(cond)) \
                                               luaL_error(L, extramsg)

#define imlua_pusherror(L, _e) ((_e == IM_ERR_NONE)? lua_pushnil(L): lua_pushnumber(L, _e))


/********************************/
/* exported from "imlua.c".     */
/********************************/

/* constant registration. */

typedef struct _imlua_constant {
  const char *name;
  lua_Number value;
  const char *str_value;
} imlua_constant;

void imlua_regconstants(lua_State *L, const imlua_constant *imconst);


/********************************/
/* private module open          */
/********************************/

void imlua_open_convert(lua_State *L);  /* imlua_convert.c */
void imlua_open_util(lua_State *L);     /* imlua_util.c    */
void imlua_open_file(lua_State *L);     /* imlua_file.c    */

#ifdef __cplusplus
}
#endif

#endif