mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
Added support for friend operator definitions
This commit is contained in:
@ -449,7 +449,7 @@ void to_string(CodeFriend self, String* result )
|
||||
{
|
||||
append_fmt( result, "friend %S", to_string(self->Declaration) );
|
||||
|
||||
if ( self->Declaration->Type != CT_Function && (* result)[ length(* result) - 1 ] != ';' )
|
||||
if ( self->Declaration->Type != CT_Function && self->Declaration->Type != CT_Operator && (* result)[ length(* result) - 1 ] != ';' )
|
||||
{
|
||||
append( result, ";" );
|
||||
}
|
||||
|
@ -905,11 +905,11 @@ CodeBody parse_class_struct_body( TokType which, Token name )
|
||||
break;
|
||||
|
||||
case Tok_Operator:
|
||||
if ( currtok.Text[0] != '~' )
|
||||
{
|
||||
log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) );
|
||||
return InvalidCode;
|
||||
}
|
||||
//if ( currtok.Text[0] != '~' )
|
||||
//{
|
||||
// log_failure( "Operator token found in global body but not destructor unary negation\n%s", to_string(Context) );
|
||||
// return InvalidCode;
|
||||
//}
|
||||
|
||||
member = parse_destructor();
|
||||
// ~<Name>()
|
||||
@ -3859,7 +3859,8 @@ CodeFriend parse_friend()
|
||||
eat( Tok_Decl_Friend );
|
||||
// friend
|
||||
|
||||
CodeFn function = { nullptr };
|
||||
CodeFn function = { nullptr };
|
||||
CodeOperator op = { nullptr };
|
||||
|
||||
// Type declaration or return type
|
||||
CodeTypename type = parse_type();
|
||||
@ -3892,6 +3893,12 @@ CodeFriend parse_friend()
|
||||
// if ( params )
|
||||
// function->Params = params;
|
||||
}
|
||||
|
||||
// Operator declaration or definition
|
||||
if ( currtok.Type == Tok_Decl_Operator )
|
||||
{
|
||||
op = parse_operator_after_ret_type( ModuleFlag_None, NullCode, type );
|
||||
}
|
||||
|
||||
CodeComment inline_cmt = NullCode;
|
||||
if ( function && function->Type == CT_Function_Fwd )
|
||||
@ -3912,6 +3919,8 @@ CodeFriend parse_friend()
|
||||
|
||||
if ( function )
|
||||
result->Declaration = function;
|
||||
else if ( op )
|
||||
result->Declaration = op;
|
||||
else
|
||||
result->Declaration = type;
|
||||
|
||||
|
Reference in New Issue
Block a user