Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
2/*
3 This file is part of darktable,
4 Copyright (C) 2013-2021 darktable developers.
5
6 darktable is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 darktable is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with darktable. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <gtk/gtk.h>
23#include <lautoc.h>
24#include <lauxlib.h>
25#include <lua.h>
26#include <lualib.h>
27
31typedef char *char_20;
32typedef char *char_32;
33typedef char *char_52;
34typedef char *char_64;
35typedef char *char_128;
36typedef char *char_256;
37typedef char *char_512;
38typedef char *char_1024;
40typedef char *char_path_length;
41typedef const char *const_string; // string that has no push function
42typedef double protected_double; // like double, but NAN is mapped to nil
43typedef double progress_double; // a double in [0.0,1.0] any value out of bound will be silently converted to
44 // the bound both at push and pull time
45
46// Types added to the lua type system and usable externally
47typedef GtkOrientation dt_lua_orientation_t;
48typedef GtkAlign dt_lua_align_t;
49typedef PangoEllipsizeMode dt_lua_ellipsize_mode_t;
50
51
52
72#define dt_lua_init_type(L, type_name) dt_lua_init_type_type(L, luaA_type(L, type_name))
74
75
76
77/*********************************/
78/* MEMBER REGISTRATION FUNCTIONS */
79/*********************************/
81#define dt_lua_type_register_const(L, type_name, name) \
82 dt_lua_type_register_const_type(L, luaA_type_find(L, #type_name), name)
83void dt_lua_type_register_const_type(lua_State *L, luaA_Type type_id, const char *name);
84
86#define dt_lua_type_register(L, type_name, name) \
87 dt_lua_type_register_type(L, luaA_type_find(L, #type_name), name)
88void dt_lua_type_register_type(lua_State *L, luaA_Type type_id, const char *name);
89
92#define dt_lua_type_register_struct(L, type_name) \
93 dt_lua_type_register_struct_type(L, luaA_type_find(L, #type_name))
95
96// register a function for number index
97// first push the len function (can be nil)
98// then push the member function
99#define dt_lua_type_register_number(L, type_name) \
100 dt_lua_type_register_number_type(L, luaA_type_find(L, #type_name))
102#define dt_lua_type_register_number_const(L, type_name) \
103 dt_lua_type_register_number_const_type(L, luaA_type_find(L, #type_name))
105
110#define dt_lua_type_register_parent(L, type_name, parent_type_name) \
111 dt_lua_type_register_parent_type(L, luaA_type_find(L, #type_name), luaA_type_find(L, #parent_type_name))
112void dt_lua_type_register_parent_type(lua_State *L, luaA_Type type_id, luaA_Type parent_type_id);
113
114/********************/
115/* MEMBER FUNCTIONS */
116/********************/
121
122/***********/
123/* HELPERS */
124/***********/
125
133#define dt_lua_init_int_type(L, type_name) dt_lua_init_int_type_type(L, luaA_type(L, type_name))
135#define dt_lua_init_gpointer_type(L, type_name) dt_lua_init_gpointer_type_type(L, luaA_type(L, type_name))
137
142#define dt_lua_type_gpointer_alias(L,type_name,pointer,alias) \
143 dt_lua_type_gpointer_alias_type(L,luaA_type(L,type_name),pointer,alias)
144void dt_lua_type_gpointer_alias_type(lua_State*L,luaA_Type type_id,void* pointer,void* alias);
145
146
154void dt_lua_type_gpointer_drop(lua_State*L, void* pointer);
155
162luaA_Type dt_lua_init_singleton(lua_State *L, const char *unique_name, void *data);
163
169 const char *unique_name, void *data);
170
171
172
173#define dt_lua_isa(L, index, type) dt_lua_isa_type(L, index, luaA_type(L, type))
174
175gboolean dt_lua_isa_type(lua_State *L, int index, luaA_Type type_id);
176gboolean dt_lua_typeisa_type(lua_State *L, luaA_Type obj_type, luaA_Type type_id);
177
178#define dt_lua_type_setmetafield(L,type_name,name) dt_lua_type_setmetafield_type(L,luaA_type(L,type_name),name)
179void dt_lua_type_setmetafield_type(lua_State*L,luaA_Type type,const char* method_name);
180
182
183// clang-format off
184// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
185// vim: shiftwidth=2 expandtab tabstop=2 cindent
186// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
187// clang-format on
188
int type
Definition common/metadata.c:42
char * name
Definition common/metadata.c:41
int luaA_Type
Definition lua.h:92
int(* lua_CFunction)(lua_State *L)
Definition lua.h:91
int lua_State
Definition lua.h:90
char * char_256
Definition types.h:36
char * char_128
Definition types.h:35
void dt_lua_type_register_type(lua_State *L, luaA_Type type_id, const char *name)
Definition types.c:461
GtkOrientation dt_lua_orientation_t
Definition types.h:47
GtkAlign dt_lua_align_t
Definition types.h:48
void dt_lua_type_gpointer_drop(lua_State *L, void *pointer)
Definition types.c:842
void dt_lua_type_register_parent_type(lua_State *L, luaA_Type type_id, luaA_Type parent_type_id)
Definition types.c:572
void dt_lua_type_setmetafield_type(lua_State *L, luaA_Type type, const char *method_name)
Definition types.c:888
char * char_32
Definition types.h:32
PangoEllipsizeMode dt_lua_ellipsize_mode_t
Definition types.h:49
int dt_lua_type_member_luaautoc(lua_State *L)
member function for luaautoc struct, will use luaautoc to push/pull content
Definition types.c:519
void dt_lua_type_register_struct_type(lua_State *L, luaA_Type type_id)
Definition types.c:538
char * char_512
Definition types.h:37
luaA_Type dt_lua_init_gpointer_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:795
char * char_64
Definition types.h:34
void dt_lua_type_gpointer_alias_type(lua_State *L, luaA_Type type_id, void *pointer, void *alias)
Definition types.c:825
void dt_lua_type_register_number_const_type(lua_State *L, luaA_Type type_id)
Definition types.c:485
luaA_Type dt_lua_init_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:666
void dt_lua_type_register_const_type(lua_State *L, luaA_Type type_id, const char *name)
Definition types.c:475
char * char_path_length
Definition types.h:40
luaA_Type dt_lua_init_wrapped_singleton(lua_State *L, lua_CFunction pusher, lua_CFunction getter, const char *unique_name, void *data)
Definition types.c:746
char * char_filename_length
Definition types.h:39
int dt_lua_type_member_common(lua_State *L)
member function for common members. The common member must be the only upvalue of the function
Definition types.c:560
double protected_double
Definition types.h:42
char * char_1024
Definition types.h:38
const char * const_string
Definition types.h:41
int dt_lua_init_early_types(lua_State *L)
Definition types.c:940
gboolean dt_lua_isa_type(lua_State *L, int index, luaA_Type type_id)
Definition types.c:864
double progress_double
Definition types.h:43
char * char_52
Definition types.h:33
luaA_Type dt_lua_init_singleton(lua_State *L, const char *unique_name, void *data)
Definition types.c:674
char * char_20
Definition types.h:31
luaA_Type dt_lua_init_int_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:767
void dt_lua_type_register_number_type(lua_State *L, luaA_Type type_id)
Definition types.c:500
gboolean dt_lua_typeisa_type(lua_State *L, luaA_Type obj_type, luaA_Type type_id)
Definition types.c:872