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