<commit_before>/* Esvg - SVG
 * Copyright (C) 2011 <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.
 * If not, see <http://www.gnu.org/licenses/>.
 */
#include "esvg_private_main.h"
#include "esvg_private_attribute_presentation.h"
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
static void _color_dump(Esvg_Color *c)
{
	printf("%02x%02x%02x", c->r, c->g, c->b);
}

static void _paint_dump(Esvg_Paint *p)
{
	switch (p->type)
	{
		case ESVG_PAINT_CURRENT_COLOR:
		printf("current color");
		break;

		case ESVG_PAINT_COLOR:
		_color_dump(&p->value.color);
		break;

		case ESVG_PAINT_SERVER:
		printf("paint server");
		break;

		default:
		break;
	}
}

static void _length_dump(Esvg_Length *l)
{
	printf("%g", l->value);
	switch (l->unit)
	{
		case ESVG_UNIT_LENGTH_EM:
		printf("em");
		break;

		case ESVG_UNIT_LENGTH_EX:
		printf("ex");
		break;

		case ESVG_UNIT_LENGTH_PX:
		printf("px");
		break;

		case ESVG_UNIT_LENGTH_PT:
		printf("pt");
		break;

		case ESVG_UNIT_LENGTH_PC:
		printf("pc");
		break;

		case ESVG_UNIT_LENGTH_CM:
		printf("cm");
		break;

		case ESVG_UNIT_LENGTH_MM:
		printf("mm");
		break;

		case ESVG_UNIT_LENGTH_IN:
		printf("in");
		break;

		case ESVG_UNIT_LENGTH_PERCENT:
		printf("%%");
		break;

		default:
		break;
	}
}

static void _line_cap_dump(Esvg_Stroke_Line_Cap cap)
{
	switch (cap)
	{
		case ESVG_LINE_CAP_BUTT:
		printf("butt");
		break;

		case ESVG_LINE_CAP_ROUND:
		printf("round");
		break;

		case ESVG_LINE_CAP_SQUARE:
		printf("square");
		break;

		default:
		break;
	}
}

static void _line_join_dump(Esvg_Stroke_Line_Join join)
{
	switch (join)
	{
		case ESVG_LINE_JOIN_MITER:
		printf("miter");
		break;

		case ESVG_LINE_JOIN_ROUND:
		printf("round");
		break;

		case ESVG_LINE_JOIN_BEVEL:
		printf("bevel");
		break;

		default:
		break;
	}
}

/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
void esvg_attribute_presentation_setup(Esvg_Attribute_Presentation *thiz)
{
	Esvg_Color black = { 0, 0, 0 };
	Esvg_Length one = { ESVG_UNIT_LENGTH_PX, 1 };

	/* first do the cleanup */
	esvg_attribute_presentation_cleanup(thiz);
	/* now the default values */
	thiz->color.v = black;
	thiz->stroke_width.v = ESVG_LENGTH_1;
	thiz->stroke_opacity.v = 1.0;
	thiz->fill_opacity.v = 1.0;
	thiz->opacity.v = 1.0;
	thiz->fill_rule.v = ESVG_NON_ZERO;
	thiz->fill.v.type = ESVG_PAINT_COLOR;
	thiz->fill.v.value.color = black;
	thiz->stroke.v.type = ESVG_PAINT_NONE;
	thiz->stroke_width.v = one;
	thiz->stroke_line_cap.v = ESVG_LINE_CAP_BUTT;
	thiz->stroke_line_join.v = ESVG_LINE_JOIN_MITER;
	thiz->stop_opacity.v = 1.0;
}

void esvg_attribute_presentation_cleanup(Esvg_Attribute_Presentation *thiz)
{
	/* TODO free every attribute that can be allocated, i.e strings */
	if (thiz->fill.v.type == ESVG_PAINT_SERVER)
	{
		if (thiz->fill.v.value.paint_server)
			free(thiz->fill.v.value.paint_server);
	}
	if (thiz->stroke.v.type == ESVG_PAINT_SERVER)
	{
		if (thiz->stroke.v.value.paint_server)
			free(thiz->stroke.v.value.paint_server);
	}
}

