Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
c_internal.h File Reference
#include <string_view>
#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 INDIRECT_SCRIPTAPI_RIDX   0
 
#define PUSH_ERROR_HANDLER(L)    (lua_rawgeti((L), LUA_REGISTRYINDEX, CUSTOM_RIDX_ERROR_HANDLER), lua_gettop((L)))
 
#define PCALL_RESL(L, RES)
 

Enumerations

enum  {
  CUSTOM_RIDX_BEFORE_ = 0 , CUSTOM_RIDX_SCRIPTAPI , CUSTOM_RIDX_GLOBALS_BACKUP , CUSTOM_RIDX_CURRENT_MOD_NAME ,
  CUSTOM_RIDX_ERROR_HANDLER , CUSTOM_RIDX_HTTP_API_LUA , CUSTOM_RIDX_METATABLE_MAP , CUSTOM_RIDX_READ_VECTOR ,
  CUSTOM_RIDX_PUSH_VECTOR , CUSTOM_RIDX_READ_NODE , CUSTOM_RIDX_PUSH_NODE , CUSTOM_RIDX_PUSH_MOVERESULT1
}
 
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  DeprecatedHandlingMode { Ignore , Log , Error }
 

Functions

std::string script_get_backtrace (lua_State *L)
 
int script_exception_wrapper (lua_State *L, lua_CFunction f)
 
int script_error_handler (lua_State *L)
 
void script_error (lua_State *L, int pcall_result, const char *mod, const char *fxn)
 
bool script_log_unique (lua_State *L, std::string_view message, std::ostream &log_to, int stack_depth=1)
 
DeprecatedHandlingMode get_deprecated_handling_mode ()
 Reads deprecated_lua_api_handling in settings, returns cached value.
 
void log_deprecated (lua_State *L, std::string_view message, int stack_depth=1, bool once=false)
 Handles a deprecation warning based on user settings.
 
void call_string_dump (lua_State *L, int idx)
 

Macro Definition Documentation

◆ 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__); \
} \
}

Referenced by ModApiEnv::l_add_item().

◆ PUSH_ERROR_HANDLER

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

Referenced by MainMenuScripting::beforeClose(), ScriptApiEnv::check_for_falling(), check_function(), ScriptApiServer::createAuth(), ScriptApiDetached::detached_inventory_AllowMove(), ScriptApiDetached::detached_inventory_AllowPut(), ScriptApiDetached::detached_inventory_AllowTake(), ScriptApiDetached::detached_inventory_OnMove(), ScriptApiDetached::detached_inventory_OnPut(), ScriptApiDetached::detached_inventory_OnTake(), ScriptApiServer::getAuth(), ScriptApiMainMenu::handleMainMenuButtons(), ScriptApiMainMenu::handleMainMenuEvent(), ScriptApiItem::item_CraftPredict(), ScriptApiItem::item_OnCraft(), ScriptApiItem::item_OnDrop(), ScriptApiItem::item_OnPlace(), ScriptApiItem::item_OnSecondaryUse(), ScriptApiItem::item_OnUse(), ModApiEnv::l_add_item(), ScriptApiBase::loadScript(), ScriptApiEntity::luaentity_Activate(), ScriptApiEntity::luaentity_Deactivate(), ScriptApiEntity::luaentity_GetStaticdata(), ScriptApiEntity::luaentity_Punch(), ScriptApiEntity::luaentity_run_simple_callback(), ScriptApiEntity::luaentity_Step(), ScriptApiNode::node_after_destruct(), ScriptApiNode::node_on_construct(), ScriptApiNode::node_on_destruct(), ScriptApiNode::node_on_dig(), ScriptApiNode::node_on_flood(), ScriptApiNode::node_on_punch(), ScriptApiNode::node_on_receive_fields(), ScriptApiNode::node_on_timer(), ScriptApiNodemeta::nodemeta_inventory_AllowMove(), ScriptApiNodemeta::nodemeta_inventory_AllowPut(), ScriptApiNodemeta::nodemeta_inventory_AllowTake(), ScriptApiNodemeta::nodemeta_inventory_OnMove(), ScriptApiNodemeta::nodemeta_inventory_OnPut(), ScriptApiNodemeta::nodemeta_inventory_OnTake(), ScriptApiServer::on_dynamic_media_added(), ScriptApiEnv::on_emerge_area_completion(), ScriptApiPlayer::on_player_hpchange(), AsyncWorkerThread::run(), ScriptApiBase::runCallbacksRaw(), ScriptApiServer::setPassword(), AsyncEngine::stepJobResults(), ScriptApiEnv::triggerABM(), and ScriptApiEnv::triggerLBM().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CUSTOM_RIDX_BEFORE_ 
CUSTOM_RIDX_SCRIPTAPI 
CUSTOM_RIDX_GLOBALS_BACKUP 
CUSTOM_RIDX_CURRENT_MOD_NAME 
CUSTOM_RIDX_ERROR_HANDLER 
CUSTOM_RIDX_HTTP_API_LUA 
CUSTOM_RIDX_METATABLE_MAP 
CUSTOM_RIDX_READ_VECTOR 
CUSTOM_RIDX_PUSH_VECTOR 
CUSTOM_RIDX_READ_NODE 
CUSTOM_RIDX_PUSH_NODE 
CUSTOM_RIDX_PUSH_MOVERESULT1 

