MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ParseEventDef

Method ParseEventDef

neo/game/script/Script_Compiler.cpp:2442–2520  ·  view source on GitHub ↗

================ idCompiler::ParseEventDef ================ */

Source from the content-addressed store, hash-verified

2440================
2441*/
2442void idCompiler::ParseEventDef( idTypeDef *returnType, const char *name ) {
2443 const idTypeDef *expectedType;
2444 idTypeDef *argType;
2445 idTypeDef *type;
2446 int i;
2447 int num;
2448 const char *format;
2449 const idEventDef *ev;
2450 idStr parmName;
2451
2452 ev = idEventDef::FindEvent( name );
2453 if ( !ev ) {
2454 Error( "Unknown event '%s'", name );
2455 }
2456
2457 // set the return type
2458 expectedType = GetTypeForEventArg( ev->GetReturnType() );
2459 if ( !expectedType ) {
2460 Error( "Invalid return type '%c' in definition of '%s' event.", ev->GetReturnType(), name );
2461 }
2462 if ( returnType != expectedType ) {
2463 Error( "Return type doesn't match internal return type '%s'", expectedType->Name() );
2464 }
2465
2466 idTypeDef newtype( ev_function, NULL, name, type_function.Size(), returnType );
2467
2468 ExpectToken( "(" );
2469
2470 format = ev->GetArgFormat();
2471 num = strlen( format );
2472 for( i = 0; i < num; i++ ) {
2473 expectedType = GetTypeForEventArg( format[ i ] );
2474 if ( !expectedType || ( expectedType == &type_void ) ) {
2475 Error( "Invalid parameter '%c' in definition of '%s' event.", format[ i ], name );
2476 }
2477
2478 argType = ParseType();
2479 ParseName( parmName );
2480 if ( argType != expectedType ) {
2481 Error( "The type of parm %d ('%s') does not match the internal type '%s' in definition of '%s' event.",
2482 i + 1, parmName.c_str(), expectedType->Name(), name );
2483 }
2484
2485 newtype.AddFunctionParm( argType, "" );
2486
2487 if ( i < num - 1 ) {
2488 if ( CheckToken( ")" ) ) {
2489 Error( "Too few parameters for event definition. Internal definition has %d parameters.", num );
2490 }
2491 ExpectToken( "," );
2492 }
2493 }
2494 if ( !CheckToken( ")" ) ) {
2495 Error( "Too many parameters for event definition. Internal definition has %d parameters.", num );
2496 }
2497 ExpectToken( ";" );
2498
2499 type = gameLocal.program.FindType( name );

Callers

nothing calls this directly

Calls 13

ErrorFunction · 0.50
GetReturnTypeMethod · 0.45
NameMethod · 0.45
SizeMethod · 0.45
GetArgFormatMethod · 0.45
c_strMethod · 0.45
AddFunctionParmMethod · 0.45
FindTypeMethod · 0.45
MatchesTypeMethod · 0.45
AllocTypeMethod · 0.45
AllocDefMethod · 0.45
SetNumMethod · 0.45

Tested by

no test coverage detected