Minetest  5.4.0
c_internal.h File Reference
#include <lua.h>
#include <lauxlib.h>
#include "config.h"
#include "common/c_types.h"
+ Include dependency graph for c_internal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CUSTOM_RIDX_BASE   1
 
#define CUSTOM_RIDX_SCRIPTAPI   (CUSTOM_RIDX_BASE)
 
#define CUSTOM_RIDX_GLOBALS_BACKUP   (CUSTOM_RIDX_BASE + 1)
 
#define CUSTOM_RIDX_CURRENT_MOD_NAME   (CUSTOM_RIDX_BASE + 2)
 
#define CUSTOM_RIDX_BACKTRACE   (CUSTOM_RIDX_BASE + 3)
 
#define INDIRECT_SCRIPTAPI_RIDX   0
 
#define PUSH_ERROR_HANDLER(L)    (lua_rawgeti((L), LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE), lua_gettop((L)))
 
#define PCALL_RESL(L, RES)
 
#define script_run_callbacks(L, nargs, mode)    script_run_callbacks_f((L), (nargs), (mode), __FUNCTION__)
 

Enumerations

enum  RunCallbacksMode {
  RUN_CALLBACKS_MODE_FIRST , RUN_CALLBACKS_MODE_LAST , RUN_CALLBACKS_MODE_AND , RUN_CALLBACKS_MODE_AND_SC ,
  RUN_CALLBACKS_MODE_OR , RUN_CALLBACKS_MODE_OR_SC
}
 
enum class  DeprecatedHandlingMode { Ignore , Log , Error }
 

Functions

std::string script_get_backtrace (lua_State *L)
 
int script_exception_wrapper (lua_State *L, lua_CFunction f)
 
void script_error (lua_State *L, int pcall_result, const char *mod, const char *fxn)
 
void script_run_callbacks_f (lua_State *L, int nargs, RunCallbacksMode mode, const char *fxn)
 
DeprecatedHandlingMode get_deprecated_handling_mode ()
 Reads deprecated_lua_api_handling in settings, returns cached value. More...
 
void log_deprecated (lua_State *L, const std::string &message, int stack_depth=1)
 Handles a deprecation warning based on user settings. More...
 

Macro Definition Documentation

◆ CUSTOM_RIDX_BACKTRACE

#define CUSTOM_RIDX_BACKTRACE   (CUSTOM_RIDX_BASE + 3)

◆ CUSTOM_RIDX_BASE

#define CUSTOM_RIDX_BASE   1

◆ CUSTOM_RIDX_CURRENT_MOD_NAME

#define CUSTOM_RIDX_CURRENT_MOD_NAME   (CUSTOM_RIDX_BASE + 2)

◆ CUSTOM_RIDX_GLOBALS_BACKUP

#define CUSTOM_RIDX_GLOBALS_BACKUP   (CUSTOM_RIDX_BASE + 1)

◆ CUSTOM_RIDX_SCRIPTAPI

#define CUSTOM_RIDX_SCRIPTAPI   (CUSTOM_RIDX_BASE)

◆ INDIRECT_SCRIPTAPI_RIDX

#define INDIRECT_SCRIPTAPI_RIDX   0

◆ PCALL_RESL

#define PCALL_RESL (   L,
  RES 
)
Value:
{ \
int result_ = (RES); \
if (result_ != 0) { \
script_error((L), result_, NULL, __FUNCTION__); \
} \
}

◆ PUSH_ERROR_HANDLER

#define PUSH_ERROR_HANDLER (   L)     (lua_rawgeti((L), LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE), lua_gettop((L)))

◆ script_run_callbacks

#define script_run_callbacks (   L,
  nargs,
  mode 
)     script_run_callbacks_f((L), (nargs), (mode), __FUNCTION__)

Enumeration Type Documentation

◆ DeprecatedHandlingMode

Enumerator
Ignore 
Log 
Error 

◆ RunCallbacksMode

Enumerator
RUN_CALLBACKS_MODE_FIRST 
RUN_CALLBACKS_MODE_LAST 
RUN_CALLBACKS_MODE_AND 
RUN_CALLBACKS_MODE_AND_SC 
RUN_CALLBACKS_MODE_OR 
RUN_CALLBACKS_MODE_OR_SC 

Function Documentation

◆ get_deprecated_handling_mode()

DeprecatedHandlingMode get_deprecated_handling_mode ( )

Reads deprecated_lua_api_handling in settings, returns cached value.

Returns
DeprecatedHandlingMode

References Error, g_settings, Settings::get(), Ignore, and Log.

Referenced by ModApiBase::l_deprecated_function(), and log_deprecated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_deprecated()

void log_deprecated ( lua_State *  L,
const std::string &  message,
int  stack_depth = 1 
)

Handles a deprecation warning based on user settings.

Parameters
LLua State
messageThe deprecation method
stack_depthHow far on the stack to the first user function (ie: not builtin or core)

References Error, get_deprecated_handling_mode(), Ignore, script_log(), and warningstream.

Referenced by ModApiParticles::l_add_particle(), ModApiParticles::l_add_particlespawner(), ObjectRef::l_get_attribute(), ModApiEnvMod::l_get_connected_players(), ObjectRef::l_get_entity_name(), ObjectRef::l_get_look_pitch(), ObjectRef::l_get_look_yaw(), ModApiMapgen::l_get_mapgen_params(), ModApiUtil::l_log(), ModApiMapgen::l_register_ore(), ObjectRef::l_set_attribute(), ObjectRef::l_set_look_pitch(), ObjectRef::l_set_look_yaw(), ModApiMapgen::l_set_mapgen_params(), ObjectRef::l_set_physics_override(), ObjectRef::l_set_sky(), and read_hud_element().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ script_error()

void script_error ( lua_State *  L,
int  pcall_result,
const char *  mod,
const char *  fxn 
)

References itos(), and porting::mt_snprintf().

Referenced by ModApiBase::l_deprecated_function(), script_log(), script_run_callbacks_f(), and ScriptApiBase::scriptError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ script_exception_wrapper()

int script_exception_wrapper ( lua_State *  L,
lua_CFunction  f 
)

Referenced by ScriptApiBase::ScriptApiBase().

+ Here is the caller graph for this function:

◆ script_get_backtrace()

std::string script_get_backtrace ( lua_State *  L)

◆ script_run_callbacks_f()

void script_run_callbacks_f ( lua_State *  L,
int  nargs,
RunCallbacksMode  mode,
const char *  fxn 
)

References FATAL_ERROR_IF, PUSH_ERROR_HANDLER, and script_error().

+ Here is the call graph for this function: