Rename A_Int/A_Bool/A_State to int/bool/state

- This is an effort to emphasize that these are just type casts. Now they
  look like function-style casts with no action function styling.
  They do no magic joojoo at all. The only reason they exist is because
  the DECORATE parser can only parse return statements that call a
  function, so these satisfy that requirement. i.e. *return int(666);* is
  identical to *return 666;* (if the parser could handle the latter).
This commit is contained in:
Randy Heit 2016-02-20 22:05:17 -06:00
parent cab39973df
commit e7b9e7e955
5 changed files with 40 additions and 11 deletions

View file

@ -673,3 +673,7 @@ xx(Max_Exp)
xx(Mant_Dig) xx(Mant_Dig)
xx(Min_10_Exp) xx(Min_10_Exp)
xx(Max_10_Exp) xx(Max_10_Exp)
xx(__decorate_internal_int__)
xx(__decorate_internal_bool__)
xx(__decorate_internal_state__)

View file

@ -192,6 +192,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
PFunction *afd, FString statestring, FStateDefinitions *statedef); PFunction *afd, FString statestring, FStateDefinitions *statedef);
FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Baggage &bag, PPrototype *&proto, bool &endswithret); FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Baggage &bag, PPrototype *&proto, bool &endswithret);
class FxVMFunctionCall *ParseAction(FScanner &sc, FState state, FString statestring, Baggage &bag); class FxVMFunctionCall *ParseAction(FScanner &sc, FState state, FString statestring, Baggage &bag);
FName CheckCastKludges(FName in);
void AddImplicitReturn(class FxSequence *code, const PPrototype *proto, FScanner &sc); void AddImplicitReturn(class FxSequence *code, const PPrototype *proto, FScanner &sc);
void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, PClassActor *cls, DWORD funcflags); void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, PClassActor *cls, DWORD funcflags);

View file

@ -325,13 +325,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance)
//=========================================================================== //===========================================================================
// //
// A_State // __decorate_internal_state__
// //
// Returns the state passed in. // Returns the state passed in.
// //
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_State) DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_state__)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_OBJECT(self, AActor); PARAM_OBJECT(self, AActor);
@ -341,13 +341,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_State)
//=========================================================================== //===========================================================================
// //
// A_Int // __decorate_internal_int__
// //
// Returns the int passed in. // Returns the int passed in.
// //
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Int) DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_int__)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_OBJECT(self, AActor); PARAM_OBJECT(self, AActor);
@ -357,13 +357,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Int)
//=========================================================================== //===========================================================================
// //
// A_Bool // __decorate_internal_bool__
// //
// Returns the bool passed in. // Returns the bool passed in.
// //
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Bool) DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_bool__)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_OBJECT(self, AActor); PARAM_OBJECT(self, AActor);

View file

@ -555,7 +555,9 @@ FxVMFunctionCall *ParseAction(FScanner &sc, FState state, FString statestring, B
return call; return call;
} }
PFunction *afd = dyn_cast<PFunction>(bag.Info->Symbols.FindSymbol(FName(sc.String, true), true)); FName symname = FName(sc.String, true);
symname = CheckCastKludges(symname);
PFunction *afd = dyn_cast<PFunction>(bag.Info->Symbols.FindSymbol(symname, true));
if (afd != NULL) if (afd != NULL)
{ {
FArgumentList *args = new FArgumentList; FArgumentList *args = new FArgumentList;
@ -678,3 +680,24 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
sc.MustGetStringName(")"); sc.MustGetStringName(")");
} }
} }
//==========================================================================
//
// CheckCastKludges
//
//==========================================================================
FName CheckCastKludges(FName in)
{
switch (in)
{
case NAME_Int:
return NAME___decorate_internal_int__;
case NAME_Bool:
return NAME___decorate_internal_bool__;
case NAME_State:
return NAME___decorate_internal_state__;
default:
return in;
}
}

View file

@ -43,10 +43,6 @@ ACTOR Actor native //: Thinker
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT); native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT);
native state A_State(state returnme);
native int A_Int(int returnme);
native bool A_Bool(bool returnme);
// Action functions // Action functions
// Meh, MBF redundant functions. Only for DeHackEd support. // Meh, MBF redundant functions. Only for DeHackEd support.
action native A_Turn(float angle = 0); action native A_Turn(float angle = 0);
@ -353,4 +349,9 @@ ACTOR Actor native //: Thinker
POL5 A -1 POL5 A -1
Stop Stop
} }
// Internal functions
native state __decorate_internal_state__(state);
native int __decorate_internal_int__(int);
native bool __decorate_internal_bool__(bool);
} }