Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2013-2015 Jérémy Rosen.
4 Copyright (C) 2013 Ulrich Pegelow.
5 Copyright (C) 2014-2016 Tobias Ellinghaus.
6 Copyright (C) 2016 Roman Lebedev.
7 Copyright (C) 2017, 2019, 2021 luzpaz.
8 Copyright (C) 2020-2021 Pascal Obry.
9 Copyright (C) 2022 Martin Bařinka.
10
11 darktable is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 darktable is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with darktable. If not, see <http://www.gnu.org/licenses/>.
23*/
24#pragma once
25
26#include <gtk/gtk.h>
27#include <lautoc.h>
28#include <lauxlib.h>
29#include <lua.h>
30#include <lualib.h>
31
35typedef char *char_20;
36typedef char *char_32;
37typedef char *char_52;
38typedef char *char_64;
39typedef char *char_128;
40typedef char *char_256;
41typedef char *char_512;
42typedef char *char_1024;
44typedef char *char_path_length;
45typedef const char *const_string; // string that has no push function
46typedef double protected_double; // like double, but NAN is mapped to nil
47typedef double progress_double; // a double in [0.0,1.0] any value out of bound will be silently converted to
48 // the bound both at push and pull time
49
50// Types added to the lua type system and usable externally
51typedef GtkOrientation dt_lua_orientation_t;
52typedef GtkAlign dt_lua_align_t;
53typedef PangoEllipsizeMode dt_lua_ellipsize_mode_t;
54
55
56
76#define dt_lua_init_type(L, type_name) dt_lua_init_type_type(L, luaA_type(L, type_name))
78
79
80
81/*********************************/
82/* MEMBER REGISTRATION FUNCTIONS */
83/*********************************/
85#define dt_lua_type_register_const(L, type_name, name) \
86 dt_lua_type_register_const_type(L, luaA_type_find(L, #type_name), name)
87void dt_lua_type_register_const_type(lua_State *L, luaA_Type type_id, const char *name);
88
90#define dt_lua_type_register(L, type_name, name) \
91 dt_lua_type_register_type(L, luaA_type_find(L, #type_name), name)
92void dt_lua_type_register_type(lua_State *L, luaA_Type type_id, const char *name);
93
96#define dt_lua_type_register_struct(L, type_name) \
97 dt_lua_type_register_struct_type(L, luaA_type_find(L, #type_name))
99
100// register a function for number index
101// first push the len function (can be nil)
102// then push the member function
103#define dt_lua_type_register_number(L, type_name) \
104 dt_lua_type_register_number_type(L, luaA_type_find(L, #type_name))
106#define dt_lua_type_register_number_const(L, type_name) \
107 dt_lua_type_register_number_const_type(L, luaA_type_find(L, #type_name))
109
114#define dt_lua_type_register_parent(L, type_name, parent_type_name) \
115 dt_lua_type_register_parent_type(L, luaA_type_find(L, #type_name), luaA_type_find(L, #parent_type_name))
116void dt_lua_type_register_parent_type(lua_State *L, luaA_Type type_id, luaA_Type parent_type_id);
117
118/********************/
119/* MEMBER FUNCTIONS */
120/********************/
125
126/***********/
127/* HELPERS */
128/***********/
129
137#define dt_lua_init_int_type(L, type_name) dt_lua_init_int_type_type(L, luaA_type(L, type_name))
139#define dt_lua_init_gpointer_type(L, type_name) dt_lua_init_gpointer_type_type(L, luaA_type(L, type_name))
141
146#define dt_lua_type_gpointer_alias(L,type_name,pointer,alias) \
147 dt_lua_type_gpointer_alias_type(L,luaA_type(L,type_name),pointer,alias)
148void dt_lua_type_gpointer_alias_type(lua_State*L,luaA_Type type_id,void* pointer,void* alias);
149
150
158void dt_lua_type_gpointer_drop(lua_State*L, void* pointer);
159
166luaA_Type dt_lua_init_singleton(lua_State *L, const char *unique_name, void *data);
167
173 const char *unique_name, void *data);
174
175
176
177#define dt_lua_isa(L, index, type) dt_lua_isa_type(L, index, luaA_type(L, type))
178
179gboolean dt_lua_isa_type(lua_State *L, int index, luaA_Type type_id);
180gboolean dt_lua_typeisa_type(lua_State *L, luaA_Type obj_type, luaA_Type type_id);
181
182#define dt_lua_type_setmetafield(L,type_name,name) dt_lua_type_setmetafield_type(L,luaA_type(L,type_name),name)
183void dt_lua_type_setmetafield_type(lua_State*L,luaA_Type type,const char* method_name);
184
186
187// clang-format off
188// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
189// vim: shiftwidth=2 expandtab tabstop=2 cindent
190// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
191// clang-format on
192
const float L
Definition colorspaces_inline_conversions.h:724
int type
Definition common/metadata.c:62
char * name
Definition common/metadata.c:61
int luaA_Type
Definition lua.h:97
int(* lua_CFunction)(lua_State *L)
Definition lua.h:96
int lua_State
Definition lua.h:95
char * char_256
Definition types.h:40
char * char_128
Definition types.h:39
void dt_lua_type_register_type(lua_State *L, luaA_Type type_id, const char *name)
Definition types.c:468
GtkOrientation dt_lua_orientation_t
Definition types.h:51
GtkAlign dt_lua_align_t
Definition types.h:52
void dt_lua_type_gpointer_drop(lua_State *L, void *pointer)
Definition types.c:849
void dt_lua_type_register_parent_type(lua_State *L, luaA_Type type_id, luaA_Type parent_type_id)
Definition types.c:579
void dt_lua_type_setmetafield_type(lua_State *L, luaA_Type type, const char *method_name)
Definition types.c:895
char * char_32
Definition types.h:36
PangoEllipsizeMode dt_lua_ellipsize_mode_t
Definition types.h:53
int dt_lua_type_member_luaautoc(lua_State *L)
member function for luaautoc struct, will use luaautoc to push/pull content
Definition types.c:526
void dt_lua_type_register_struct_type(lua_State *L, luaA_Type type_id)
Definition types.c:545
char * char_512
Definition types.h:41
luaA_Type dt_lua_init_gpointer_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:802
char * char_64
Definition types.h:38
void dt_lua_type_gpointer_alias_type(lua_State *L, luaA_Type type_id, void *pointer, void *alias)
Definition types.c:832
void dt_lua_type_register_number_const_type(lua_State *L, luaA_Type type_id)
Definition types.c:492
luaA_Type dt_lua_init_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:673
void dt_lua_type_register_const_type(lua_State *L, luaA_Type type_id, const char *name)
Definition types.c:482
char * char_path_length
Definition types.h:44
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:753
char * char_filename_length
Definition types.h:43
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:567
double protected_double
Definition types.h:46
char * char_1024
Definition types.h:42
const char * const_string
Definition types.h:45
int dt_lua_init_early_types(lua_State *L)
Definition types.c:947
gboolean dt_lua_isa_type(lua_State *L, int index, luaA_Type type_id)
Definition types.c:871
double progress_double
Definition types.h:47
char * char_52
Definition types.h:37
luaA_Type dt_lua_init_singleton(lua_State *L, const char *unique_name, void *data)
Definition types.c:681
char * char_20
Definition types.h:35
luaA_Type dt_lua_init_int_type_type(lua_State *L, luaA_Type type_id)
Definition types.c:774
void dt_lua_type_register_number_type(lua_State *L, luaA_Type type_id)
Definition types.c:507
gboolean dt_lua_typeisa_type(lua_State *L, luaA_Type obj_type, luaA_Type type_id)
Definition types.c:879