Skip to content

Commit

Permalink
Update gsl-lite (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
cagelight committed Sep 29, 2023
1 parent 05a1e5e commit 4e5fc65
Show file tree
Hide file tree
Showing 22 changed files with 5,559 additions and 896 deletions.
2 changes: 1 addition & 1 deletion code/cgame/FxScheduler.cpp
Expand Up @@ -524,7 +524,7 @@ int CFxScheduler::ParseEffect( const char *file, const CGPGroup& base )

for( const auto& primitiveGroup : base.GetSubGroups() )
{
static std::map< gsl::cstring_view, EPrimType, Q::CStringViewILess > primitiveTypes{
static std::map< gsl::cstring_span, EPrimType, Q::CStringViewILess > primitiveTypes{
{ CSTRING_VIEW( "particle" ), Particle },
{ CSTRING_VIEW( "line" ), Line },
{ CSTRING_VIEW( "tail" ), Tail },
Expand Down
104 changes: 52 additions & 52 deletions code/cgame/FxScheduler.h
Expand Up @@ -278,41 +278,41 @@ class CPrimitiveTemplate
private:

// Lower level parsing utilities
bool ParseVector( const gsl::cstring_view& val, vec3_t min, vec3_t max );
bool ParseFloat( const gsl::cstring_view& val, float& min, float& max );
bool ParseGroupFlags( const gsl::cstring_view& val, int& flags );
bool ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max );
bool ParseFloat( const gsl::cstring_span& val, float& min, float& max );
bool ParseGroupFlags( const gsl::cstring_span& val, int& flags );

// Base key processing
// Note that these all have their own parse functions in case it becomes important to do certain kinds
// of validation specific to that type.
bool ParseMin( const gsl::cstring_view& val );
bool ParseMax( const gsl::cstring_view& val );
bool ParseDelay( const gsl::cstring_view& val );
bool ParseCount( const gsl::cstring_view& val );
bool ParseLife( const gsl::cstring_view& val );
bool ParseElasticity( const gsl::cstring_view& val );
bool ParseFlags( const gsl::cstring_view& val );
bool ParseSpawnFlags( const gsl::cstring_view& val );

bool ParseOrigin1( const gsl::cstring_view& val );
bool ParseOrigin2( const gsl::cstring_view& val );
bool ParseRadius( const gsl::cstring_view& val );
bool ParseHeight( const gsl::cstring_view& val );
bool ParseWindModifier( const gsl::cstring_view& val );
bool ParseRotation( const gsl::cstring_view& val );
bool ParseRotationDelta( const gsl::cstring_view& val );
bool ParseAngle( const gsl::cstring_view& val );
bool ParseAngleDelta( const gsl::cstring_view& val );
bool ParseVelocity( const gsl::cstring_view& val );
bool ParseAcceleration( const gsl::cstring_view& val );
bool ParseGravity( const gsl::cstring_view& val );
bool ParseDensity( const gsl::cstring_view& val );
bool ParseVariance( const gsl::cstring_view& val );
bool ParseMin( const gsl::cstring_span& val );
bool ParseMax( const gsl::cstring_span& val );
bool ParseDelay( const gsl::cstring_span& val );
bool ParseCount( const gsl::cstring_span& val );
bool ParseLife( const gsl::cstring_span& val );
bool ParseElasticity( const gsl::cstring_span& val );
bool ParseFlags( const gsl::cstring_span& val );
bool ParseSpawnFlags( const gsl::cstring_span& val );

bool ParseOrigin1( const gsl::cstring_span& val );
bool ParseOrigin2( const gsl::cstring_span& val );
bool ParseRadius( const gsl::cstring_span& val );
bool ParseHeight( const gsl::cstring_span& val );
bool ParseWindModifier( const gsl::cstring_span& val );
bool ParseRotation( const gsl::cstring_span& val );
bool ParseRotationDelta( const gsl::cstring_span& val );
bool ParseAngle( const gsl::cstring_span& val );
bool ParseAngleDelta( const gsl::cstring_span& val );
bool ParseVelocity( const gsl::cstring_span& val );
bool ParseAcceleration( const gsl::cstring_span& val );
bool ParseGravity( const gsl::cstring_span& val );
bool ParseDensity( const gsl::cstring_span& val );
bool ParseVariance( const gsl::cstring_span& val );

/// Case insensitive map from cstring_view to Value
template< typename Value >
using StringViewIMap = std::map< gsl::cstring_view, Value, Q::CStringViewILess >;
using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_view& );
using StringViewIMap = std::map< gsl::cstring_span, Value, Q::CStringViewILess >;
using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_span& );
// Group type processing
bool ParseGroup( const CGPGroup& grp, const StringViewIMap< ParseMethod >& parseMethods, gsl::czstring name );
bool ParseRGB( const CGPGroup& grp );
Expand All @@ -331,30 +331,30 @@ class CPrimitiveTemplate
bool ParsePlayFxStrings( const CGPProperty& grp );

// Group keys
bool ParseRGBStart( const gsl::cstring_view& val );
bool ParseRGBEnd( const gsl::cstring_view& val );
bool ParseRGBParm( const gsl::cstring_view& val );
bool ParseRGBFlags( const gsl::cstring_view& val );

bool ParseAlphaStart( const gsl::cstring_view& val );
bool ParseAlphaEnd( const gsl::cstring_view& val );
bool ParseAlphaParm( const gsl::cstring_view& val );
bool ParseAlphaFlags( const gsl::cstring_view& val );

bool ParseSizeStart( const gsl::cstring_view& val );
bool ParseSizeEnd( const gsl::cstring_view& val );
bool ParseSizeParm( const gsl::cstring_view& val );
bool ParseSizeFlags( const gsl::cstring_view& val );

bool ParseSize2Start( const gsl::cstring_view& val );
bool ParseSize2End( const gsl::cstring_view& val );
bool ParseSize2Parm( const gsl::cstring_view& val );
bool ParseSize2Flags( const gsl::cstring_view& val );

bool ParseLengthStart( const gsl::cstring_view& val );
bool ParseLengthEnd( const gsl::cstring_view& val );
bool ParseLengthParm( const gsl::cstring_view& val );
bool ParseLengthFlags( const gsl::cstring_view& val );
bool ParseRGBStart( const gsl::cstring_span& val );
bool ParseRGBEnd( const gsl::cstring_span& val );
bool ParseRGBParm( const gsl::cstring_span& val );
bool ParseRGBFlags( const gsl::cstring_span& val );

bool ParseAlphaStart( const gsl::cstring_span& val );
bool ParseAlphaEnd( const gsl::cstring_span& val );
bool ParseAlphaParm( const gsl::cstring_span& val );
bool ParseAlphaFlags( const gsl::cstring_span& val );

bool ParseSizeStart( const gsl::cstring_span& val );
bool ParseSizeEnd( const gsl::cstring_span& val );
bool ParseSizeParm( const gsl::cstring_span& val );
bool ParseSizeFlags( const gsl::cstring_span& val );

bool ParseSize2Start( const gsl::cstring_span& val );
bool ParseSize2End( const gsl::cstring_span& val );
bool ParseSize2Parm( const gsl::cstring_span& val );
bool ParseSize2Flags( const gsl::cstring_span& val );

bool ParseLengthStart( const gsl::cstring_span& val );
bool ParseLengthEnd( const gsl::cstring_span& val );
bool ParseLengthParm( const gsl::cstring_span& val );
bool ParseLengthFlags( const gsl::cstring_span& val );


public:
Expand Down
6 changes: 3 additions & 3 deletions code/cgame/FxSystem.cpp
Expand Up @@ -136,21 +136,21 @@ void SFxHelper::AddFxToScene( refEntity_t *ent )
}

