MCPcopy Create free account
hub / github.com/defold/defold / global_create

Function global_create

engine/script/src/luasocket/unix.c:324–346  ·  view source on GitHub ↗

=========================================================================*\ * Library functions \*=========================================================================*/ -------------------------------------------------------------------------*\ * Creates a master unix object \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

322* Creates a master unix object
323\*-------------------------------------------------------------------------*/
324static int global_create(lua_State *L) {
325 t_socket sock;
326 int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0);
327 /* try to allocate a system socket */
328 if (err == IO_DONE) {
329 /* allocate unix object */
330 p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
331 /* set its type as master object */
332 auxiliar_setclass(L, "unix{master}", -1);
333 /* initialize remaining structure fields */
334 socket_setnonblocking(&sock);
335 un->sock = sock;
336 io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv,
337 (p_error) socket_ioerror, &un->sock);
338 timeout_init(&un->tm, -1, -1);
339 buffer_init(&un->buf, &un->io, &un->tm);
340 return 1;
341 } else {
342 lua_pushnil(L);
343 lua_pushstring(L, socket_strerror(err));
344 return 2;
345 }
346}

Callers

nothing calls this directly

Calls 10

lua_newuserdataFunction · 0.85
auxiliar_setclassFunction · 0.85
io_initFunction · 0.85
timeout_initFunction · 0.85
buffer_initFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushstringFunction · 0.85
socket_createFunction · 0.70
socket_setnonblockingFunction · 0.70
socket_strerrorFunction · 0.70

Tested by

no test coverage detected