#! /bin/sh

#    /* Pos_1_2_Sub_0_5 */ { 1.0f / 2.0f, -0.5f },	36, -36
#    /* Pos_2_12        */ { 2.0f / 12.0f, 0.0f },	12
#	→
##define Pos_1_2_Sub_0_5	pos72(36, -36)
##define Pos_2_12	pos72(12, 0)

#    // U+250E ┎ BOX DRAWINGS DOWN HEAVY AND RIGHT LIGHT
#    {
#        Instruction{ Shape_LightLine, Pos_1_2_Sub_1, Pos_1_2, Pos_1_1, Pos_1_2 },
#        Instruction{ Shape_HeavyLine, Pos_1_2, Pos_1_2, Pos_1_2, Pos_1_1 },
#        Instruction{ Shape_EmptyRect, Pos_1_2_Add_1, Pos_Min, Pos_Max, Pos_1_2_Sub_1 },
#        Instruction{ Shape_RoundRect, Pos_Min, Pos_1_2, Pos_1_2, Pos_Max },
#    },
#	→
#        when 0x250E:  // ┎ BOX DRAWINGS DOWN HEAVY AND RIGHT LIGHT
#          drawline(false, Pos_1_2_Sub_1, Pos_1_2, Pos_1_1, Pos_1_2);
#          drawline(true, Pos_1_2, Pos_1_2, Pos_1_2, Pos_1_1);
#          drawangle(Pos_1_2_Add_1, Pos_Min, Pos_Max, Pos_1_2_Sub_1);
#          drawcurve(Pos_Min, Pos_1_2, Pos_1_2, Pos_Max);

cat $* |
sed -e "s%^ */\* \(Pos[^ ]*\)  *\*/ {.*},	\([-0-9]*\), *\([-0-9]*\).*%#define \1	pos72(\2, \3)%" \
    -e t \
    -e "s%^ */\* \(Pos[^ ]*\)  *\*/ {.*},	\([-0-9]*\).*%#define \1	pos72(\2, 0)%" \
    -e t \
    -e "s%^ *// U+\([0-9A-F]*\) *\(.*\)%        when 0x\1:  // \2%" \
    -e t \
    -e "s%^ *Instruction{ Shape_LightLine, \(.*\) },%          drawline(false, \1);%" \
    -e t \
    -e "s%^ *Instruction{ Shape_HeavyLine, \(.*\) },%          drawline(true, \1);%" \
    -e t \
    -e "s%^ *Instruction{ Shape_EmptyRect, \(.*\) },%          drawangle(\1);%" \
    -e t \
    -e "s%^ *Instruction{ Shape_RoundRect, \(.*\) },%          drawcurve(\1);%" \
    -e t \
    -e d