◆ 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

◆ call_string_dump()

void call_string_dump ( lua_State * L,
int idx )

References CUSTOM_RIDX_GLOBALS_BACKUP, and idx.

Referenced by ModApiServer::l_do_async_callback(), and pack_inner().

+ Here is the caller graph for this function:

◆ 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 ModSpec::checkAndLog(), SubgameSpec::checkAndLog(), 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,
std::string_view message,
int stack_depth = 1,
bool once = false )

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). -1 to disabled.
onceLog the deprecation warning only once per callsite.

References Error, get_deprecated_handling_mode(), Ignore, infostream, script_get_backtrace(), script_log_add_source(), script_log_unique(), and warningstream.

Referenced by ScriptApiSecurity::checkPath(), get_compress_method(), ModApiParticles::l_add_particle(), ModApiParticles::l_add_particlespawner(), LuaVoxelManip::l_calc_lighting(), ObjectRef::l_get_attribute(), ObjectRef::l_get_bone_position(), ModApiEnv::l_get_connected_players(), ObjectRef::l_get_entity_name(), ObjectRef::l_get_look_pitch(), ObjectRef::l_get_look_yaw(), ModApiMapgen::l_get_mapgen_params(), LuaItemStack::l_get_metadata(), ObjectRef::l_get_sky(), ObjectRef::l_get_sky_color(), ModApiUtil::l_log(), ModApiMapgen::l_register_ore(), ObjectRef::l_set_attribute(), ObjectRef::l_set_bone_position(), LuaVoxelManip::l_set_lighting(), ObjectRef::l_set_look_pitch(), ObjectRef::l_set_look_yaw(), ModApiMapgen::l_set_mapgen_params(), LuaItemStack::l_set_metadata(), ObjectRef::l_set_sky(), MetaDataRef::l_set_string(), LuaVoxelManip::l_was_modified(), ScriptApiEntity::logDeprecationForExistingProperties(), 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 ScriptApiBase::scriptError(), and AsyncEngine::stepJobResults().

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

◆ script_error_handler()

int script_error_handler ( lua_State * L)

Referenced by ScriptApiBase::ScriptApiBase().

+ Here is the caller graph for this function:

◆ script_exception_wrapper()

int script_exception_wrapper ( lua_State * L,
lua_CFunction f )

References debug_describe_exc().

Referenced by ScriptApiBase::ScriptApiBase().

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

◆ script_get_backtrace()

std::string script_get_backtrace ( lua_State * L)

Referenced by check_field_or_nil(), checkSettingSecurity(), ModApiServer::l_chat_send_all(), ModApiServer::l_chat_send_player(), ObjectRef::l_set_armor_groups(), log_deprecated(), read_tool_capabilities(), ScriptApiBase::realityCheck(), and warn_if_field_exists().

+ Here is the caller graph for this function:

◆ script_log_unique()

bool script_log_unique ( lua_State * L,
std::string_view message,
std::ostream & log_to,
int stack_depth = 1 )

References hash(), murmur_hash_64_ua(), and script_log_add_source().

Referenced by log_deprecated(), and read_hud_change().

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