godot的NetSocket是如何创建实例的?
How does godot's NetSocket creates an instance?
我正在阅读 godot 的源代码,我无法理解 NetSocket class 如何创建它的实例。
在 net_socket.cpp 中定义了 create(),但我看不到它是如何工作的。
#include "net_socket.h"
NetSocket *(*NetSocket::_create)() = NULL;
NetSocket *NetSocket::create() {
if (_create)
return _create();
ERR_PRINT("Unable to create network socket, platform not supported");
return NULL;
}
特别是_create
是什么? NetSocket *(*NetSocket::_create)() = NULL;
实际上做了什么?
您查看的文件有误。那一个只是委托给任何平台特定的实现已经链接 in/instantiated,使用 函数指针 称为 _create
.
设置在例如the POSIX impl.
只需在代码库中搜索 _create
的实例,您就会看到它是如何工作的。
我正在阅读 godot 的源代码,我无法理解 NetSocket class 如何创建它的实例。
在 net_socket.cpp 中定义了 create(),但我看不到它是如何工作的。
#include "net_socket.h"
NetSocket *(*NetSocket::_create)() = NULL;
NetSocket *NetSocket::create() {
if (_create)
return _create();
ERR_PRINT("Unable to create network socket, platform not supported");
return NULL;
}
特别是_create
是什么? NetSocket *(*NetSocket::_create)() = NULL;
实际上做了什么?
您查看的文件有误。那一个只是委托给任何平台特定的实现已经链接 in/instantiated,使用 函数指针 称为 _create
.
设置在例如the POSIX impl.
只需在代码库中搜索 _create
的实例,您就会看到它是如何工作的。