"Fossies" - the Fresh Open Source Software Archive

Member "darktable-2.6.3/src/lua/lua.h" (20 Oct 2019, 3985 Bytes) of package /linux/misc/darktable-2.6.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "lua.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2    This file is part of darktable,
    3    copyright (c) 2012 Jeremy Rosen
    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 /* this file can safely be included when lua is disabled */
   22 
   23 
   24 /* these include are out of the ifdef to avoid compile errors when compiling with/without lua
   25    users that accidentally use it won't be affected by the ifdef USE_LUA
   26  */
   27 #include "common/dtpthread.h"
   28 #include <glib.h>
   29 
   30 #ifdef USE_LUA
   31 #include <lautoc.h>
   32 #include <lauxlib.h>
   33 #include <lua.h>
   34 #include <lualib.h>
   35 
   36 /**
   37   (0,+1)
   38   find or create the global darktable module table and push it on the stack
   39   */
   40 int dt_lua_push_darktable_lib(lua_State *L);
   41 
   42 /**
   43   (-1,+1)
   44   check that the top of the stack is a table, creates or find a subtable named "name",
   45   adds it on top of the stack, and remove the previous table
   46 
   47   used to easily do a tree organisation of objects
   48 */
   49 void dt_lua_goto_subtable(lua_State *L, const char *sub_name);
   50 
   51 
   52 void dt_lua_init_lock();
   53 void dt_lua_lock_internal(const char *function, const char *file, int line, gboolean silent);
   54 void dt_lua_unlock_internal(const char *function, int line);
   55 
   56 #define dt_lua_debug_stack(L) dt_lua_debug_stack_internal(L, __FUNCTION__, __LINE__)
   57 void dt_lua_debug_stack_internal(lua_State *L, const char *function, int line);
   58 #define dt_lua_debug_table(L, index) dt_lua_debug_table_internal(L, index, __FUNCTION__, __LINE__)
   59 void dt_lua_debug_table_internal(lua_State *L, int t, const char *function, int line);
   60 
   61 
   62 #define dt_lua_lock() dt_lua_lock_internal(__FUNCTION__, __FILE__, __LINE__, FALSE)
   63 #define dt_lua_lock_silent() dt_lua_lock_internal(__FUNCTION__, __FILE__, __LINE__, TRUE)
   64 #define dt_lua_unlock() dt_lua_unlock_internal( __FUNCTION__, __LINE__) 
   65 
   66 typedef struct
   67 {
   68   lua_State *state;                  // main lua context
   69 
   70   dt_pthread_mutex_t mutex;          // mutex protecting the lua condition variable
   71   pthread_cond_t cond;               // condition variable to wait for the lua lock
   72   bool exec_lock;                    // true if some lua code is running. this is logically a mutex
   73 
   74   bool ending;                       // true if we are in the process of terminating DT
   75 
   76   GMainLoop *loop;                   // loop running the lua context
   77   GMainContext *context;             // the lua context responsible for dispatching tasks
   78   GThreadPool *pool;                 // pool of threads to run lua tasks on (should be one or two at most, unless lot of blocking lua threads
   79   GAsyncQueue * stacked_job_queue;   // queue of jobs whose arguments are on a lua stack
   80   GAsyncQueue * alien_job_queue;     // queue of jobs coming from C, args are passed in a glist
   81   GAsyncQueue * string_job_queue;    // queue of jobs as lua expressions, passed with args as a string
   82 
   83 } dt_lua_state_t;
   84 
   85 
   86 void dt_lua_redraw_screen();
   87 
   88 #else
   89 /* defines to easily have a few lua types when lua is not available */
   90 typedef int lua_State;
   91 typedef int (*lua_CFunction)(lua_State *L);
   92 typedef int luaA_Type;
   93 #define LUAA_INVALID_TYPE -1
   94 typedef struct
   95 {
   96   int unused; // if this is empty clang++ complains that the struct has size 0 in C and size 1 in C++
   97 } dt_lua_state_t;
   98 #endif
   99 
  100 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
  101 // vim: shiftwidth=2 expandtab tabstop=2 cindent
  102 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;