mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-14 18:51:47 -07:00
First test works.
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
inline
|
||||
u8 square_u8(u8 value)
|
||||
{
|
||||
return value * value
|
||||
}
|
||||
|
||||
inline
|
||||
u16 square_u16(u16 value)
|
||||
{
|
||||
return value * value
|
||||
}
|
||||
|
||||
inline
|
||||
u32 square_u32(u32 value)
|
||||
{
|
||||
return value * value
|
||||
}
|
||||
|
||||
inline
|
||||
u64 square_u64(u64 value)
|
||||
{
|
||||
return value * value
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#define gen_time
|
||||
#include "Bloat.hpp"
|
||||
#include "gen.hpp"
|
||||
|
||||
#ifdef gen_time
|
||||
using namespace gen;
|
||||
|
||||
char* sprintf_buf[ZPL_PRINTF_MAXLEN];
|
||||
|
||||
/*
|
||||
What it should generate:
|
||||
|
||||
@ -20,10 +23,10 @@
|
||||
{
|
||||
Code integral_type = make_type( type );
|
||||
|
||||
string name = string_sprintf_buf( g_allocator, "square_%s", type );
|
||||
string name = string_sprintf( g_allocator, (char*)sprintf_buf, ZPL_PRINTF_MAXLEN, "square_%s", type );
|
||||
Code specifiers = make_specifiers( 1, Specifier::Inline );
|
||||
Code params = make_parameters( 1, "value", integral_type );
|
||||
Code ret_stmt = make_fmt( "return value * value" );
|
||||
Code ret_stmt = make_fmt( "\treturn value * value" );
|
||||
|
||||
Code result = make_function( name,
|
||||
specifiers,
|
||||
@ -41,17 +44,17 @@
|
||||
u32 gen_math()
|
||||
{
|
||||
Code fadd_u8 = gen_square( u8 );
|
||||
// Code fadd_u16 = gen_square( u16 );
|
||||
// Code fadd_u32 = gen_square( u32 );
|
||||
// Code fadd_u64 = gen_square( u64 );
|
||||
Code fadd_u16 = gen_square( u16 );
|
||||
Code fadd_u32 = gen_square( u32 );
|
||||
Code fadd_u64 = gen_square( u64 );
|
||||
|
||||
Builder
|
||||
mathgen;
|
||||
mathgen.open( "math.gen.hpp" );
|
||||
mathgen.print( fadd_u8 );
|
||||
// mathgen.print( fadd_u16 );
|
||||
// mathgen.print( fadd_u32 );
|
||||
// mathgen.print( fadd_u64 );
|
||||
mathgen.print( fadd_u16 );
|
||||
mathgen.print( fadd_u32 );
|
||||
mathgen.print( fadd_u64 );
|
||||
mathgen.write();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user