32 Star 227 Fork 40

GVPI++俱乐部/Dora-SSR

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tolua.mdx 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
Li Jin 提交于 2025-01-06 16:24 +08:00 . Fixed doc site prismjs language adding. [skip CI]
# tolua
**Description:**
  The `tolua` record provides utilities for interfacing between C++ and Lua.
## type
**Type:** Function.
**Description:**
  Returns the C++ object type of a Lua object.
**Signature:**
```tl
type: function(item: any): string
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| item | any | The Lua object to get the type of. |
**Returns:**
| Return Type | Description |
| --- | --- |
| string | The C++ object type. |
## cast
**Type:** Field.
**Description:**
  Attempts to cast a Lua object to a C++ type object.
**Signature:**
```tl
cast: function<T>(item: any, name: string): T | nil
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| item | any | The Lua object to cast. |
| name | string | The name of the C++ type to cast to. |
**Returns:**
| Return Type | Description |
| --- | --- |
| T\|nil | The cast object, or `nil` if the cast fails. |
## class
**Type:** Function.
**Description:**
&emsp;&emsp;Gets the class object for a given class name.
**Signature:**
```tl
class: function(className: string): table | nil
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| className | string | The name of the class to get the table for. |
**Returns:**
| Return Type | Description |
| --- | --- |
| table\|nil | The class table, or `nil` if the class does not exist. |
## setpeer
**Type:** Function.
**Description:**
&emsp;&emsp;Sets the peer table for an object. A pear table is a table referenced by a Lua userdata providing custom fields for this userdata object.
**Signature:**
```tl
setpeer: function(obj: Object, data: table)
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| obj | Object | The object to set the peer table for. |
| data | table | The table to use as the peer table. |
## getpeer
**Type:** Function.
**Description:**
&emsp;&emsp;Gets the peer table for an object. A pear table is a table referenced by a Lua userdata providing custom fields for this userdata object.
**Signature:**
```tl
getpeer: function(obj: Object): table
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| obj | Object | The object to get the peer table for. |
**Returns:**
| Return Type | Description |
| --- | --- |
| table | The peer table, or nil if the object has no peer table. |
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/ippclub/Dora-SSR.git
git@gitee.com:ippclub/Dora-SSR.git
ippclub
Dora-SSR
Dora-SSR
main

搜索帮助