//------------------------------------------------------
int SFxHelper::RegisterShader( const gsl::cstring_view& shader )
int SFxHelper::RegisterShader( const gsl::cstring_span& shader )
{
// TODO: it would be nice to change the ABI here to allow for passing of string views
return cgi_R_RegisterShader( std::string( shader.begin(), shader.end() ).c_str() );
}

//------------------------------------------------------
int SFxHelper::RegisterSound( const gsl::cstring_view& sound )
int SFxHelper::RegisterSound( const gsl::cstring_span& sound )
{
// TODO: it would be nice to change the ABI here to allow for passing of string views
return cgi_S_RegisterSound( std::string( sound.begin(), sound.end() ).c_str() );
}

//------------------------------------------------------
int SFxHelper::RegisterModel( const gsl::cstring_view& model )
int SFxHelper::RegisterModel( const gsl::cstring_span& model )
{
return cgi_R_RegisterModel( std::string( model.begin(), model.end() ).c_str() );
}
Expand Down
6 changes: 3 additions & 3 deletions code/cgame/FxSystem.h
Expand Up @@ -58,7 +58,7 @@ struct SFxHelper
// Sound
void PlaySound( const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );
void PlayLocalSound( sfxHandle_t sfx, int channelNum );
int RegisterSound( const gsl::cstring_view& sound );
int RegisterSound( const gsl::cstring_span& sound );

//G2
int GetOriginAxisFromBolt(const centity_t &cent, int modelNum, int boltNum, vec3_t /*out*/origin, vec3_t /*out*/*axis);
Expand All @@ -70,8 +70,8 @@ struct SFxHelper
void AddFxToScene( refEntity_t *ent );
void AddLightToScene( vec3_t org, float radius, float red, float green, float blue );

int RegisterShader( const gsl::cstring_view& shader );
int RegisterModel( const gsl::cstring_view& model );
int RegisterShader( const gsl::cstring_span& shader );
int RegisterModel( const gsl::cstring_span& model );

void AddPolyToScene( int shader, int count, polyVert_t *verts );

Expand Down

0 comments on commit 4e5fc65

Please sign in to comment.