The bottom layer of lua is written in C language. In the bottom layer of lua, when adding data to the list, which functions will be called, and these functions are required to be the highest level

  1. luaH_newkey: Adds a new key-value pair to the list, or overwrites the old value if the key already exists.
  2. luaH_set: Adds a new key-value pair to the list, or overwrites the old value if the key already exists. Unlike luaH_newkey, this function can get the key and value at the specified stack location.
  3. luaH_setint: Adds a new key-value pair to the list, where the key is an integer. Similar to luaH_set, this function can get a value at a specified stack location. It should be noted that the above functions are all top-level API functions, that is, they are Lua library functions written in C language, not functions of Lua language itself. The specific implementation of these functions is in Lua's C library, and you can understand its internal implementation by viewing the source code.

Guess you like

Origin blog.csdn.net/ihateright/article/details/131133476
Recommended