mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 14:30:53 -07:00 
			
		
		
		
	Code::set_global reduction
This commit is contained in:
		| @@ -174,7 +174,7 @@ struct Code | ||||
| 	bool        is_equal( Code other )     { return GEN_NS is_equal(* this, other); } \ | ||||
| 	bool        is_body()                  { return GEN_NS is_body(* this); } \ | ||||
| 	bool        is_valid()                 { return GEN_NS is_valid(* this); } \ | ||||
| 	void        set_global();              \ | ||||
| 	void        set_global()               { return GEN_NS set_global(* this); } \ | ||||
| 	String      to_string();               \ | ||||
| 	Typename&   operator = ( AST* other ); \ | ||||
| 	Typename&   operator = ( Code other ); \ | ||||
|   | ||||
| @@ -7,16 +7,6 @@ | ||||
|  | ||||
| #pragma region generated code inline implementation | ||||
|  | ||||
| inline void Code::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline Code& Code::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -33,16 +23,6 @@ inline Code::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodeBody::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeBody& CodeBody::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -59,16 +39,6 @@ inline CodeBody::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodeAttributes::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeAttributes& CodeAttributes::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -105,16 +75,6 @@ inline AST_Attributes* CodeAttributes::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeComment::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeComment& CodeComment::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -151,16 +111,6 @@ inline AST_Comment* CodeComment::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeConstructor::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeConstructor& CodeConstructor::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -197,16 +147,6 @@ inline AST_Constructor* CodeConstructor::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeClass::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeClass& CodeClass::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -223,16 +163,6 @@ inline CodeClass::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodeDefine::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeDefine& CodeDefine::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -269,16 +199,6 @@ inline AST_Define* CodeDefine::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeDestructor::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeDestructor& CodeDestructor::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -315,16 +235,6 @@ inline AST_Destructor* CodeDestructor::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeEnum::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeEnum& CodeEnum::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -361,16 +271,6 @@ inline AST_Enum* CodeEnum::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeExec::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeExec& CodeExec::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -407,16 +307,6 @@ inline AST_Exec* CodeExec::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeExtern::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeExtern& CodeExtern::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -453,16 +343,6 @@ inline AST_Extern* CodeExtern::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeFriend::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeFriend& CodeFriend::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -499,16 +379,6 @@ inline AST_Friend* CodeFriend::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeFn::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeFn& CodeFn::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -545,16 +415,6 @@ inline AST_Fn* CodeFn::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeInclude::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeInclude& CodeInclude::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -591,16 +451,6 @@ inline AST_Include* CodeInclude::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeModule::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeModule& CodeModule::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -637,16 +487,6 @@ inline AST_Module* CodeModule::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeNS::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeNS& CodeNS::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -683,16 +523,6 @@ inline AST_NS* CodeNS::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeOperator::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeOperator& CodeOperator::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -729,16 +559,6 @@ inline AST_Operator* CodeOperator::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeOpCast::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeOpCast& CodeOpCast::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -775,16 +595,6 @@ inline AST_OpCast* CodeOpCast::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeParam::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeParam& CodeParam::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -801,16 +611,6 @@ inline CodeParam::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodePragma::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodePragma& CodePragma::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -847,16 +647,6 @@ inline AST_Pragma* CodePragma::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodePreprocessCond::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -893,16 +683,6 @@ inline AST_PreprocessCond* CodePreprocessCond::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeSpecifiers::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -919,16 +699,6 @@ inline CodeSpecifiers::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodeStruct::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeStruct& CodeStruct::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -945,16 +715,6 @@ inline CodeStruct::operator bool() | ||||
| 	return ast != nullptr; | ||||
| } | ||||
|  | ||||
| inline void CodeTemplate::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeTemplate& CodeTemplate::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -991,16 +751,6 @@ inline AST_Template* CodeTemplate::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeType::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeType& CodeType::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -1037,16 +787,6 @@ inline AST_Type* CodeType::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeTypedef::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeTypedef& CodeTypedef::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -1083,16 +823,6 @@ inline AST_Typedef* CodeTypedef::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeUnion::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeUnion& CodeUnion::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -1129,16 +859,6 @@ inline AST_Union* CodeUnion::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeUsing::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeUsing& CodeUsing::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
| @@ -1175,16 +895,6 @@ inline AST_Using* CodeUsing::operator->() | ||||
| 	return ast; | ||||
| } | ||||
|  | ||||
| inline void CodeVar::set_global() | ||||
| { | ||||
| 	if ( ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure( "Code::set_global: Cannot set code as global, AST is null!" ); | ||||
| 		return; | ||||
| 	} | ||||
| 	rcast( AST*, ast )->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline CodeVar& CodeVar::operator=( Code other ) | ||||
| { | ||||
| 	if ( other.ast && other->Parent ) | ||||
|   | ||||
| @@ -139,6 +139,18 @@ bool is_valid(Code self) | ||||
| 	return self.ast != nullptr && self.ast->Type != CodeT::Invalid; | ||||
| } | ||||
|  | ||||
| inline | ||||
| void set_global(Code self) | ||||
| { | ||||
| 	if ( self.ast == nullptr ) | ||||
| 	{ | ||||
| 		log_failure("Code::set_global: Cannot set code as global, AST is null!"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	self->Parent = Code_Global.ast; | ||||
| } | ||||
|  | ||||
| inline | ||||
| Code& Code::operator ++() | ||||
| { | ||||
|   | ||||
| @@ -354,17 +354,6 @@ CodeBody gen_ast_inlines() | ||||
| 	char const* code_impl_tmpl = stringize( | ||||
| 		\n | ||||
| 		inline | ||||
| 		void <typename>::set_global() | ||||
| 		{ | ||||
| 			if ( ast == nullptr ) | ||||
| 			{ | ||||
| 				log_failure("Code::set_global: Cannot set code as global, AST is null!"); | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			rcast(AST*, ast)->Parent = Code_Global.ast; | ||||
| 		} | ||||
| 		inline | ||||
| 		<typename>& <typename>::operator =( Code other ) | ||||
| 		{ | ||||
| 			if ( other.ast && other->Parent ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user