MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / main

Function main

src/server/angelscript/samples/asrun/source/main.cpp:68–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66vector<asIScriptContext*> g_ctxPool;
67
68int main(int argc, char **argv)
69{
70#if defined(_MSC_VER)
71 // Tell MSVC to report any memory leaks
72 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
73 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE);
74 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);
75
76 // Use _CrtSetBreakAlloc(n) to find a specific memory leak
77#endif
78
79#if defined(_WIN32)
80 // Turn on support for virtual terminal sequences to add support for colored text in the console
81 // Ref: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
82 // Ref: https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line
83 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
84 if (hOut == INVALID_HANDLE_VALUE)
85 return -1;
86
87 DWORD dwMode = 0;
88 if (!GetConsoleMode(hOut, &dwMode))
89 return -1;
90
91 dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
92 if (!SetConsoleMode(hOut, dwMode))
93 return -1;
94#endif
95
96 int r;
97
98 // Validate the command line arguments
99 bool argsValid = true;
100 if( argc < 2 )
101 argsValid = false;
102 else if( argc == 2 && strcmp(argv[1], "-d") == 0 )
103 argsValid = false;
104
105 if( !argsValid )
106 {
107 cout << "AngelScript command line runner. Version " << ANGELSCRIPT_VERSION_STRING << endl << endl;
108 cout << "Usage: " << endl;
109 cout << "asrun [-d] <script file> [<args>]" << endl;
110 cout << " -d inform if the script should be runned with debug" << endl;
111 cout << " <script file> is the script file that should be runned" << endl;
112 cout << " <args> zero or more args for the script" << endl;
113
114 WaitForUser();
115 return -1;
116 }
117
118 // Create the script engine
119 asIScriptEngine *engine = asCreateScriptEngine();
120 if( engine == 0 )
121 {
122 cout << "Failed to create script engine." << endl;
123 return -1;
124 }
125

Callers

nothing calls this directly

Calls 7

WaitForUserFunction · 0.85
SetWorkDirFunction · 0.85
ExecuteScriptFunction · 0.85
ShutDownAndReleaseMethod · 0.80
ConfigureEngineFunction · 0.70
CompileScriptFunction · 0.70
ReleaseMethod · 0.45

Tested by

no test coverage detected