void esvg_attribute_presentation_merge_rel(const Esvg_Attribute_Presentation *s,
		const Esvg_Attribute_Presentation *rel,<commit_msg>Use the correct order of the attributes<commit_after>/* Esvg - SVG
 * Copyright (C) 2011 <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.
 * If not, see <http://www.gnu.org/licenses/>.
 */
#include "esvg_private_main.h"
#include "esvg_private_attribute_presentation.h"
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
static void _color_dump(Esvg_Color *c)
{
	printf("%02x%02x%02x", c->r, c->g, c->b);
}

static void _paint_dump(Esvg_Paint *p)
{
	switch (p->type)
	{
		case ESVG_PAINT_CURRENT_COLOR:
		printf("current color");
		break;

		case ESVG_PAINT_COLOR:
		_color_dump(&p->value.color);
		break;

		case ESVG_PAINT_SERVER:
		printf("paint server");
		break;

		default:
		break;
	}
}

static void _length_dump(Esvg_Length *l)
{
	printf("%g", l->value);
	switch (l->unit)
	{
		case ESVG_UNIT_LENGTH_EM:
		printf("em");
		break;

		case ESVG_UNIT_LENGTH_EX:
		printf("ex");
		break;

		case ESVG_UNIT_LENGTH_PX:
		printf("px");
		break;

		case ESVG_UNIT_LENGTH_PT:
		printf("pt");
		break;

		case ESVG_UNIT_LENGTH_PC:
		printf("pc");
		break;

		case ESVG_UNIT_LENGTH_CM:
		printf("cm");
		break;

		case ESVG_UNIT_LENGTH_MM:
		printf("mm");
		break;

		case ESVG_UNIT_LENGTH_IN:
		printf("in");
		break;

		case ESVG_UNIT_LENGTH_PERCENT:
		printf("%%");
		break;

		default:
		break;
	}
}

static void _line_cap_dump(Esvg_Stroke_Line_Cap cap)
{
	switch (cap)
	{
		case ESVG_LINE_CAP_BUTT:
		printf("butt");
		break;

		case ESVG_LINE_CAP_ROUND:
		printf("round");
		break;

		case ESVG_LINE_CAP_SQUARE:
		printf("square");
		break;

		default:
		break;
	}
}

static void _line_join_dump(Esvg_Stroke_Line_Join join)
{
	switch (join)
	{
		case ESVG_LINE_JOIN_MITER:
		printf("miter");
		break;

		case ESVG_LINE_JOIN_ROUND:
		printf("round");
		break;

		case ESVG_LINE_JOIN_BEVEL:
		printf("bevel");
		break;

		default:
		break;
	}
}

/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
void esvg_attribute_presentation_setup(Esvg_Attribute_Presentation *thiz)
{
	Esvg_Color black = { 0, 0, 0 };
	Esvg_Length one = { ESVG_UNIT_LENGTH_PX, 1 };

	/* first do the cleanup */
	esvg_attribute_presentation_cleanup(thiz);
	/* now the default values */
	thiz->color.v = black;
	thiz->stroke_width.v = ESVG_LENGTH_1;
	thiz->stroke_opacity.v = 1.0;
	thiz->fill_opacity.v = 1.0;
	thiz->opacity.v = 1.0;
	thiz->fill_rule.v = ESVG_NON_ZERO;
	thiz->fill.v.type = ESVG_PAINT_COLOR;
	thiz->fill.v.value.color = black;
	thiz->stroke.v.type = ESVG_PAINT_NONE;
	thiz->stroke_width.v = one;
	thiz->stroke_line_cap.v = ESVG_LINE_CAP_BUTT;
	thiz->stroke_line_join.v = ESVG_LINE_JOIN_MITER;
	thiz->stop_opacity.v = 1.0;
}

void esvg_attribute_presentation_cleanup(Esvg_Attribute_Presentation *thiz)
{
	/* TODO free every attribute that can be allocated, i.e strings */
	if (thiz->fill.v.type == ESVG_PAINT_SERVER)
	{
		if (thiz->fill.v.value.paint_server)
			free(thiz->fill.v.value.paint_server);
	}
	if (thiz->stroke.v.type == ESVG_PAINT_SERVER)
	{
		if (thiz->stroke.v.value.paint_server)
			free(thiz->stroke.v.value.paint_server);
	}
}

void esvg_attribute_presentation_merge_rel(const Esvg_Attribute_Presentation *rel,
		const Esvg_Attribute_Presentation *s,
{'fraction_non_alphanumeric': 0.1836536122597908, 'fraction_numerical': 0.006081245439065921, 'mean_word_length': 3.874333135743924, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213591', 'n_tokens_mistral': 3173, 'n_tokens_neox': 2906, 'n_words': 627}