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

Function ResolveURL

engine/script/src/script_msg.cpp:605–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603 }
604
605 dmMessage::Result ResolveURL(lua_State* L, const char* url, dmMessage::URL* out_url, dmMessage::URL* default_url)
606 {
607 // Special handling for "." which means default socket + path
608 if (url[0] == '.' && url[1] == '\0')
609 {
610 out_url->m_Socket = default_url->m_Socket;
611 out_url->m_Path = default_url->m_Path;
612 return dmMessage::RESULT_OK;
613 }
614 // Special handling for "#" which means default socket + path + fragment
615 if (url[0] == '#' && url[1] == '\0')
616 {
617 *out_url = *default_url;
618 return dmMessage::RESULT_OK;
619 }
620
621 // Make sure that m_FunctionRef is 0. A value != 0 is probably a bug due to
622 // reused PropertyVar (union) or use of char-buffers with uninitialized data
623 assert(out_url->_reserved == 0);
624 dmMessage::StringURL string_url;
625 dmMessage::Result result = dmMessage::ParseURL(url, &string_url);
626 if (result != dmMessage::RESULT_OK)
627 {
628 return result;
629 }
630 if (string_url.m_SocketSize > 0)
631 {
632 char socket_name[64];
633 if (string_url.m_SocketSize >= sizeof(socket_name))
634 return dmMessage::RESULT_INVALID_SOCKET_NAME;
635 dmStrlCpy(socket_name, string_url.m_Socket, dmMath::Min(string_url.m_SocketSize+1, (unsigned int) sizeof(socket_name)));
636 result = dmMessage::GetSocket(socket_name, &out_url->m_Socket);
637 if (!(result == dmMessage::RESULT_OK || result == dmMessage::RESULT_NAME_OK_SOCKET_NOT_FOUND))
638 {
639 return result;
640 }
641 out_url->m_Path = dmHashBuffer64(string_url.m_Path, string_url.m_PathSize);
642 }
643 else
644 {
645 out_url->m_Socket = default_url->m_Socket;
646 if (string_url.m_PathSize > 0)
647 {
648 ResolvePath(L, string_url.m_Path, string_url.m_PathSize, out_url->m_Path);
649 }
650 else
651 {
652 out_url->m_Path = default_url->m_Path;
653 }
654 }
655 if (string_url.m_FragmentSize > 0)
656 {
657 out_url->m_Fragment = dmHashBuffer64(string_url.m_Fragment, string_url.m_FragmentSize);
658 }
659 else if (string_url.m_SocketSize == 0 && string_url.m_PathSize == 0)
660 {
661 out_url->m_Fragment = default_url->m_Fragment;
662 }

Callers 5

URL_newFunction · 0.70
Msg_PostFunction · 0.70
TEST_FFunction · 0.50
TEST_FFunction · 0.50
CheckRenderCameraFunction · 0.50

Calls 15

ParseURLFunction · 0.85
dmStrlCpyFunction · 0.85
MinFunction · 0.85
ResolvePathFunction · 0.85
IsURLFunction · 0.85
lua_touserdataFunction · 0.85
ResetURLFunction · 0.85
lua_isstringFunction · 0.85
IsURLGlobalFunction · 0.85
luaL_errorFunction · 0.85
lua_gettopFunction · 0.85
ToHashFunction · 0.85

Tested by 2

TEST_FFunction · 0.40
TEST_FFunction · 0.40