Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
call.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2013-2016 Jérémy Rosen.
4 Copyright (C) 2014, 2016 Tobias Ellinghaus.
5 Copyright (C) 2016 Roman Lebedev.
6 Copyright (C) 2017 luzpaz.
7 Copyright (C) 2020 Pascal Obry.
8 Copyright (C) 2022 Martin Bařinka.
9
10 darktable is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 darktable is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with darktable. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26#include "lua/lua.h"
27
28/*
29 pop a function from the top of the stack, push a new version on the stack
30 that will be called from the GTK main thread
31 */
32#define dt_lua_gtk_wrap(L) dt_lua_gtk_wrap_internal(L,__FUNCTION__,__LINE__)
33void dt_lua_gtk_wrap_internal(lua_State*L,const char* function, int line);
34
35/*
36 similar to pcall, but in case of error, it will call dt_lua_check_print_error with a proper stack
37 */
38int dt_lua_treated_pcall(lua_State*L, int nargs, int nresults);
39/*
40 deal with lua_pcall calling convention
41 * print the string on the top of L if result != LUA_OK
42 * pop the error string
43 * return result
44 */
45int dt_lua_check_print_error(lua_State* L, int result);
46
47
48/*
49 call a function asynchronously
50 a callback+data can be provided, the callback will be called when the job is finished
51 if no callback is provided, a message will be printed in case of error
52 */
53
54typedef void (*dt_lua_finish_callback)(lua_State* L,int result,void* data);
55
56void dt_lua_async_call_internal(const char * function, int line,lua_State *L, int nargs,int nresults,dt_lua_finish_callback cb, void*data);
57#define dt_lua_async_call(L,nargs,nresults,cb,data) dt_lua_async_call_internal(__FUNCTION__,__LINE__,L,nargs,nresults,cb,data)
58
59
60/*
61 Call a lua function asynchronously, parameters are passed through varags,
62 and temporarily stored in a glist before pushing in the stack
63
64 This function CAN be called with the gtk lock held.
65 * function : the function to call
66 * ... triplets of dt_lua_asyc_call_arg_type, type_description, value,
67 * LUA_ASYNC_TYPEID : the type description is a luaA_Typeid
68 * LUA_ASYNC_TYPENAME : the type description is a const char * which is a type name for the lua typing system
69 * ..._WITH_FREE : the value is a pointer that must be freed after being pushed on the stack
70 add a GClosure parameter : the freeing function. will be invoked with the pointer to free plus any extra data given at closure creation
71 */
72
80void dt_lua_async_call_alien_internal(const char * call_function, int line,lua_CFunction function,int nresults,dt_lua_finish_callback cb, void*data, dt_lua_async_call_arg_type arg_type,...);
81#define dt_lua_async_call_alien(fn,nresults,cb,data,arg,...) dt_lua_async_call_alien_internal(__FUNCTION__,__LINE__,fn,nresults,cb,data,arg,__VA_ARGS__)
82
83
84
85void dt_lua_async_call_string_internal(const char* function, int line,const char* lua_string,int nresults,dt_lua_finish_callback cb, void*cb_data);
86#define dt_lua_async_call_string(lua_string,nresults,cb,data) dt_lua_async_call_string_internal(__FUNCTION__,__LINE__,lua_string,nresults,cb,data)
87
88
89
90
92
93// clang-format off
94// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
95// vim: shiftwidth=2 expandtab tabstop=2 cindent
96// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
97// clang-format on
98
int dt_lua_init_call(lua_State *L)
Definition call.c:701
void dt_lua_async_call_internal(const char *function, int line, lua_State *L, int nargs, int nresults, dt_lua_finish_callback cb, void *data)
Definition call.c:480
void dt_lua_async_call_alien_internal(const char *call_function, int line, lua_CFunction function, int nresults, dt_lua_finish_callback cb, void *data, dt_lua_async_call_arg_type arg_type,...)
Definition call.c:496
void(* dt_lua_finish_callback)(lua_State *L, int result, void *data)
Definition call.h:54
int dt_lua_check_print_error(lua_State *L, int result)
Definition call.c:37
dt_lua_async_call_arg_type
Definition call.h:73
@ LUA_ASYNC_TYPEID
Definition call.h:74
@ LUA_ASYNC_TYPENAME_WITH_FREE
Definition call.h:77
@ LUA_ASYNC_TYPEID_WITH_FREE
Definition call.h:75
@ LUA_ASYNC_TYPENAME
Definition call.h:76
@ LUA_ASYNC_DONE
Definition call.h:78
void dt_lua_gtk_wrap_internal(lua_State *L, const char *function, int line)
Definition call.c:695
int dt_lua_treated_pcall(lua_State *L, int nargs, int nresults)
Definition call.c:54
void dt_lua_async_call_string_internal(const char *function, int line, const char *lua_string, int nresults, dt_lua_finish_callback cb, void *cb_data)
Definition call.c:565
const float L
Definition colorspaces_inline_conversions.h:724
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
int(* lua_CFunction)(lua_State *L)
Definition lua.h:96
int lua_State
Definition lua.h:95