libcss: branch lcneves/units updated. release/0.7.0-26-g99e5168
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/99e5168ecb0f7203ed0d4d...
...commit http://git.netsurf-browser.org/libcss.git/commit/99e5168ecb0f7203ed0d4d6c...
...tree http://git.netsurf-browser.org/libcss.git/tree/99e5168ecb0f7203ed0d4d6ce2...
The branch, lcneves/units has been updated
via 99e5168ecb0f7203ed0d4d6ce2f08f092760029b (commit)
from 16505397bc2d474e365d0b7a3b57e1b81fd28661 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=99e5168ecb0f7203ed0d...
commit 99e5168ecb0f7203ed0d4d6ce2f08f092760029b
Author: Lucas Neves <lcneves(a)gmail.com>
Commit: Lucas Neves <lcneves(a)gmail.com>
WIP: Select: autogen for selection properties.
diff --git a/src/select/__pycache__/assets.cpython-36.pyc b/src/select/__pycache__/assets.cpython-36.pyc
index 9b622ce..b5bf9ca 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc b/src/select/__pycache__/select_config.cpython-36.pyc
index 55e01f8..3fdda2a 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 91bf92a..3f6b7d1 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -59,6 +59,27 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
const css_hint *parent, css_hint *size),
void *pw);
-#endif
-'''
+#endif'''
+
+assets['propset.h'] = {}
+assets['propset.h']['header'] = copyright + '''\
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_propset_h_
+#define css_select_propset_h_
+
+#include <string.h>
+
+#include <libcss/computed.h>
+#include "computed.h"
+
+/** Default values are 'initial value', unless the property is inherited,
+ * in which case it is 'inherit'. */'''
+assets['propset.h']['footer'] = '''
+#endif'''
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index a76c528..a319a58 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -13,6 +13,7 @@
+struct css_computed_uncommon_i {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -52,10 +53,60 @@
* entry
*
* cursor 5 sizeof(ptr)
+ *
* --- --- ---
* 116 bits 60 + 4sizeof(ptr) bytes
+ * ===================
+ * 75 + 4sizeof(ptr) bytes
+ *
+ * Bit allocations:
+ *
+ * 0 bbbbbbbbbbbccccccccoooooooouuuuu
+ * border_spacing; column_rule_width; outline_width; cursor
+ *
+ * 1 wwwwwwwlllllllcccccccooooooobbbb
+ * word_spacing; letter_spacing; column_width; column_gap; break_before
+ *
+ * 2 ccccccccccccccccccccccccccbbbboo
+ * clip; break_after; column_fill
+ *
+ * 3 ccccbbbboolluuttnner............
+ * column_rule_style; break_inside; column_span; column_count;
+ * column_rule_color; outline_color; content; counter_increment; counter_reset
*/
+ uint32_t bits[4];
+
+ css_fixed border_spacing_a;
+ css_fixed border_spacing_b;
+ css_fixed clip_a;
+ css_fixed clip_b;
+ css_fixed clip_c;
+ css_fixed clip_d;
+ int32_t column_count;
+ css_fixed column_gap;
+ css_color column_rule_color;
+ css_fixed column_rule_width;
+ css_fixed column_width;
+ css_fixed letter_spacing;
+ css_color outline_color;
+ css_fixed outline_width;
+ css_fixed word_spacing;
+};
+typedef struct css_computed_uncommon {
+ struct css_computed_uncommon_i i;
+
+ css_computed_content_item *content;
+ css_computed_counter *counter_increment;
+ css_computed_counter *counter_reset;
+ lwc_string **cursor;
+
+ struct css_computed_uncommon *next;
+ uint32_t count;
+ uint32_t bin;
+} css_computed_uncommon;
+
+typedef struct css_computed_page {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -65,10 +116,24 @@
* page_break_inside 2
* widows 1 4
*
+ *
* --- --- ---
* 10 bits 8 bytes
+ * ===================
+ * 10 bytes
+ *
+ * Bit allocations:
+ *
+ * 0 pppaaaggwo......................
+ * page_break_after; page_break_before; page_break_inside; widows; orphans
*/
+ uint32_t bits[1];
+
+ int32_t orphans;
+ int32_t widows;
+} css_computed_page;
+struct css_computed_style_i {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -157,9 +222,115 @@
* Encode quotes as an array of string objects, terminated with a blank entry.
*
* quotes 1 sizeof(ptr)
+ *
* --- --- ---
* 329 bits 160 + 4sizeof(ptr) bytes
+ * ===================
+ * 202 + 4sizeof(ptr) bytes
+ *
+ * Bit allocations:
+ *
+ * 0 bbbbbbbboooooooorrrrrrrrdddddddd
+ * border_bottom_width; border_left_width; border_top_width; border_right_width
+ *
+ * 1 mmmmmmmbbbbbbbaaaaaaaiiiiiiioooo
+ * max_height; bottom; margin_bottom; min_height; border_left_style
+ *
+ * 2 hhhhhhhrrrrrrrmmmmmmmaaaaaaatttt
+ * height; right; margin_top; margin_right; text_align
+ *
+ * 3 mmmmmmmtttttttffffffflllllllbbbb
+ * max_width; top; flex_basis; line_height; border_right_style
+ *
+ * 4 wwwwwwwmmmmmmmiiiiiiilllllllffff
+ * width; margin_left; min_width; left; font_weight
+ *
+ * 5 bbbbbbbbbbbvvvvvvvvvfffffffffaaa
+ * background_position; vertical_align; font_size; align_content
+ *
+ * 6 dddddtttttoooollllbbbbrrrraaaiii
+ * display; text_decoration; outline_style; list_style_type;
+ * border_bottom_style; border_top_style; align_items; align_self
+ *
+ * 7 ppppppaaaaaaddddddttttttiiiiiicc
+ * padding_bottom; padding_left; padding_top; text_indent; padding_right;
+ * caption_side
+ *
+ * 8 bboorrvvttddffaanniillcczzuueess
+ * border_bottom_color; border_collapse; border_left_color; visibility;
+ * table_layout; border_top_color; flex_wrap; background_attachment;
+ * font_style; font_variant; float; background_color; z_index; unicode_bidi;
+ * border_right_color; list_style_position
+ *
+ * 9 wwwbbbcccfffooopppnnnjjjttteexxa
+ * white_space; background_repeat; clear; flex_direction; overflow; position;
+ * font_family; justify_content; text_transform; empty_cells; box_sizing;
+ * opacity
+ *
+ * 10 ddfbcliqo.......................
+ * direction; flex_grow; background_image; color; flex_shrink;
+ * list_style_image; quotes; order
*/
+ uint32_t bits[11];
+
+ css_color background_color;
+ lwc_string *background_image;
+ css_fixed background_position_a;
+ css_fixed background_position_b;
+ css_color border_bottom_color;
+ css_fixed border_bottom_width;
+ css_color border_left_color;
+ css_fixed border_left_width;
+ css_color border_right_color;
+ css_fixed border_right_width;
+ css_color border_top_color;
+ css_fixed border_top_width;
+ css_fixed bottom;
+ css_color color;
+ css_fixed flex_basis;
+ css_fixed flex_grow;
+ css_fixed flex_shrink;
+ css_fixed font_size;
+ css_fixed height;
+ css_fixed left;
+ css_fixed line_height;
+ lwc_string *list_style_image;
+ css_fixed margin_bottom;
+ css_fixed margin_left;
+ css_fixed margin_right;
+ css_fixed margin_top;
+ css_fixed max_height;
+ css_fixed max_width;
+ css_fixed min_height;
+ css_fixed min_width;
+ css_fixed opacity;
+ int32_t order;
+ css_fixed padding_bottom;
+ css_fixed padding_left;
+ css_fixed padding_right;
+ css_fixed padding_top;
+ css_fixed right;
+ css_fixed text_indent;
+ css_fixed top;
+ css_fixed vertical_align;
+ css_fixed width;
+ int32_t z_index;
+
+ css_computed_uncommon *uncommon;
+ void *aural;
+};
+
+struct css_computed_style {
+ struct css_computed_style_i i;
+
+ lwc_string **font_family;
+ lwc_string **quotes;
+
+ css_computed_page *page;
+ struct css_computed_style *next;
+ uint32_t count;
+ uint32_t bin;
+};
/**
* Take a new reference to a computed style
*
@@ -194,4 +365,4 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
const css_hint *parent, css_hint *size),
void *pw);
-#endif
+#endif
\ No newline at end of file
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
new file mode 100644
index 0000000..4976929
--- /dev/null
+++ b/src/select/autogenerated_propset.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 The NetSurf Project
+ */
+
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_propset_h_
+#define css_select_propset_h_
+
+#include <string.h>
+
+#include <libcss/computed.h>
+#include "computed.h"
+
+/** Default values are 'initial value', unless the property is inherited,
+ * in which case it is 'inherit'. */
+static const css_computed_uncommon default_uncommon = {
+ .i = {
+ .bits = {
+ (CSS_BORDER_SPACING_SET << 21) | (
+ CSS_COLUMN_RULE_WIDTH_MEDIUM << 13) | (
+ CSS_OUTLINE_WIDTH_MEDIUM << 5) |
+ CSS_CURSOR_INHERIT,
+ (CSS_WORD_SPACING_NORMAL << 25) | (
+ CSS_LETTER_SPACING_NORMAL << 18) | (
+ CSS_COLUMN_WIDTH_AUTO << 11) | (
+ CSS_COLUMN_GAP_NORMAL << 4) |
+ CSS_BREAK_BEFORE_AUTO,
+ (CSS_CLIP_AUTO << 6) | (CSS_BREAK_AFTER_AUTO << 2) |
+ CSS_COLUMN_FILL_BALANCE,
+ (CSS_COLUMN_RULE_STYLE_NONE << 28) | (
+ CSS_BREAK_INSIDE_AUTO << 24) | (
+ CSS_COLUMN_SPAN_NONE << 22) | (
+ CSS_COLUMN_COUNT_AUTO << 20) | (
+ CSS_COLUMN_RULE_CURRENT_COLOR << 18) | (
+ CSS_OUTLINE_COLOR_INVERT << 16) | (
+ CSS_CONTENT_NORMAL << 14) | (
+ CSS_COUNTER_INCREMENT_NONE << 13) | (
+ CSS_COUNTER_RESET_NONE << 12)
+ },
+ },
+};
+static const css_computed_page default_page = {
+ .bits = {
+ (CSS_PAGE_BREAK_AFTER_AUTO << 29) | (CSS_PAGE_BREAK_BEFORE_AUTO
+ << 26) | (CSS_PAGE_BREAK_INSIDE_AUTO << 24) | (
+ CSS_WIDOWS_SET << 23) | (CSS_ORPHANS_SET << 22)
+ },
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/select/select_config.py b/src/select/select_config.py
index e63dc8b..2f0899b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -5,10 +5,11 @@
# Configuration of CSS values
values = {
- ('length', 'css_fixed', 4, 0, 'unit', 'css_unit', 5, 'CSS_UNIT_PX'),
- ('integer', 'int32_t', 4, 0),
- ('fixed', 'css_fixed', 4, 0),
- ('color', 'css_color', 4, 0),
+ ('length', 'css_fixed', 4, '0',
+ 'unit', 'css_unit', 5, 'CSS_UNIT_PX'),
+ ('integer', 'int32_t', 4, '0'),
+ ('fixed', 'css_fixed', 4, '0'),
+ ('color', 'css_color', 4, '0'),
('string', 'lwc_string*'),
('string_arr', 'lwc_string**'),
('counter', 'css_computed_counter*'),
@@ -110,25 +111,25 @@ page = {
('page_break_after', 3, None, None, 'CSS_PAGE_BREAK_AFTER_AUTO'),
('page_break_before', 3, None, None, 'CSS_PAGE_BREAK_BEFORE_AUTO'),
('page_break_inside', 2, None, None, 'CSS_PAGE_BREAK_INSIDE_AUTO'),
- ('widows', 1, 'integer', None, ('CSS_WIDOWS_SET', 2)),
- ('orphans', 1, 'integer', None, ('CSS_ORPHANS_SET', 2))
+ ('widows', 1, 'integer', None, ('CSS_WIDOWS_SET', '2 << CSS_RADIX_POINT')),
+ ('orphans', 1, 'integer', None, ('CSS_ORPHANS_SET', '2 << CSS_RADIX_POINT'))
}
uncommon = {
# Uncommon group
('border_spacing', 1, ('length', 'length'), 'CSS_BORDER_SPACING_SET',
- ('CSS_BORDER_SPACING_SET', 0, 'CSS_UNIT_PX', 0, 'CSS_UNIT_PX')),
+ ('CSS_BORDER_SPACING_SET', '0', 'CSS_UNIT_PX', '0', 'CSS_UNIT_PX')),
('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
('clip', 6, ('length', 'length', 'length', 'length'),
- 'CSS_CLIP_RECT', None, None, ('get', 'set')),
+ 'CSS_CLIP_RECT', 'CSS_CLIP_AUTO', None, ('get', 'set')),
('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
('column_gap', 2, 'length',
'CSS_COLUMN_GAP_SET', 'CSS_COLUMN_GAP_NORMAL'),
('column_rule_color', 2, 'color', None,
- ('CSS_COLUMN_RULE_CURRENT_COLOR', 0)),
+ ('CSS_COLUMN_RULE_CURRENT_COLOR', '0')),
('column_rule_style', 4, None, None, 'CSS_COLUMN_RULE_STYLE_NONE'),
('column_rule_width', 3, 'length',
'CSS_COLUMN_RULE_WIDTH_WIDTH', 'CSS_COLUMN_RULE_WIDTH_MEDIUM'),
@@ -150,18 +151,16 @@ uncommon = {
('counter_reset', 1, 'counter', None, 'CSS_COUNTER_RESET_NONE',
'Encode counter_reset as an array of name, value pairs, '
'terminated with a blank entry.'),
- ('cursor', 5, 'string_arr', 'CSS_CURSOR_AUTO', None,
+ ('cursor', 5, 'string_arr', 'CSS_CURSOR_AUTO', 'CSS_CURSOR_INHERIT',
'Encode cursor uri(s) as an array of string objects, terminated '
'with a blank entry'),
- ('content', 2, 'content_item', 'CSS_CONTENT_NORMAL', None,
+ ('content', 2, 'content_item', 'CSS_CONTENT_NORMAL', 'CSS_CONTENT_NORMAL',
'Encode content as an array of content items, terminated with '
'a blank entry.')
}
-groups = {
- 'main': { 'name': 'style', 'props': style },
- 'others': [
- { 'name': 'uncommon', 'props': uncommon },
- { 'name': 'page', 'props': page }
- ]
-}
+groups = [
+ { 'name': 'uncommon', 'props': uncommon },
+ { 'name': 'page', 'props': page },
+ { 'name': 'style', 'props': style }
+]
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 31fe613..d605f0b 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -3,13 +3,24 @@
# http://www.opensource.org/licenses/mit-license.php
# Copyright 2017 Lucas Neves <lcneves(a)gmail.com>
+import math
+import string
from select_config import values, groups
from assets import assets
+def shift_star(value_type, prop_name):
+ '''Shifts the asterisks from a pointer type to its name.
+ i.e. `lwc_string** str_array` would become `lwc_string **str_array`'''
+ star_i = value_type.find('*')
+ v_type = value_type if star_i is -1 else value_type[:star_i]
+ v_name = prop_name if star_i is -1 else value_type[star_i:] + prop_name
+ return (v_type, v_name)
+
class Text:
def __init__(self):
self._lines = []
self._comment = False
+ self._esc_nl = False
self._indent = 0
name_width = 31
@@ -27,10 +38,15 @@ class Text:
self.append(' */' if comm else '/*')
self._comment = not comm
+ def escape_newline(self):
+ self._esc_nl = not self._esc_nl
+
def append(self, text=None, pre_formatted=False):
if not text:
- self._lines.append('\t' * self._indent + ' * '
- if self._comment else '')
+ self._lines.append('{}{}{}'.format(
+ '\t' * self._indent,
+ ' * ' if self._comment else '',
+ '\t' * (9 - self._indent) + '\\' if self._esc_nl else ''))
return
if isinstance(text, list):
@@ -42,7 +58,7 @@ class Text:
self._lines.append(text)
return
- column_max = 80
+ column_max = 72 if self._esc_nl else 80
multiline = False
while text:
@@ -54,16 +70,20 @@ class Text:
line += text
text = ''
else:
- break_index = text[:column_max - prefix_size].rfind(' ')
+ space_index = text[:column_max - prefix_size].rfind(' ')
+ paren_index = text[:column_max - prefix_size].rfind('(')
+ break_index = max(space_index, paren_index + 1)
line += text[:break_index].rstrip()
text = text[break_index:].lstrip()
+ if self._esc_nl:
+ line += '\t' * (9 - math.floor(len(line) / 8)) + '\\'
self._lines.append(line)
if text and not self._comment and not multiline:
self.indent(2)
multiline = True
if multiline:
- self._indent(-2)
+ self.indent(-2)
def table_line(self):
self.append('{0:{n}}{0:{b}}{0}'.format(
@@ -75,6 +95,9 @@ class Text:
n=self.name_width, b=self.bits_width))
self.table_line()
+ def result_line(self):
+ self.append(' ' * self.name_width + '=' * (self.bits_width + 3))
+
def to_string(self):
return '\n'.join(self._lines)
@@ -82,7 +105,7 @@ class CSSValue:
'Values to be associated with properties.'
def __init__(self, name, css_type, size=None, default='NULL',
bits_name=None, bits_type=None,
- bits_size=None, bits_default=0):
+ bits_size=None, bits_default='0'):
self.name = name
self.type = css_type
self.size = size # `None` means sizeof(ptr)
@@ -105,6 +128,7 @@ class CSSProperty:
self.condition = condition
self.override = self.get_tuple(override)
self.comments = comments
+ self.__shift = None
__vals = [ CSSValue(*x) for x in values ]
@@ -153,22 +177,35 @@ class CSSProperty:
return (name + bits_size + vars_size +
(' + ' if vars_size and ptr else '') + ptr)
+ @property
+ def shift(self):
+ if self.__shift is None:
+ raise NameError('Attribute `shift` not set yet!')
+ return self.__shift
+
+ @shift.setter
+ def shift(self, val):
+ if type(val) is not int:
+ raise TypeError('Value of `shift` must be an integer!')
+ if val < 0:
+ raise ValueError('Value of `shift` must be zero or positive!')
+ self.__shift = val
+
class Bin:
def __init__(self, first_object):
self.contents = [ first_object ]
@property
def size(self):
- return sum([ x['size'] for x in self.contents ])
+ return sum([ x.bits_size for x in self.contents ])
def push(self, obj):
self.contents.append(obj)
class CSSGroup:
- def __init__(self, config, is_main=False):
+ def __init__(self, config):
self.name = config['name']
self.props = [ CSSProperty(*x) for x in config['props'] ]
- self.is_main = is_main
self.__bits_array = None
@property
@@ -193,15 +230,16 @@ class CSSGroup:
bin_size = 32
self.__bits_array = []
- props = sorted([ { 'name': p.name, 'size': p.bits_size }
- for p in self.props ], key=(lambda x: x['size']), reverse=True)
+ props = sorted(self.props, key=(lambda x: x.bits_size), reverse=True)
for p in props:
for b in self.__bits_array:
- if b.size + p['size'] <= bin_size:
+ if b.size + p.bits_size <= bin_size:
b.push(p)
+ p.shift = 32 - sum([ x.bits_size for x in b.contents ])
break
else:
+ p.shift = 32 - p.bits_size
self.__bits_array.append(Bin(p))
self.__bits_array.sort(key=(lambda x: x.size), reverse=True)
@@ -211,6 +249,11 @@ class CSSGroup:
def make_computed_h(self):
t = Text()
t.append()
+
+ typedef = 'typedef ' if self.name is 'page' else ''
+ t.append('{}struct css_computed_{}{} {{'.format(
+ typedef, self.name, '' if self.name is 'page' else '_i'))
+
t.comment()
commented = []
t.table_header()
@@ -220,6 +263,7 @@ class CSSGroup:
else:
commented.extend(( '', prop.comments, '', prop.size_line ))
t.append(commented)
+ t.append()
t.table_line()
t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
str(self.bits_size), ' bits', str(self.bytes_size),
@@ -227,18 +271,112 @@ class CSSGroup:
if self.ptr_size else '',
' bytes',
len_1=Text.name_width, len_2=(Text.bits_width - 3)))
+ t.result_line()
+ t.append('{:{len_1}}{:>3}{}{}'.format('',
+ math.ceil(self.bits_size / 8) + self.bytes_size,
+ ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+ if self.ptr_size else '',
+ ' bytes', len_1=Text.name_width))
+ t.append()
+
+ t.append('Bit allocations:')
+ for i, b in enumerate(self.bits_array):
+ bits = []
+ for prop in b.contents:
+ for char in prop.name + prop.name.upper():
+ if char not in bits and char in string.ascii_letters:
+ bits.extend(char * prop.bits_size)
+ break
+ t.append()
+ t.append('{:<2} {:.<32}'.format(str(i), ''.join(bits)))
+ t.append('; '.join([ p.name for p in b.contents ]))
t.comment()
+ t.indent(1)
+ t.append('uint32_t bits[' + str(len(self.bits_array)) + '];')
+ t.append()
+ t.append(self.make_value_declaration(for_commented=False))
+ if self.name is 'style':
+ t.append()
+ t.append('css_computed_uncommon *uncommon;')
+ t.append('void *aural;')
+ t.indent(-1)
+ t.append('}}{};'.format(
+ ' css_computed_' + self.name if typedef else ''))
+
+ if self.name is not 'page':
+ typedef = 'typedef ' if self.name is not 'style' else ''
+ t.append()
+ t.append('{}struct css_computed_{} {{'.format(
+ typedef, self.name))
+ t.indent(1)
+ t.append('struct css_computed_' + self.name + '_i i;')
+ t.append()
+ t.append(self.make_value_declaration(for_commented=True))
+ t.append()
+ if self.name is 'style':
+ t.append('css_computed_page *page;')
+ t.append('struct css_computed_' + self.name + ' *next;')
+ t.append('uint32_t count;')
+ t.append('uint32_t bin;')
+ t.indent(-1)
+ t.append('}}{};'.format(
+ ' css_computed_' + self.name if typedef else ''))
+
+ return t.to_string()
+
+ def make_propset_h(self):
+ t = Text()
+
+ if self.name is not 'style':
+ t.append('static const css_computed_{0} default_{0} = {{'.format(
+ self.name))
+ t.indent(1)
+ if self.name is not 'page':
+ t.append('.i = {')
+ t.indent(1)
+ t.append('.bits = {')
+ t.indent(1)
+ bits_ops = []
+ for b in self.bits_array:
+ or_ops = []
+ for p in b.contents:
+ or_ops.append('({} << {})'.format(p.defaults[0],
+ str(p.shift)) if p.shift else p.defaults[0])
+ bits_ops.append(' | '.join(or_ops))
+ t.append(',\n'.join(bits_ops).split('\n'))
+ t.indent(-1)
+ t.append('},')
+
+ if self.name is not 'page':
+ t.indent(-1)
+ t.append('},')
+
+ t.indent(-1)
+ t.append('};')
+
return t.to_string()
+ def make_value_declaration(self, for_commented):
+ r = []
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ if bool(p.comments) == for_commented:
+ for i, v in enumerate(p.values):
+ v_suffix = ('' if len(p.values) is 1 else
+ '_' + string.ascii_lowercase[i])
+ v_type, v_name = shift_star(v.type, p.name)
+ r.append('{} {}{}{}'.format(v_type, v_name, v_suffix, ';'))
+ return r
+
def make_text(self, filename):
if filename == 'computed.h':
return self.make_computed_h()
+ if filename == 'propset.h':
+ return self.make_propset_h()
else:
raise ValueError()
-css_groups = [ CSSGroup(g) for g in groups['others'] ]
-css_groups.append(CSSGroup(groups['main'], is_main=True))
+css_groups = [ CSSGroup(g) for g in groups ]
for k, v in assets.items():
# Key is filename string (e.g. "computed.h") without autogenerated_ prefix
-----------------------------------------------------------------------
Summary of changes:
src/select/__pycache__/assets.cpython-36.pyc | Bin 1398 -> 1913 bytes
.../__pycache__/select_config.cpython-36.pyc | Bin 6490 -> 6543 bytes
src/select/assets.py | 25 ++-
src/select/autogenerated_computed.h | 173 +++++++++++++++++++-
src/select/autogenerated_propset.h | 60 +++++++
src/select/select_config.py | 35 ++--
src/select/select_generator.py | 166 +++++++++++++++++--
7 files changed, 424 insertions(+), 35 deletions(-)
create mode 100644 src/select/autogenerated_propset.h
diff --git a/src/select/__pycache__/assets.cpython-36.pyc b/src/select/__pycache__/assets.cpython-36.pyc
index 9b622ce..b5bf9ca 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc b/src/select/__pycache__/select_config.cpython-36.pyc
index 55e01f8..3fdda2a 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 91bf92a..3f6b7d1 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -59,6 +59,27 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
const css_hint *parent, css_hint *size),
void *pw);
-#endif
-'''
+#endif'''
+
+assets['propset.h'] = {}
+assets['propset.h']['header'] = copyright + '''\
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_propset_h_
+#define css_select_propset_h_
+
+#include <string.h>
+
+#include <libcss/computed.h>
+#include "computed.h"
+
+/** Default values are 'initial value', unless the property is inherited,
+ * in which case it is 'inherit'. */'''
+assets['propset.h']['footer'] = '''
+#endif'''
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index a76c528..a319a58 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -13,6 +13,7 @@
+struct css_computed_uncommon_i {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -52,10 +53,60 @@
* entry
*
* cursor 5 sizeof(ptr)
+ *
* --- --- ---
* 116 bits 60 + 4sizeof(ptr) bytes
+ * ===================
+ * 75 + 4sizeof(ptr) bytes
+ *
+ * Bit allocations:
+ *
+ * 0 bbbbbbbbbbbccccccccoooooooouuuuu
+ * border_spacing; column_rule_width; outline_width; cursor
+ *
+ * 1 wwwwwwwlllllllcccccccooooooobbbb
+ * word_spacing; letter_spacing; column_width; column_gap; break_before
+ *
+ * 2 ccccccccccccccccccccccccccbbbboo
+ * clip; break_after; column_fill
+ *
+ * 3 ccccbbbboolluuttnner............
+ * column_rule_style; break_inside; column_span; column_count;
+ * column_rule_color; outline_color; content; counter_increment; counter_reset
*/
+ uint32_t bits[4];
+
+ css_fixed border_spacing_a;
+ css_fixed border_spacing_b;
+ css_fixed clip_a;
+ css_fixed clip_b;
+ css_fixed clip_c;
+ css_fixed clip_d;
+ int32_t column_count;
+ css_fixed column_gap;
+ css_color column_rule_color;
+ css_fixed column_rule_width;
+ css_fixed column_width;
+ css_fixed letter_spacing;
+ css_color outline_color;
+ css_fixed outline_width;
+ css_fixed word_spacing;
+};
+typedef struct css_computed_uncommon {
+ struct css_computed_uncommon_i i;
+
+ css_computed_content_item *content;
+ css_computed_counter *counter_increment;
+ css_computed_counter *counter_reset;
+ lwc_string **cursor;
+
+ struct css_computed_uncommon *next;
+ uint32_t count;
+ uint32_t bin;
+} css_computed_uncommon;
+
+typedef struct css_computed_page {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -65,10 +116,24 @@
* page_break_inside 2
* widows 1 4
*
+ *
* --- --- ---
* 10 bits 8 bytes
+ * ===================
+ * 10 bytes
+ *
+ * Bit allocations:
+ *
+ * 0 pppaaaggwo......................
+ * page_break_after; page_break_before; page_break_inside; widows; orphans
*/
+ uint32_t bits[1];
+
+ int32_t orphans;
+ int32_t widows;
+} css_computed_page;
+struct css_computed_style_i {
/*
* Property Size (bits) Size (bytes)
* --- --- ---
@@ -157,9 +222,115 @@
* Encode quotes as an array of string objects, terminated with a blank entry.
*
* quotes 1 sizeof(ptr)
+ *
* --- --- ---
* 329 bits 160 + 4sizeof(ptr) bytes
+ * ===================
+ * 202 + 4sizeof(ptr) bytes
+ *
+ * Bit allocations:
+ *
+ * 0 bbbbbbbboooooooorrrrrrrrdddddddd
+ * border_bottom_width; border_left_width; border_top_width; border_right_width
+ *
+ * 1 mmmmmmmbbbbbbbaaaaaaaiiiiiiioooo
+ * max_height; bottom; margin_bottom; min_height; border_left_style
+ *
+ * 2 hhhhhhhrrrrrrrmmmmmmmaaaaaaatttt
+ * height; right; margin_top; margin_right; text_align
+ *
+ * 3 mmmmmmmtttttttffffffflllllllbbbb
+ * max_width; top; flex_basis; line_height; border_right_style
+ *
+ * 4 wwwwwwwmmmmmmmiiiiiiilllllllffff
+ * width; margin_left; min_width; left; font_weight
+ *
+ * 5 bbbbbbbbbbbvvvvvvvvvfffffffffaaa
+ * background_position; vertical_align; font_size; align_content
+ *
+ * 6 dddddtttttoooollllbbbbrrrraaaiii
+ * display; text_decoration; outline_style; list_style_type;
+ * border_bottom_style; border_top_style; align_items; align_self
+ *
+ * 7 ppppppaaaaaaddddddttttttiiiiiicc
+ * padding_bottom; padding_left; padding_top; text_indent; padding_right;
+ * caption_side
+ *
+ * 8 bboorrvvttddffaanniillcczzuueess
+ * border_bottom_color; border_collapse; border_left_color; visibility;
+ * table_layout; border_top_color; flex_wrap; background_attachment;
+ * font_style; font_variant; float; background_color; z_index; unicode_bidi;
+ * border_right_color; list_style_position
+ *
+ * 9 wwwbbbcccfffooopppnnnjjjttteexxa
+ * white_space; background_repeat; clear; flex_direction; overflow; position;
+ * font_family; justify_content; text_transform; empty_cells; box_sizing;
+ * opacity
+ *
+ * 10 ddfbcliqo.......................
+ * direction; flex_grow; background_image; color; flex_shrink;
+ * list_style_image; quotes; order
*/
+ uint32_t bits[11];
+
+ css_color background_color;
+ lwc_string *background_image;
+ css_fixed background_position_a;
+ css_fixed background_position_b;
+ css_color border_bottom_color;
+ css_fixed border_bottom_width;
+ css_color border_left_color;
+ css_fixed border_left_width;
+ css_color border_right_color;
+ css_fixed border_right_width;
+ css_color border_top_color;
+ css_fixed border_top_width;
+ css_fixed bottom;
+ css_color color;
+ css_fixed flex_basis;
+ css_fixed flex_grow;
+ css_fixed flex_shrink;
+ css_fixed font_size;
+ css_fixed height;
+ css_fixed left;
+ css_fixed line_height;
+ lwc_string *list_style_image;
+ css_fixed margin_bottom;
+ css_fixed margin_left;
+ css_fixed margin_right;
+ css_fixed margin_top;
+ css_fixed max_height;
+ css_fixed max_width;
+ css_fixed min_height;
+ css_fixed min_width;
+ css_fixed opacity;
+ int32_t order;
+ css_fixed padding_bottom;
+ css_fixed padding_left;
+ css_fixed padding_right;
+ css_fixed padding_top;
+ css_fixed right;
+ css_fixed text_indent;
+ css_fixed top;
+ css_fixed vertical_align;
+ css_fixed width;
+ int32_t z_index;
+
+ css_computed_uncommon *uncommon;
+ void *aural;
+};
+
+struct css_computed_style {
+ struct css_computed_style_i i;
+
+ lwc_string **font_family;
+ lwc_string **quotes;
+
+ css_computed_page *page;
+ struct css_computed_style *next;
+ uint32_t count;
+ uint32_t bin;
+};
/**
* Take a new reference to a computed style
*
@@ -194,4 +365,4 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
const css_hint *parent, css_hint *size),
void *pw);
-#endif
+#endif
\ No newline at end of file
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
new file mode 100644
index 0000000..4976929
--- /dev/null
+++ b/src/select/autogenerated_propset.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 The NetSurf Project
+ */
+
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_propset_h_
+#define css_select_propset_h_
+
+#include <string.h>
+
+#include <libcss/computed.h>
+#include "computed.h"
+
+/** Default values are 'initial value', unless the property is inherited,
+ * in which case it is 'inherit'. */
+static const css_computed_uncommon default_uncommon = {
+ .i = {
+ .bits = {
+ (CSS_BORDER_SPACING_SET << 21) | (
+ CSS_COLUMN_RULE_WIDTH_MEDIUM << 13) | (
+ CSS_OUTLINE_WIDTH_MEDIUM << 5) |
+ CSS_CURSOR_INHERIT,
+ (CSS_WORD_SPACING_NORMAL << 25) | (
+ CSS_LETTER_SPACING_NORMAL << 18) | (
+ CSS_COLUMN_WIDTH_AUTO << 11) | (
+ CSS_COLUMN_GAP_NORMAL << 4) |
+ CSS_BREAK_BEFORE_AUTO,
+ (CSS_CLIP_AUTO << 6) | (CSS_BREAK_AFTER_AUTO << 2) |
+ CSS_COLUMN_FILL_BALANCE,
+ (CSS_COLUMN_RULE_STYLE_NONE << 28) | (
+ CSS_BREAK_INSIDE_AUTO << 24) | (
+ CSS_COLUMN_SPAN_NONE << 22) | (
+ CSS_COLUMN_COUNT_AUTO << 20) | (
+ CSS_COLUMN_RULE_CURRENT_COLOR << 18) | (
+ CSS_OUTLINE_COLOR_INVERT << 16) | (
+ CSS_CONTENT_NORMAL << 14) | (
+ CSS_COUNTER_INCREMENT_NONE << 13) | (
+ CSS_COUNTER_RESET_NONE << 12)
+ },
+ },
+};
+static const css_computed_page default_page = {
+ .bits = {
+ (CSS_PAGE_BREAK_AFTER_AUTO << 29) | (CSS_PAGE_BREAK_BEFORE_AUTO
+ << 26) | (CSS_PAGE_BREAK_INSIDE_AUTO << 24) | (
+ CSS_WIDOWS_SET << 23) | (CSS_ORPHANS_SET << 22)
+ },
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/select/select_config.py b/src/select/select_config.py
index e63dc8b..2f0899b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -5,10 +5,11 @@
# Configuration of CSS values
values = {
- ('length', 'css_fixed', 4, 0, 'unit', 'css_unit', 5, 'CSS_UNIT_PX'),
- ('integer', 'int32_t', 4, 0),
- ('fixed', 'css_fixed', 4, 0),
- ('color', 'css_color', 4, 0),
+ ('length', 'css_fixed', 4, '0',
+ 'unit', 'css_unit', 5, 'CSS_UNIT_PX'),
+ ('integer', 'int32_t', 4, '0'),
+ ('fixed', 'css_fixed', 4, '0'),
+ ('color', 'css_color', 4, '0'),
('string', 'lwc_string*'),
('string_arr', 'lwc_string**'),
('counter', 'css_computed_counter*'),
@@ -110,25 +111,25 @@ page = {
('page_break_after', 3, None, None, 'CSS_PAGE_BREAK_AFTER_AUTO'),
('page_break_before', 3, None, None, 'CSS_PAGE_BREAK_BEFORE_AUTO'),
('page_break_inside', 2, None, None, 'CSS_PAGE_BREAK_INSIDE_AUTO'),
- ('widows', 1, 'integer', None, ('CSS_WIDOWS_SET', 2)),
- ('orphans', 1, 'integer', None, ('CSS_ORPHANS_SET', 2))
+ ('widows', 1, 'integer', None, ('CSS_WIDOWS_SET', '2 << CSS_RADIX_POINT')),
+ ('orphans', 1, 'integer', None, ('CSS_ORPHANS_SET', '2 << CSS_RADIX_POINT'))
}
uncommon = {
# Uncommon group
('border_spacing', 1, ('length', 'length'), 'CSS_BORDER_SPACING_SET',
- ('CSS_BORDER_SPACING_SET', 0, 'CSS_UNIT_PX', 0, 'CSS_UNIT_PX')),
+ ('CSS_BORDER_SPACING_SET', '0', 'CSS_UNIT_PX', '0', 'CSS_UNIT_PX')),
('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
('clip', 6, ('length', 'length', 'length', 'length'),
- 'CSS_CLIP_RECT', None, None, ('get', 'set')),
+ 'CSS_CLIP_RECT', 'CSS_CLIP_AUTO', None, ('get', 'set')),
('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
('column_gap', 2, 'length',
'CSS_COLUMN_GAP_SET', 'CSS_COLUMN_GAP_NORMAL'),
('column_rule_color', 2, 'color', None,
- ('CSS_COLUMN_RULE_CURRENT_COLOR', 0)),
+ ('CSS_COLUMN_RULE_CURRENT_COLOR', '0')),
('column_rule_style', 4, None, None, 'CSS_COLUMN_RULE_STYLE_NONE'),
('column_rule_width', 3, 'length',
'CSS_COLUMN_RULE_WIDTH_WIDTH', 'CSS_COLUMN_RULE_WIDTH_MEDIUM'),
@@ -150,18 +151,16 @@ uncommon = {
('counter_reset', 1, 'counter', None, 'CSS_COUNTER_RESET_NONE',
'Encode counter_reset as an array of name, value pairs, '
'terminated with a blank entry.'),
- ('cursor', 5, 'string_arr', 'CSS_CURSOR_AUTO', None,
+ ('cursor', 5, 'string_arr', 'CSS_CURSOR_AUTO', 'CSS_CURSOR_INHERIT',
'Encode cursor uri(s) as an array of string objects, terminated '
'with a blank entry'),
- ('content', 2, 'content_item', 'CSS_CONTENT_NORMAL', None,
+ ('content', 2, 'content_item', 'CSS_CONTENT_NORMAL', 'CSS_CONTENT_NORMAL',
'Encode content as an array of content items, terminated with '
'a blank entry.')
}
-groups = {
- 'main': { 'name': 'style', 'props': style },
- 'others': [
- { 'name': 'uncommon', 'props': uncommon },
- { 'name': 'page', 'props': page }
- ]
-}
+groups = [
+ { 'name': 'uncommon', 'props': uncommon },
+ { 'name': 'page', 'props': page },
+ { 'name': 'style', 'props': style }
+]
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 31fe613..d605f0b 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -3,13 +3,24 @@
# http://www.opensource.org/licenses/mit-license.php
# Copyright 2017 Lucas Neves <lcneves(a)gmail.com>
+import math
+import string
from select_config import values, groups
from assets import assets
+def shift_star(value_type, prop_name):
+ '''Shifts the asterisks from a pointer type to its name.
+ i.e. `lwc_string** str_array` would become `lwc_string **str_array`'''
+ star_i = value_type.find('*')
+ v_type = value_type if star_i is -1 else value_type[:star_i]
+ v_name = prop_name if star_i is -1 else value_type[star_i:] + prop_name
+ return (v_type, v_name)
+
class Text:
def __init__(self):
self._lines = []
self._comment = False
+ self._esc_nl = False
self._indent = 0
name_width = 31
@@ -27,10 +38,15 @@ class Text:
self.append(' */' if comm else '/*')
self._comment = not comm
+ def escape_newline(self):
+ self._esc_nl = not self._esc_nl
+
def append(self, text=None, pre_formatted=False):
if not text:
- self._lines.append('\t' * self._indent + ' * '
- if self._comment else '')
+ self._lines.append('{}{}{}'.format(
+ '\t' * self._indent,
+ ' * ' if self._comment else '',
+ '\t' * (9 - self._indent) + '\\' if self._esc_nl else ''))
return
if isinstance(text, list):
@@ -42,7 +58,7 @@ class Text:
self._lines.append(text)
return
- column_max = 80
+ column_max = 72 if self._esc_nl else 80
multiline = False
while text:
@@ -54,16 +70,20 @@ class Text:
line += text
text = ''
else:
- break_index = text[:column_max - prefix_size].rfind(' ')
+ space_index = text[:column_max - prefix_size].rfind(' ')
+ paren_index = text[:column_max - prefix_size].rfind('(')
+ break_index = max(space_index, paren_index + 1)
line += text[:break_index].rstrip()
text = text[break_index:].lstrip()
+ if self._esc_nl:
+ line += '\t' * (9 - math.floor(len(line) / 8)) + '\\'
self._lines.append(line)
if text and not self._comment and not multiline:
self.indent(2)
multiline = True
if multiline:
- self._indent(-2)
+ self.indent(-2)
def table_line(self):
self.append('{0:{n}}{0:{b}}{0}'.format(
@@ -75,6 +95,9 @@ class Text:
n=self.name_width, b=self.bits_width))
self.table_line()
+ def result_line(self):
+ self.append(' ' * self.name_width + '=' * (self.bits_width + 3))
+
def to_string(self):
return '\n'.join(self._lines)
@@ -82,7 +105,7 @@ class CSSValue:
'Values to be associated with properties.'
def __init__(self, name, css_type, size=None, default='NULL',
bits_name=None, bits_type=None,
- bits_size=None, bits_default=0):
+ bits_size=None, bits_default='0'):
self.name = name
self.type = css_type
self.size = size # `None` means sizeof(ptr)
@@ -105,6 +128,7 @@ class CSSProperty:
self.condition = condition
self.override = self.get_tuple(override)
self.comments = comments
+ self.__shift = None
__vals = [ CSSValue(*x) for x in values ]
@@ -153,22 +177,35 @@ class CSSProperty:
return (name + bits_size + vars_size +
(' + ' if vars_size and ptr else '') + ptr)
+ @property
+ def shift(self):
+ if self.__shift is None:
+ raise NameError('Attribute `shift` not set yet!')
+ return self.__shift
+
+ @shift.setter
+ def shift(self, val):
+ if type(val) is not int:
+ raise TypeError('Value of `shift` must be an integer!')
+ if val < 0:
+ raise ValueError('Value of `shift` must be zero or positive!')
+ self.__shift = val
+
class Bin:
def __init__(self, first_object):
self.contents = [ first_object ]
@property
def size(self):
- return sum([ x['size'] for x in self.contents ])
+ return sum([ x.bits_size for x in self.contents ])
def push(self, obj):
self.contents.append(obj)
class CSSGroup:
- def __init__(self, config, is_main=False):
+ def __init__(self, config):
self.name = config['name']
self.props = [ CSSProperty(*x) for x in config['props'] ]
- self.is_main = is_main
self.__bits_array = None
@property
@@ -193,15 +230,16 @@ class CSSGroup:
bin_size = 32
self.__bits_array = []
- props = sorted([ { 'name': p.name, 'size': p.bits_size }
- for p in self.props ], key=(lambda x: x['size']), reverse=True)
+ props = sorted(self.props, key=(lambda x: x.bits_size), reverse=True)
for p in props:
for b in self.__bits_array:
- if b.size + p['size'] <= bin_size:
+ if b.size + p.bits_size <= bin_size:
b.push(p)
+ p.shift = 32 - sum([ x.bits_size for x in b.contents ])
break
else:
+ p.shift = 32 - p.bits_size
self.__bits_array.append(Bin(p))
self.__bits_array.sort(key=(lambda x: x.size), reverse=True)
@@ -211,6 +249,11 @@ class CSSGroup:
def make_computed_h(self):
t = Text()
t.append()
+
+ typedef = 'typedef ' if self.name is 'page' else ''
+ t.append('{}struct css_computed_{}{} {{'.format(
+ typedef, self.name, '' if self.name is 'page' else '_i'))
+
t.comment()
commented = []
t.table_header()
@@ -220,6 +263,7 @@ class CSSGroup:
else:
commented.extend(( '', prop.comments, '', prop.size_line ))
t.append(commented)
+ t.append()
t.table_line()
t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
str(self.bits_size), ' bits', str(self.bytes_size),
@@ -227,18 +271,112 @@ class CSSGroup:
if self.ptr_size else '',
' bytes',
len_1=Text.name_width, len_2=(Text.bits_width - 3)))
+ t.result_line()
+ t.append('{:{len_1}}{:>3}{}{}'.format('',
+ math.ceil(self.bits_size / 8) + self.bytes_size,
+ ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+ if self.ptr_size else '',
+ ' bytes', len_1=Text.name_width))
+ t.append()
+
+ t.append('Bit allocations:')
+ for i, b in enumerate(self.bits_array):
+ bits = []
+ for prop in b.contents:
+ for char in prop.name + prop.name.upper():
+ if char not in bits and char in string.ascii_letters:
+ bits.extend(char * prop.bits_size)
+ break
+ t.append()
+ t.append('{:<2} {:.<32}'.format(str(i), ''.join(bits)))
+ t.append('; '.join([ p.name for p in b.contents ]))
t.comment()
+ t.indent(1)
+ t.append('uint32_t bits[' + str(len(self.bits_array)) + '];')
+ t.append()
+ t.append(self.make_value_declaration(for_commented=False))
+ if self.name is 'style':
+ t.append()
+ t.append('css_computed_uncommon *uncommon;')
+ t.append('void *aural;')
+ t.indent(-1)
+ t.append('}}{};'.format(
+ ' css_computed_' + self.name if typedef else ''))
+
+ if self.name is not 'page':
+ typedef = 'typedef ' if self.name is not 'style' else ''
+ t.append()
+ t.append('{}struct css_computed_{} {{'.format(
+ typedef, self.name))
+ t.indent(1)
+ t.append('struct css_computed_' + self.name + '_i i;')
+ t.append()
+ t.append(self.make_value_declaration(for_commented=True))
+ t.append()
+ if self.name is 'style':
+ t.append('css_computed_page *page;')
+ t.append('struct css_computed_' + self.name + ' *next;')
+ t.append('uint32_t count;')
+ t.append('uint32_t bin;')
+ t.indent(-1)
+ t.append('}}{};'.format(
+ ' css_computed_' + self.name if typedef else ''))
+
+ return t.to_string()
+
+ def make_propset_h(self):
+ t = Text()
+
+ if self.name is not 'style':
+ t.append('static const css_computed_{0} default_{0} = {{'.format(
+ self.name))
+ t.indent(1)
+ if self.name is not 'page':
+ t.append('.i = {')
+ t.indent(1)
+ t.append('.bits = {')
+ t.indent(1)
+ bits_ops = []
+ for b in self.bits_array:
+ or_ops = []
+ for p in b.contents:
+ or_ops.append('({} << {})'.format(p.defaults[0],
+ str(p.shift)) if p.shift else p.defaults[0])
+ bits_ops.append(' | '.join(or_ops))
+ t.append(',\n'.join(bits_ops).split('\n'))
+ t.indent(-1)
+ t.append('},')
+
+ if self.name is not 'page':
+ t.indent(-1)
+ t.append('},')
+
+ t.indent(-1)
+ t.append('};')
+
return t.to_string()
+ def make_value_declaration(self, for_commented):
+ r = []
+ for p in sorted(self.props, key=(lambda x: x.name)):
+ if bool(p.comments) == for_commented:
+ for i, v in enumerate(p.values):
+ v_suffix = ('' if len(p.values) is 1 else
+ '_' + string.ascii_lowercase[i])
+ v_type, v_name = shift_star(v.type, p.name)
+ r.append('{} {}{}{}'.format(v_type, v_name, v_suffix, ';'))
+ return r
+
def make_text(self, filename):
if filename == 'computed.h':
return self.make_computed_h()
+ if filename == 'propset.h':
+ return self.make_propset_h()
else:
raise ValueError()
-css_groups = [ CSSGroup(g) for g in groups['others'] ]
-css_groups.append(CSSGroup(groups['main'], is_main=True))
+css_groups = [ CSSGroup(g) for g in groups ]
for k, v in assets.items():
# Key is filename string (e.g. "computed.h") without autogenerated_ prefix
--
Cascading Style Sheets library
5 years, 4 months
libcss: branch lcneves/units updated. release/0.7.0-25-g1650539
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/16505397bc2d474e365d0b...
...commit http://git.netsurf-browser.org/libcss.git/commit/16505397bc2d474e365d0b7a...
...tree http://git.netsurf-browser.org/libcss.git/tree/16505397bc2d474e365d0b7a3b...
The branch, lcneves/units has been updated
via 16505397bc2d474e365d0b7a3b57e1b81fd28661 (commit)
from 41cee64272bed090f3b2151ce00b00c3c89222f1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=16505397bc2d474e365d...
commit 16505397bc2d474e365d0b7a3b57e1b81fd28661
Author: Lucas Neves <lcneves(a)gmail.com>
Commit: Lucas Neves <lcneves(a)gmail.com>
WIP: Select: Autogen for selection properties.
diff --git a/src/select/__pycache__/assets.cpython-36.pyc b/src/select/__pycache__/assets.cpython-36.pyc
index f7b7da8..9b622ce 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc b/src/select/__pycache__/select_config.cpython-36.pyc
index bcda842..55e01f8 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 33982b0..91bf92a 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -29,7 +29,7 @@ assets['computed.h']['footer'] = '''\
* Take a new reference to a computed style
*
* \param style The style to take a new reference to.
- * \return The new computed style reference
+ * \\return The new computed style reference
*/
static inline css_computed_style * css__computed_style_ref(
css_computed_style *style)
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index 76a6b32..a76c528 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -14,122 +14,157 @@
/*
- * border_spacing 1 + 10 8
- * break_after 4
- * break_before 4
- * break_inside 4
- * clip 6
- * column_count 2 4
- * column_fill 2
- * column_gap 2 + 5 4
- * column_rule_color 2 4
- * column_rule_style 4
- * column_rule_width 3 + 5 4
- * column_span 2
- * column_width 2 + 5 4
- * content 2 sizeof(ptr)
- * counter_increment 1 sizeof(ptr)
- * counter_reset 1 sizeof(ptr)
- * cursor 5 sizeof(ptr)
- * letter_spacing 2 + 5 4
- * outline_color 2 4
- * outline_width 3 + 5 4
- * word_spacing 2 + 5 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * border_spacing 1 + 10 8
+ * break_after 4
+ * break_before 4
+ * break_inside 4
+ * clip 6 + 20 16
+ * column_count 2 4
+ * column_fill 2
+ * column_gap 2 + 5 4
+ * column_rule_color 2 4
+ * column_rule_style 4
+ * column_rule_width 3 + 5 4
+ * column_span 2
+ * column_width 2 + 5 4
+ * letter_spacing 2 + 5 4
+ * outline_color 2 4
+ * outline_width 3 + 5 4
+ * word_spacing 2 + 5 4
+ *
+ * Encode content as an array of content items, terminated with a blank entry.
+ *
+ * content 2 sizeof(ptr)
+ *
+ * Encode counter_increment as an array of name, value pairs, terminated with a
+ * blank entry.
+ *
+ * counter_increment 1 sizeof(ptr)
+ *
+ * Encode counter_reset as an array of name, value pairs, terminated with a
+ * blank entry.
+ *
+ * counter_reset 1 sizeof(ptr)
+ *
+ * Encode cursor uri(s) as an array of string objects, terminated with a blank
+ * entry
+ *
+ * cursor 5 sizeof(ptr)
+ * --- --- ---
+ * 116 bits 60 + 4sizeof(ptr) bytes
*/
/*
- * orphans 1 4
- * page_break_after 3
- * page_break_before 3
- * page_break_inside 2
- * widows 1 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * orphans 1 4
+ * page_break_after 3
+ * page_break_before 3
+ * page_break_inside 2
+ * widows 1 4
+ *
+ * --- --- ---
+ * 10 bits 8 bytes
*/
/*
- * align_content 3
- * align_items 3
- * align_self 3
- * background_attachment 2
- * background_color 2 4
- * background_image 1 sizeof(ptr)
- * background_position 1 + 10 8
- * background_repeat 3
- * border_bottom_color 2 4
- * border_bottom_style 4
- * border_bottom_width 3 + 5 4
- * border_collapse 2
- * border_left_color 2 4
- * border_left_style 4
- * border_left_width 3 + 5 4
- * border_right_color 2 4
- * border_right_style 4
- * border_right_width 3 + 5 4
- * border_top_color 2 4
- * border_top_style 4
- * border_top_width 3 + 5 4
- * bottom 2 + 5 4
- * box_sizing 2
- * caption_side 2
- * clear 3
- * color 1 4
- * direction 2
- * display 5
- * empty_cells 2
- * flex_basis 2 + 5 4
- * flex_direction 3
- * flex_grow 1 4
- * flex_shrink 1 4
- * flex_wrap 2
- * float 2
- * font_family 3 sizeof(ptr)
- * font_size 4 + 5 4
- * font_style 2
- * font_variant 2
- * font_weight 4
- * height 2 + 5 4
- * justify_content 3
- * left 2 + 5 4
- * line_height 2 + 5 4
- * list_style_image 1 sizeof(ptr)
- * list_style_position 2
- * list_style_type 4
- * margin_bottom 2 + 5 4
- * margin_left 2 + 5 4
- * margin_right 2 + 5 4
- * margin_top 2 + 5 4
- * max_height 2 + 5 4
- * max_width 2 + 5 4
- * min_height 2 + 5 4
- * min_width 2 + 5 4
- * opacity 1 4
- * order 1 4
- * outline_style 4
- * overflow 3
- * padding_bottom 1 + 5 4
- * padding_left 1 + 5 4
- * padding_right 1 + 5 4
- * padding_top 1 + 5 4
- * position 3
- * quotes 1 sizeof(ptr)
- * right 2 + 5 4
- * table_layout 2
- * text_align 4
- * text_decoration 5
- * text_indent 1 + 5 4
- * text_transform 3
- * top 2 + 5 4
- * unicode_bidi 2
- * vertical_align 4 + 5 4
- * visibility 2
- * white_space 3
- * width 2 + 5 4
- * z_index 2 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * align_content 3
+ * align_items 3
+ * align_self 3
+ * background_attachment 2
+ * background_color 2 4
+ * background_image 1 sizeof(ptr)
+ * background_position 1 + 10 8
+ * background_repeat 3
+ * border_bottom_color 2 4
+ * border_bottom_style 4
+ * border_bottom_width 3 + 5 4
+ * border_collapse 2
+ * border_left_color 2 4
+ * border_left_style 4
+ * border_left_width 3 + 5 4
+ * border_right_color 2 4
+ * border_right_style 4
+ * border_right_width 3 + 5 4
+ * border_top_color 2 4
+ * border_top_style 4
+ * border_top_width 3 + 5 4
+ * bottom 2 + 5 4
+ * box_sizing 2
+ * caption_side 2
+ * clear 3
+ * color 1 4
+ * direction 2
+ * display 5
+ * empty_cells 2
+ * flex_basis 2 + 5 4
+ * flex_direction 3
+ * flex_grow 1 4
+ * flex_shrink 1 4
+ * flex_wrap 2
+ * float 2
+ * font_size 4 + 5 4
+ * font_style 2
+ * font_variant 2
+ * font_weight 4
+ * height 2 + 5 4
+ * justify_content 3
+ * left 2 + 5 4
+ * line_height 2 + 5 4
+ * list_style_image 1 sizeof(ptr)
+ * list_style_position 2
+ * list_style_type 4
+ * margin_bottom 2 + 5 4
+ * margin_left 2 + 5 4
+ * margin_right 2 + 5 4
+ * margin_top 2 + 5 4
+ * max_height 2 + 5 4
+ * max_width 2 + 5 4
+ * min_height 2 + 5 4
+ * min_width 2 + 5 4
+ * opacity 1 4
+ * order 1 4
+ * outline_style 4
+ * overflow 3
+ * padding_bottom 1 + 5 4
+ * padding_left 1 + 5 4
+ * padding_right 1 + 5 4
+ * padding_top 1 + 5 4
+ * position 3
+ * right 2 + 5 4
+ * table_layout 2
+ * text_align 4
+ * text_decoration 5
+ * text_indent 1 + 5 4
+ * text_transform 3
+ * top 2 + 5 4
+ * unicode_bidi 2
+ * vertical_align 4 + 5 4
+ * visibility 2
+ * white_space 3
+ * width 2 + 5 4
+ * z_index 2 4
+ *
+ * Encode font family as an array of string objects, terminated with a blank
+ * entry.
+ *
+ * font_family 3 sizeof(ptr)
+ *
+ * Encode quotes as an array of string objects, terminated with a blank entry.
+ *
+ * quotes 1 sizeof(ptr)
+ * --- --- ---
+ * 329 bits 160 + 4sizeof(ptr) bytes
*/
/**
* Take a new reference to a computed style
*
* \param style The style to take a new reference to.
- *
eturn The new computed style reference
+ * \return The new computed style reference
*/
static inline css_computed_style * css__computed_style_ref(
css_computed_style *style)
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 27b2dc9..e63dc8b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -121,7 +121,7 @@ uncommon = {
('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
- ('clip', 6, ('length, length, length, length'),
+ ('clip', 6, ('length', 'length', 'length', 'length'),
'CSS_CLIP_RECT', None, None, ('get', 'set')),
('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index a1af7a5..31fe613 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -12,6 +12,9 @@ class Text:
self._comment = False
self._indent = 0
+ name_width = 31
+ bits_width = 16
+
def indent(self, value, absolute=False):
if absolute:
self._indent = value
@@ -25,11 +28,16 @@ class Text:
self._comment = not comm
def append(self, text=None, pre_formatted=False):
- if text is None:
+ if not text:
self._lines.append('\t' * self._indent + ' * '
if self._comment else '')
return
+ if isinstance(text, list):
+ for t in text:
+ self.append(t, pre_formatted)
+ return
+
if pre_formatted:
self._lines.append(text)
return
@@ -46,7 +54,7 @@ class Text:
line += text
text = ''
else:
- break_index = text[:text[:column_max - prefix_size].rfind(' ')]
+ break_index = text[:column_max - prefix_size].rfind(' ')
line += text[:break_index].rstrip()
text = text[break_index:].lstrip()
self._lines.append(line)
@@ -57,6 +65,16 @@ class Text:
if multiline:
self._indent(-2)
+ def table_line(self):
+ self.append('{0:{n}}{0:{b}}{0}'.format(
+ '---', n=self.name_width, b=self.bits_width))
+
+ def table_header(self):
+ self.append('{:{n}}{:{b}}{}'.format(
+ 'Property', 'Size (bits)', 'Size (bytes)',
+ n=self.name_width, b=self.bits_width))
+ self.table_line()
+
def to_string(self):
return '\n'.join(self._lines)
@@ -108,15 +126,24 @@ class CSSProperty:
if v.bits is not None ])
@property
+ def bytes_size(self):
+ return sum([ v.size for v in self.values if v.size is not None ])
+
+ @property
+ def ptr_size(self):
+ return sum([ 1 for v in self.values if v.size is None ])
+
+ @property
def size_line(self):
- name = '{:31}'.format(self.name)
- type_size = str(self.type_size)
+ name = '{:{width}}'.format(self.name, width=Text.name_width)
+ type_size = '{:>3}'.format(str(self.type_size))
extra_size = sum([ v.bits['size'] for v in self.values
if v.bits is not None ])
- bits_size = '{:16}'.format(type_size +
- (' + ' + str(extra_size) if extra_size else ''))
- vars_size = sum([ v.size for v in self.values if v.size is not None ])
- vars_size = str(vars_size) if vars_size else ''
+ bits_size = '{:{width}}'.format(type_size +
+ (' + ' + str(extra_size) if extra_size else ''),
+ width=Text.bits_width)
+ vars_size = '{:>3}'.format(
+ str(self.bytes_size)) if self.bytes_size else ''
ptr = ''
for v in self.values:
if v.size is None:
@@ -145,6 +172,18 @@ class CSSGroup:
self.__bits_array = None
@property
+ def bits_size(self):
+ return sum([ p.bits_size for p in self.props ])
+
+ @property
+ def bytes_size(self):
+ return sum([ p.bytes_size for p in self.props ])
+
+ @property
+ def ptr_size(self):
+ return sum([ p.ptr_size for p in self.props ])
+
+ @property
def bits_array(self):
'''Implements a `best fit first` heuristics for the bin packing of
property bits in the bits array'''
@@ -173,9 +212,23 @@ class CSSGroup:
t = Text()
t.append()
t.comment()
+ commented = []
+ t.table_header()
for prop in sorted(self.props, key=(lambda x: x.name)):
- t.append(prop.size_line)
+ if prop.comments is None:
+ t.append(prop.size_line)
+ else:
+ commented.extend(( '', prop.comments, '', prop.size_line ))
+ t.append(commented)
+ t.table_line()
+ t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
+ str(self.bits_size), ' bits', str(self.bytes_size),
+ ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+ if self.ptr_size else '',
+ ' bytes',
+ len_1=Text.name_width, len_2=(Text.bits_width - 3)))
t.comment()
+
return t.to_string()
def make_text(self, filename):
@@ -187,7 +240,7 @@ class CSSGroup:
css_groups = [ CSSGroup(g) for g in groups['others'] ]
css_groups.append(CSSGroup(groups['main'], is_main=True))
-for k, v in assets:
+for k, v in assets.items():
# Key is filename string (e.g. "computed.h") without autogenerated_ prefix
body = '\n'.join([ g.make_text(k) for g in css_groups ])
text = '\n'.join([ v['header'], body, v['footer'] ])
-----------------------------------------------------------------------
Summary of changes:
src/select/__pycache__/assets.cpython-36.pyc | Bin 1375 -> 1398 bytes
.../__pycache__/select_config.cpython-36.pyc | Bin 6502 -> 6490 bytes
src/select/assets.py | 2 +-
src/select/autogenerated_computed.h | 245 +++++++++++---------
src/select/select_config.py | 2 +-
src/select/select_generator.py | 73 +++++-
6 files changed, 205 insertions(+), 117 deletions(-)
diff --git a/src/select/__pycache__/assets.cpython-36.pyc b/src/select/__pycache__/assets.cpython-36.pyc
index f7b7da8..9b622ce 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc b/src/select/__pycache__/select_config.cpython-36.pyc
index bcda842..55e01f8 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 33982b0..91bf92a 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -29,7 +29,7 @@ assets['computed.h']['footer'] = '''\
* Take a new reference to a computed style
*
* \param style The style to take a new reference to.
- * \return The new computed style reference
+ * \\return The new computed style reference
*/
static inline css_computed_style * css__computed_style_ref(
css_computed_style *style)
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index 76a6b32..a76c528 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -14,122 +14,157 @@
/*
- * border_spacing 1 + 10 8
- * break_after 4
- * break_before 4
- * break_inside 4
- * clip 6
- * column_count 2 4
- * column_fill 2
- * column_gap 2 + 5 4
- * column_rule_color 2 4
- * column_rule_style 4
- * column_rule_width 3 + 5 4
- * column_span 2
- * column_width 2 + 5 4
- * content 2 sizeof(ptr)
- * counter_increment 1 sizeof(ptr)
- * counter_reset 1 sizeof(ptr)
- * cursor 5 sizeof(ptr)
- * letter_spacing 2 + 5 4
- * outline_color 2 4
- * outline_width 3 + 5 4
- * word_spacing 2 + 5 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * border_spacing 1 + 10 8
+ * break_after 4
+ * break_before 4
+ * break_inside 4
+ * clip 6 + 20 16
+ * column_count 2 4
+ * column_fill 2
+ * column_gap 2 + 5 4
+ * column_rule_color 2 4
+ * column_rule_style 4
+ * column_rule_width 3 + 5 4
+ * column_span 2
+ * column_width 2 + 5 4
+ * letter_spacing 2 + 5 4
+ * outline_color 2 4
+ * outline_width 3 + 5 4
+ * word_spacing 2 + 5 4
+ *
+ * Encode content as an array of content items, terminated with a blank entry.
+ *
+ * content 2 sizeof(ptr)
+ *
+ * Encode counter_increment as an array of name, value pairs, terminated with a
+ * blank entry.
+ *
+ * counter_increment 1 sizeof(ptr)
+ *
+ * Encode counter_reset as an array of name, value pairs, terminated with a
+ * blank entry.
+ *
+ * counter_reset 1 sizeof(ptr)
+ *
+ * Encode cursor uri(s) as an array of string objects, terminated with a blank
+ * entry
+ *
+ * cursor 5 sizeof(ptr)
+ * --- --- ---
+ * 116 bits 60 + 4sizeof(ptr) bytes
*/
/*
- * orphans 1 4
- * page_break_after 3
- * page_break_before 3
- * page_break_inside 2
- * widows 1 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * orphans 1 4
+ * page_break_after 3
+ * page_break_before 3
+ * page_break_inside 2
+ * widows 1 4
+ *
+ * --- --- ---
+ * 10 bits 8 bytes
*/
/*
- * align_content 3
- * align_items 3
- * align_self 3
- * background_attachment 2
- * background_color 2 4
- * background_image 1 sizeof(ptr)
- * background_position 1 + 10 8
- * background_repeat 3
- * border_bottom_color 2 4
- * border_bottom_style 4
- * border_bottom_width 3 + 5 4
- * border_collapse 2
- * border_left_color 2 4
- * border_left_style 4
- * border_left_width 3 + 5 4
- * border_right_color 2 4
- * border_right_style 4
- * border_right_width 3 + 5 4
- * border_top_color 2 4
- * border_top_style 4
- * border_top_width 3 + 5 4
- * bottom 2 + 5 4
- * box_sizing 2
- * caption_side 2
- * clear 3
- * color 1 4
- * direction 2
- * display 5
- * empty_cells 2
- * flex_basis 2 + 5 4
- * flex_direction 3
- * flex_grow 1 4
- * flex_shrink 1 4
- * flex_wrap 2
- * float 2
- * font_family 3 sizeof(ptr)
- * font_size 4 + 5 4
- * font_style 2
- * font_variant 2
- * font_weight 4
- * height 2 + 5 4
- * justify_content 3
- * left 2 + 5 4
- * line_height 2 + 5 4
- * list_style_image 1 sizeof(ptr)
- * list_style_position 2
- * list_style_type 4
- * margin_bottom 2 + 5 4
- * margin_left 2 + 5 4
- * margin_right 2 + 5 4
- * margin_top 2 + 5 4
- * max_height 2 + 5 4
- * max_width 2 + 5 4
- * min_height 2 + 5 4
- * min_width 2 + 5 4
- * opacity 1 4
- * order 1 4
- * outline_style 4
- * overflow 3
- * padding_bottom 1 + 5 4
- * padding_left 1 + 5 4
- * padding_right 1 + 5 4
- * padding_top 1 + 5 4
- * position 3
- * quotes 1 sizeof(ptr)
- * right 2 + 5 4
- * table_layout 2
- * text_align 4
- * text_decoration 5
- * text_indent 1 + 5 4
- * text_transform 3
- * top 2 + 5 4
- * unicode_bidi 2
- * vertical_align 4 + 5 4
- * visibility 2
- * white_space 3
- * width 2 + 5 4
- * z_index 2 4
+ * Property Size (bits) Size (bytes)
+ * --- --- ---
+ * align_content 3
+ * align_items 3
+ * align_self 3
+ * background_attachment 2
+ * background_color 2 4
+ * background_image 1 sizeof(ptr)
+ * background_position 1 + 10 8
+ * background_repeat 3
+ * border_bottom_color 2 4
+ * border_bottom_style 4
+ * border_bottom_width 3 + 5 4
+ * border_collapse 2
+ * border_left_color 2 4
+ * border_left_style 4
+ * border_left_width 3 + 5 4
+ * border_right_color 2 4
+ * border_right_style 4
+ * border_right_width 3 + 5 4
+ * border_top_color 2 4
+ * border_top_style 4
+ * border_top_width 3 + 5 4
+ * bottom 2 + 5 4
+ * box_sizing 2
+ * caption_side 2
+ * clear 3
+ * color 1 4
+ * direction 2
+ * display 5
+ * empty_cells 2
+ * flex_basis 2 + 5 4
+ * flex_direction 3
+ * flex_grow 1 4
+ * flex_shrink 1 4
+ * flex_wrap 2
+ * float 2
+ * font_size 4 + 5 4
+ * font_style 2
+ * font_variant 2
+ * font_weight 4
+ * height 2 + 5 4
+ * justify_content 3
+ * left 2 + 5 4
+ * line_height 2 + 5 4
+ * list_style_image 1 sizeof(ptr)
+ * list_style_position 2
+ * list_style_type 4
+ * margin_bottom 2 + 5 4
+ * margin_left 2 + 5 4
+ * margin_right 2 + 5 4
+ * margin_top 2 + 5 4
+ * max_height 2 + 5 4
+ * max_width 2 + 5 4
+ * min_height 2 + 5 4
+ * min_width 2 + 5 4
+ * opacity 1 4
+ * order 1 4
+ * outline_style 4
+ * overflow 3
+ * padding_bottom 1 + 5 4
+ * padding_left 1 + 5 4
+ * padding_right 1 + 5 4
+ * padding_top 1 + 5 4
+ * position 3
+ * right 2 + 5 4
+ * table_layout 2
+ * text_align 4
+ * text_decoration 5
+ * text_indent 1 + 5 4
+ * text_transform 3
+ * top 2 + 5 4
+ * unicode_bidi 2
+ * vertical_align 4 + 5 4
+ * visibility 2
+ * white_space 3
+ * width 2 + 5 4
+ * z_index 2 4
+ *
+ * Encode font family as an array of string objects, terminated with a blank
+ * entry.
+ *
+ * font_family 3 sizeof(ptr)
+ *
+ * Encode quotes as an array of string objects, terminated with a blank entry.
+ *
+ * quotes 1 sizeof(ptr)
+ * --- --- ---
+ * 329 bits 160 + 4sizeof(ptr) bytes
*/
/**
* Take a new reference to a computed style
*
* \param style The style to take a new reference to.
- *
eturn The new computed style reference
+ * \return The new computed style reference
*/
static inline css_computed_style * css__computed_style_ref(
css_computed_style *style)
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 27b2dc9..e63dc8b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -121,7 +121,7 @@ uncommon = {
('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
- ('clip', 6, ('length, length, length, length'),
+ ('clip', 6, ('length', 'length', 'length', 'length'),
'CSS_CLIP_RECT', None, None, ('get', 'set')),
('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index a1af7a5..31fe613 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -12,6 +12,9 @@ class Text:
self._comment = False
self._indent = 0
+ name_width = 31
+ bits_width = 16
+
def indent(self, value, absolute=False):
if absolute:
self._indent = value
@@ -25,11 +28,16 @@ class Text:
self._comment = not comm
def append(self, text=None, pre_formatted=False):
- if text is None:
+ if not text:
self._lines.append('\t' * self._indent + ' * '
if self._comment else '')
return
+ if isinstance(text, list):
+ for t in text:
+ self.append(t, pre_formatted)
+ return
+
if pre_formatted:
self._lines.append(text)
return
@@ -46,7 +54,7 @@ class Text:
line += text
text = ''
else:
- break_index = text[:text[:column_max - prefix_size].rfind(' ')]
+ break_index = text[:column_max - prefix_size].rfind(' ')
line += text[:break_index].rstrip()
text = text[break_index:].lstrip()
self._lines.append(line)
@@ -57,6 +65,16 @@ class Text:
if multiline:
self._indent(-2)
+ def table_line(self):
+ self.append('{0:{n}}{0:{b}}{0}'.format(
+ '---', n=self.name_width, b=self.bits_width))
+
+ def table_header(self):
+ self.append('{:{n}}{:{b}}{}'.format(
+ 'Property', 'Size (bits)', 'Size (bytes)',
+ n=self.name_width, b=self.bits_width))
+ self.table_line()
+
def to_string(self):
return '\n'.join(self._lines)
@@ -108,15 +126,24 @@ class CSSProperty:
if v.bits is not None ])
@property
+ def bytes_size(self):
+ return sum([ v.size for v in self.values if v.size is not None ])
+
+ @property
+ def ptr_size(self):
+ return sum([ 1 for v in self.values if v.size is None ])
+
+ @property
def size_line(self):
- name = '{:31}'.format(self.name)
- type_size = str(self.type_size)
+ name = '{:{width}}'.format(self.name, width=Text.name_width)
+ type_size = '{:>3}'.format(str(self.type_size))
extra_size = sum([ v.bits['size'] for v in self.values
if v.bits is not None ])
- bits_size = '{:16}'.format(type_size +
- (' + ' + str(extra_size) if extra_size else ''))
- vars_size = sum([ v.size for v in self.values if v.size is not None ])
- vars_size = str(vars_size) if vars_size else ''
+ bits_size = '{:{width}}'.format(type_size +
+ (' + ' + str(extra_size) if extra_size else ''),
+ width=Text.bits_width)
+ vars_size = '{:>3}'.format(
+ str(self.bytes_size)) if self.bytes_size else ''
ptr = ''
for v in self.values:
if v.size is None:
@@ -145,6 +172,18 @@ class CSSGroup:
self.__bits_array = None
@property
+ def bits_size(self):
+ return sum([ p.bits_size for p in self.props ])
+
+ @property
+ def bytes_size(self):
+ return sum([ p.bytes_size for p in self.props ])
+
+ @property
+ def ptr_size(self):
+ return sum([ p.ptr_size for p in self.props ])
+
+ @property
def bits_array(self):
'''Implements a `best fit first` heuristics for the bin packing of
property bits in the bits array'''
@@ -173,9 +212,23 @@ class CSSGroup:
t = Text()
t.append()
t.comment()
+ commented = []
+ t.table_header()
for prop in sorted(self.props, key=(lambda x: x.name)):
- t.append(prop.size_line)
+ if prop.comments is None:
+ t.append(prop.size_line)
+ else:
+ commented.extend(( '', prop.comments, '', prop.size_line ))
+ t.append(commented)
+ t.table_line()
+ t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
+ str(self.bits_size), ' bits', str(self.bytes_size),
+ ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+ if self.ptr_size else '',
+ ' bytes',
+ len_1=Text.name_width, len_2=(Text.bits_width - 3)))
t.comment()
+
return t.to_string()
def make_text(self, filename):
@@ -187,7 +240,7 @@ class CSSGroup:
css_groups = [ CSSGroup(g) for g in groups['others'] ]
css_groups.append(CSSGroup(groups['main'], is_main=True))
-for k, v in assets:
+for k, v in assets.items():
# Key is filename string (e.g. "computed.h") without autogenerated_ prefix
body = '\n'.join([ g.make_text(k) for g in css_groups ])
text = '\n'.join([ v['header'], body, v['footer'] ])
--
Cascading Style Sheets library
5 years, 4 months
netsurf: branch master updated. release/3.7-22-g0469775
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/046977507b891d9e91a14...
...commit http://git.netsurf-browser.org/netsurf.git/commit/046977507b891d9e91a1467...
...tree http://git.netsurf-browser.org/netsurf.git/tree/046977507b891d9e91a14677c...
The branch, master has been updated
via 046977507b891d9e91a14677cb474dce4cad0b7c (commit)
from 8f73414c0655098c3ae6488540e07cca31999676 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=046977507b891d9e91a...
commit 046977507b891d9e91a14677cb474dce4cad0b7c
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Duktape: Squash -Wcast-align warnings on armhf.
diff --git a/content/handlers/javascript/duktape/duktape.c b/content/handlers/javascript/duktape/duktape.c
index 3139b69..52b9e13 100644
--- a/content/handlers/javascript/duktape/duktape.c
+++ b/content/handlers/javascript/duktape/duktape.c
@@ -4219,6 +4219,9 @@ DUK_INTERNAL_DECL void duk_regexp_match_force_global(duk_hthread *thr); /* hack
/* XXX: macro for shared header fields (avoids some padding issues) */
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(push, 8)
+#endif
struct duk_heaphdr {
duk_uint32_t h_flags;
@@ -4264,7 +4267,16 @@ struct duk_heaphdr {
#if defined(DUK_USE_HEAPPTR16)
duk_uint16_t h_extra16;
#endif
-};
+}
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_GCC_ATTR)
+__attribute__ ((aligned (8)))
+#elif (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_CLANG_ATTR)
+__attribute__ ((aligned (8)))
+#endif
+;
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(pop)
+#endif
struct duk_heaphdr_string {
/* 16 bits would be enough for shared heaphdr flags and duk_hstring
@@ -5733,6 +5745,9 @@ DUK_INTERNAL_DECL duk_double_t duk_time_get_monotonic_time(duk_hthread *thr);
* Misc
*/
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(push, 8)
+#endif
struct duk_hstring {
/* Smaller heaphdr than for other objects, because strings are held
* in string intern table which requires no link pointers. Much of
@@ -5777,7 +5792,16 @@ struct duk_hstring {
* for strings, but fields above should guarantee alignment-by-4
* (but not alignment-by-8).
*/
-};
+}
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_GCC_ATTR)
+__attribute__ ((aligned (8)))
+#elif (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_CLANG_ATTR)
+__attribute__ ((aligned (8)))
+#endif
+;
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(pop)
+#endif
/* The external string struct is defined even when the feature is inactive. */
struct duk_hstring_external {
-----------------------------------------------------------------------
Summary of changes:
content/handlers/javascript/duktape/duktape.c | 28 +++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/content/handlers/javascript/duktape/duktape.c b/content/handlers/javascript/duktape/duktape.c
index 3139b69..52b9e13 100644
--- a/content/handlers/javascript/duktape/duktape.c
+++ b/content/handlers/javascript/duktape/duktape.c
@@ -4219,6 +4219,9 @@ DUK_INTERNAL_DECL void duk_regexp_match_force_global(duk_hthread *thr); /* hack
/* XXX: macro for shared header fields (avoids some padding issues) */
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(push, 8)
+#endif
struct duk_heaphdr {
duk_uint32_t h_flags;
@@ -4264,7 +4267,16 @@ struct duk_heaphdr {
#if defined(DUK_USE_HEAPPTR16)
duk_uint16_t h_extra16;
#endif
-};
+}
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_GCC_ATTR)
+__attribute__ ((aligned (8)))
+#elif (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_CLANG_ATTR)
+__attribute__ ((aligned (8)))
+#endif
+;
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(pop)
+#endif
struct duk_heaphdr_string {
/* 16 bits would be enough for shared heaphdr flags and duk_hstring
@@ -5733,6 +5745,9 @@ DUK_INTERNAL_DECL duk_double_t duk_time_get_monotonic_time(duk_hthread *thr);
* Misc
*/
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(push, 8)
+#endif
struct duk_hstring {
/* Smaller heaphdr than for other objects, because strings are held
* in string intern table which requires no link pointers. Much of
@@ -5777,7 +5792,16 @@ struct duk_hstring {
* for strings, but fields above should guarantee alignment-by-4
* (but not alignment-by-8).
*/
-};
+}
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_GCC_ATTR)
+__attribute__ ((aligned (8)))
+#elif (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_CLANG_ATTR)
+__attribute__ ((aligned (8)))
+#endif
+;
+#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)
+#pragma pack(pop)
+#endif
/* The external string struct is defined even when the feature is inactive. */
struct duk_hstring_external {
--
NetSurf Browser
5 years, 4 months
libcss: branch lcneves/units updated. release/0.7.0-24-g41cee64
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/41cee64272bed090f3b215...
...commit http://git.netsurf-browser.org/libcss.git/commit/41cee64272bed090f3b2151c...
...tree http://git.netsurf-browser.org/libcss.git/tree/41cee64272bed090f3b2151ce0...
The branch, lcneves/units has been updated
via 41cee64272bed090f3b2151ce00b00c3c89222f1 (commit)
from ae14e8b9dd656a59d1013b977b8e2057825624b7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=41cee64272bed090f3b2...
commit 41cee64272bed090f3b2151ce00b00c3c89222f1
Author: Lucas Neves <lcneves(a)gmail.com>
Commit: Lucas Neves <lcneves(a)gmail.com>
WIP: Select: autogen for selection properties.
diff --git a/src/select/assets.py b/src/select/assets.py
index 1d726a3..33982b0 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -3,10 +3,7 @@
# http://www.opensource.org/licenses/mit-license.php
# Copyright 2017 Lucas Neves <lcneves(a)gmail.com>
-assets = {}
-
-assets['computed.h'] = {}
-assets['computed.h']['header'] = '''\
+copyright = '''\
/*
* This file is part of LibCSS
* Licensed under the MIT License,
@@ -14,6 +11,12 @@ assets['computed.h']['header'] = '''\
* Copyright 2017 The NetSurf Project
*/
+'''
+
+assets = {}
+
+assets['computed.h'] = {}
+assets['computed.h']['header'] = copyright + '''\
#ifndef css_select_computed_h_
#define css_select_computed_h_
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 3e6744c..a1af7a5 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -6,17 +6,6 @@
from select_config import values, groups
from assets import assets
-class Bin:
- def __init__(self, first_object):
- self.contents = [ first_object ]
-
- @property
- def size(self):
- return sum([ x['size'] for x in self.contents ])
-
- def push(self, obj):
- self.contents.append(obj)
-
class Text:
def __init__(self):
self._lines = []
@@ -137,32 +126,48 @@ class CSSProperty:
return (name + bits_size + vars_size +
(' + ' if vars_size and ptr else '') + ptr)
+class Bin:
+ def __init__(self, first_object):
+ self.contents = [ first_object ]
+
+ @property
+ def size(self):
+ return sum([ x['size'] for x in self.contents ])
+
+ def push(self, obj):
+ self.contents.append(obj)
+
class CSSGroup:
def __init__(self, config, is_main=False):
self.name = config['name']
self.props = [ CSSProperty(*x) for x in config['props'] ]
self.is_main = is_main
+ self.__bits_array = None
@property
- def bit_map(self):
+ def bits_array(self):
'''Implements a `best fit first` heuristics for the bin packing of
property bits in the bits array'''
+ if self.__bits_array is not None:
+ return self.__bits_array
+
bin_size = 32
- bit_map = []
+ self.__bits_array = []
props = sorted([ { 'name': p.name, 'size': p.bits_size }
for p in self.props ], key=(lambda x: x['size']), reverse=True)
for p in props:
- for b in bit_map:
+ for b in self.__bits_array:
if b.size + p['size'] <= bin_size:
b.push(p)
break
else:
- bit_map.append(Bin(p))
- bit_map.sort(key=(lambda x: x.size), reverse=True)
+ self.__bits_array.append(Bin(p))
+
+ self.__bits_array.sort(key=(lambda x: x.size), reverse=True)
- return bit_map
+ return self.__bits_array
def make_computed_h(self):
t = Text()
@@ -179,15 +184,12 @@ class CSSGroup:
else:
raise ValueError()
-def write_file(self, filename, data):
- self._lines.append('')
-
css_groups = [ CSSGroup(g) for g in groups['others'] ]
css_groups.append(CSSGroup(groups['main'], is_main=True))
-files = ['computed.h']
-for f in files:
- body = '\n'.join([ x.make_text(f) for x in css_groups ])
- text = '\n'.join([ assets[f]['header'], body, assets[f]['footer'] ])
- with open('autogenerated_' + f, 'w') as file_f:
- file_f.write(text)
+for k, v in assets:
+ # Key is filename string (e.g. "computed.h") without autogenerated_ prefix
+ body = '\n'.join([ g.make_text(k) for g in css_groups ])
+ text = '\n'.join([ v['header'], body, v['footer'] ])
+ with open('autogenerated_' + k, 'w') as file_k:
+ file_k.write(text)
-----------------------------------------------------------------------
Summary of changes:
src/select/assets.py | 11 +++++---
src/select/select_generator.py | 54 +++++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/src/select/assets.py b/src/select/assets.py
index 1d726a3..33982b0 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -3,10 +3,7 @@
# http://www.opensource.org/licenses/mit-license.php
# Copyright 2017 Lucas Neves <lcneves(a)gmail.com>
-assets = {}
-
-assets['computed.h'] = {}
-assets['computed.h']['header'] = '''\
+copyright = '''\
/*
* This file is part of LibCSS
* Licensed under the MIT License,
@@ -14,6 +11,12 @@ assets['computed.h']['header'] = '''\
* Copyright 2017 The NetSurf Project
*/
+'''
+
+assets = {}
+
+assets['computed.h'] = {}
+assets['computed.h']['header'] = copyright + '''\
#ifndef css_select_computed_h_
#define css_select_computed_h_
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 3e6744c..a1af7a5 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -6,17 +6,6 @@
from select_config import values, groups
from assets import assets
-class Bin:
- def __init__(self, first_object):
- self.contents = [ first_object ]
-
- @property
- def size(self):
- return sum([ x['size'] for x in self.contents ])
-
- def push(self, obj):
- self.contents.append(obj)
-
class Text:
def __init__(self):
self._lines = []
@@ -137,32 +126,48 @@ class CSSProperty:
return (name + bits_size + vars_size +
(' + ' if vars_size and ptr else '') + ptr)
+class Bin:
+ def __init__(self, first_object):
+ self.contents = [ first_object ]
+
+ @property
+ def size(self):
+ return sum([ x['size'] for x in self.contents ])
+
+ def push(self, obj):
+ self.contents.append(obj)
+
class CSSGroup:
def __init__(self, config, is_main=False):
self.name = config['name']
self.props = [ CSSProperty(*x) for x in config['props'] ]
self.is_main = is_main
+ self.__bits_array = None
@property
- def bit_map(self):
+ def bits_array(self):
'''Implements a `best fit first` heuristics for the bin packing of
property bits in the bits array'''
+ if self.__bits_array is not None:
+ return self.__bits_array
+
bin_size = 32
- bit_map = []
+ self.__bits_array = []
props = sorted([ { 'name': p.name, 'size': p.bits_size }
for p in self.props ], key=(lambda x: x['size']), reverse=True)
for p in props:
- for b in bit_map:
+ for b in self.__bits_array:
if b.size + p['size'] <= bin_size:
b.push(p)
break
else:
- bit_map.append(Bin(p))
- bit_map.sort(key=(lambda x: x.size), reverse=True)
+ self.__bits_array.append(Bin(p))
+
+ self.__bits_array.sort(key=(lambda x: x.size), reverse=True)
- return bit_map
+ return self.__bits_array
def make_computed_h(self):
t = Text()
@@ -179,15 +184,12 @@ class CSSGroup:
else:
raise ValueError()
-def write_file(self, filename, data):
- self._lines.append('')
-
css_groups = [ CSSGroup(g) for g in groups['others'] ]
css_groups.append(CSSGroup(groups['main'], is_main=True))
-files = ['computed.h']
-for f in files:
- body = '\n'.join([ x.make_text(f) for x in css_groups ])
- text = '\n'.join([ assets[f]['header'], body, assets[f]['footer'] ])
- with open('autogenerated_' + f, 'w') as file_f:
- file_f.write(text)
+for k, v in assets:
+ # Key is filename string (e.g. "computed.h") without autogenerated_ prefix
+ body = '\n'.join([ g.make_text(k) for g in css_groups ])
+ text = '\n'.join([ v['header'], body, v['footer'] ])
+ with open('autogenerated_' + k, 'w') as file_k:
+ file_k.write(text)
--
Cascading Style Sheets library
5 years, 4 months
netsurf: branch master updated. release/3.7-21-g8f73414
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8f73414c0655098c3ae64...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8f73414c0655098c3ae6488...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8f73414c0655098c3ae648854...
The branch, master has been updated
via 8f73414c0655098c3ae6488540e07cca31999676 (commit)
from 8cc3adee5aabd3b6ad1c6c897c9c31a8136e61cc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8f73414c0655098c3ae...
commit 8f73414c0655098c3ae6488540e07cca31999676
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Revert "Duktape: Attempt to squash aarch64 cast increases required alignment warnings."
This reverts commit 8cc3adee5aabd3b6ad1c6c897c9c31a8136e61cc.
These warnings don't show up with the CI updated to Debian Stretch.
diff --git a/content/handlers/javascript/duktape/duktape.c b/content/handlers/javascript/duktape/duktape.c
index 5e3b467..3139b69 100644
--- a/content/handlers/javascript/duktape/duktape.c
+++ b/content/handlers/javascript/duktape/duktape.c
@@ -6663,11 +6663,7 @@ struct duk_hobject {
duk_uint32_t h_size; /* hash part size or 0 if unused */
#endif
#endif
-}
-#if (DUK_USE_ALIGN_BY == 8)
-__attribute__ ((aligned (8)))
-#endif
-;
+};
/*
* Exposed data
-----------------------------------------------------------------------
Summary of changes:
content/handlers/javascript/duktape/duktape.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/content/handlers/javascript/duktape/duktape.c b/content/handlers/javascript/duktape/duktape.c
index 5e3b467..3139b69 100644
--- a/content/handlers/javascript/duktape/duktape.c
+++ b/content/handlers/javascript/duktape/duktape.c
@@ -6663,11 +6663,7 @@ struct duk_hobject {
duk_uint32_t h_size; /* hash part size or 0 if unused */
#endif
#endif
-}
-#if (DUK_USE_ALIGN_BY == 8)
-__attribute__ ((aligned (8)))
-#endif
-;
+};
/*
* Exposed data
--
NetSurf Browser
5 years, 4 months
buildsystem: branch tlsa/python-testrunner updated. release/1.6-4-gdb14e3f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/buildsystem.git/shortlog/db14e3fc674ca715f...
...commit http://git.netsurf-browser.org/buildsystem.git/commit/db14e3fc674ca715fbd...
...tree http://git.netsurf-browser.org/buildsystem.git/tree/db14e3fc674ca715fbde7...
The branch, tlsa/python-testrunner has been updated
via db14e3fc674ca715fbde762c743c31ebf82129cb (commit)
from ffc010bc1b8c2c38315b05b63e5bb0f8a72e67bc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/buildsystem.git/commit/?id=db14e3fc674ca71...
commit db14e3fc674ca715fbde762c743c31ebf82129cb
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Python test runner: Convert from Python 2 to Python 3.
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 2dde372..732a962 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -281,7 +281,7 @@ MKDIRFLAGS ?= -p
MV ?= mv
PERL ?= perl
-PYTHON ?= python
+PYTHON ?= python3
PKGCONFIG ?= PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)" pkg-config
diff --git a/testtools/testrunner.py b/testtools/testrunner.py
index 9d3aee8..6648372 100644
--- a/testtools/testrunner.py
+++ b/testtools/testrunner.py
@@ -1,4 +1,4 @@
-#!/bin/python
+#!/usr/bin/python3
#
# Testcase runner for NetSurf projects
#
@@ -13,7 +13,7 @@
import os
import sys
-import Queue
+import queue
import threading
import subprocess
@@ -41,11 +41,11 @@ LOG = open(os.path.join(builddir, "testlog"), "w")
def run_test(test_exe, test_data):
- io_q = Queue.Queue()
+ io_q = queue.Queue()
def output_collector(identifier, stream):
for line in stream:
- io_q.put((identifier, line.rstrip()))
+ io_q.put((identifier, line.decode("utf-8").rstrip()))
if not stream.closed:
stream.close()
@@ -109,7 +109,7 @@ with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
continue
# Found one; decompose
- decomposed = filter(None, line.split('\t'))
+ decomposed = list(filter(None, line.split('\t')))
# Strip whitespace
test = decomposed[0].strip()
@@ -136,7 +136,7 @@ with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
continue
# Found one; decompose
- ddecomposed = filter(None, dline.split('\t'))
+ ddecomposed = list(filter(None, dline.split('\t')))
# Strip whitespace
dtest = ddecomposed[0].strip()
-----------------------------------------------------------------------
Summary of changes:
makefiles/Makefile.tools | 2 +-
testtools/testrunner.py | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 2dde372..732a962 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -281,7 +281,7 @@ MKDIRFLAGS ?= -p
MV ?= mv
PERL ?= perl
-PYTHON ?= python
+PYTHON ?= python3
PKGCONFIG ?= PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)" pkg-config
diff --git a/testtools/testrunner.py b/testtools/testrunner.py
index 9d3aee8..6648372 100644
--- a/testtools/testrunner.py
+++ b/testtools/testrunner.py
@@ -1,4 +1,4 @@
-#!/bin/python
+#!/usr/bin/python3
#
# Testcase runner for NetSurf projects
#
@@ -13,7 +13,7 @@
import os
import sys
-import Queue
+import queue
import threading
import subprocess
@@ -41,11 +41,11 @@ LOG = open(os.path.join(builddir, "testlog"), "w")
def run_test(test_exe, test_data):
- io_q = Queue.Queue()
+ io_q = queue.Queue()
def output_collector(identifier, stream):
for line in stream:
- io_q.put((identifier, line.rstrip()))
+ io_q.put((identifier, line.decode("utf-8").rstrip()))
if not stream.closed:
stream.close()
@@ -109,7 +109,7 @@ with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
continue
# Found one; decompose
- decomposed = filter(None, line.split('\t'))
+ decomposed = list(filter(None, line.split('\t')))
# Strip whitespace
test = decomposed[0].strip()
@@ -136,7 +136,7 @@ with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
continue
# Found one; decompose
- ddecomposed = filter(None, dline.split('\t'))
+ ddecomposed = list(filter(None, dline.split('\t')))
# Strip whitespace
dtest = ddecomposed[0].strip()
--
NetSurf Project build system
5 years, 4 months
buildsystem: branch tlsa/python-testrunner updated. release/1.6-3-gffc010b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/buildsystem.git/shortlog/ffc010bc1b8c2c383...
...commit http://git.netsurf-browser.org/buildsystem.git/commit/ffc010bc1b8c2c38315...
...tree http://git.netsurf-browser.org/buildsystem.git/tree/ffc010bc1b8c2c38315b0...
The branch, tlsa/python-testrunner has been updated
via ffc010bc1b8c2c38315b05b63e5bb0f8a72e67bc (commit)
from c0152aae2d6741799a60782c56d4988b935275d1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/buildsystem.git/commit/?id=ffc010bc1b8c2c3...
commit ffc010bc1b8c2c38315b05b63e5bb0f8a72e67bc
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Python test runner: Don't need NULL in the Python version.
diff --git a/testtools/testrunner.py b/testtools/testrunner.py
index a2d3c3c..9d3aee8 100644
--- a/testtools/testrunner.py
+++ b/testtools/testrunner.py
@@ -38,7 +38,6 @@ if len(sys.argv) > 4:
# Open log file and /dev/null
LOG = open(os.path.join(builddir, "testlog"), "w")
-NULL = open(os.devnull, "r+")
def run_test(test_exe, test_data):
-----------------------------------------------------------------------
Summary of changes:
testtools/testrunner.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/testtools/testrunner.py b/testtools/testrunner.py
index a2d3c3c..9d3aee8 100644
--- a/testtools/testrunner.py
+++ b/testtools/testrunner.py
@@ -38,7 +38,6 @@ if len(sys.argv) > 4:
# Open log file and /dev/null
LOG = open(os.path.join(builddir, "testlog"), "w")
-NULL = open(os.devnull, "r+")
def run_test(test_exe, test_data):
--
NetSurf Project build system
5 years, 4 months
buildsystem: branch tlsa/python-testrunner created. release/1.6-2-gc0152aa
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/buildsystem.git/shortlog/c0152aae2d6741799...
...commit http://git.netsurf-browser.org/buildsystem.git/commit/c0152aae2d6741799a6...
...tree http://git.netsurf-browser.org/buildsystem.git/tree/c0152aae2d6741799a607...
The branch, tlsa/python-testrunner has been created
at c0152aae2d6741799a60782c56d4988b935275d1 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/buildsystem.git/commit/?id=c0152aae2d67417...
commit c0152aae2d6741799a60782c56d4988b935275d1
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Buildsystem: Change test tool to the Python implementation.
diff --git a/Makefile b/Makefile
index d1fd44b..e221973 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ MAKEFILES := $(patsubst %,Makefile.%, \
clang gcc norcroft open64 \
)
-TESTTOOLS := testrunner.pl
+TESTTOOLS := testrunner.py
CITOOLS := jenkins-build.sh
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 86fac4c..2dde372 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -281,6 +281,7 @@ MKDIRFLAGS ?= -p
MV ?= mv
PERL ?= perl
+PYTHON ?= python
PKGCONFIG ?= PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)" pkg-config
commitdiff http://git.netsurf-browser.org/buildsystem.git/commit/?id=0b023edcdea4f34...
commit 0b023edcdea4f34822828e8a7fbed503101fcc49
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Testrunner: Add Python implementation of testrunner.pl
diff --git a/testtools/testrunner.py b/testtools/testrunner.py
new file mode 100644
index 0000000..a2d3c3c
--- /dev/null
+++ b/testtools/testrunner.py
@@ -0,0 +1,172 @@
+#!/bin/python
+#
+# Testcase runner for NetSurf projects
+#
+# Usage: testrunner <builddir> <testdir> <prefix> [<executable extension>]
+#
+# Operates upon INDEX files described in the README.
+# Locates and executes testcases, feeding data files to programs
+# as appropriate.
+# Logs testcase output to file.
+# Aborts test sequence on detection of error.
+#
+
+import os
+import sys
+import Queue
+import threading
+import subprocess
+
+global builddir
+global directory
+global prefix
+global exeext
+
+if len(sys.argv) < 4:
+ print("Usage: testrunner.pl <builddir> <testdir> <prefix> [<exeext>]")
+ sys.exit(1)
+
+# Get directories
+builddir = sys.argv[1]
+directory = sys.argv[2]
+prefix = sys.argv[3]
+
+# Get EXE extension (if any)
+exeext = None
+if len(sys.argv) > 4:
+ exeext = sys.argv[4]
+
+# Open log file and /dev/null
+LOG = open(os.path.join(builddir, "testlog"), "w")
+NULL = open(os.devnull, "r+")
+
+
+def run_test(test_exe, test_data):
+ io_q = Queue.Queue()
+
+ def output_collector(identifier, stream):
+ for line in stream:
+ io_q.put((identifier, line.rstrip()))
+
+ if not stream.closed:
+ stream.close()
+
+ # Run the test
+ proc = subprocess.Popen([test_exe, test_data],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ # Threads for sticking output into queue
+ tout = threading.Thread(target=output_collector, name='stdout-watcher',
+ args=('STDOUT', proc.stdout))
+ terr = threading.Thread(target=output_collector, name='stderr-watcher',
+ args=('STDERR', proc.stderr))
+
+ tout.start()
+ terr.start()
+
+ # Wait for test to finish
+ ret = proc.wait()
+
+ # And join the output collector threads
+ tout.join()
+ terr.join()
+
+ # If last line of STDOUT is "PASS", then the test passed
+ last_line = None
+
+ # The STDERR output is just collected up and put at the end of LOG
+ error_lines = []
+
+ while not io_q.empty():
+ identifier, line = io_q.get()
+ if identifier == "STDOUT":
+ LOG.write("%s\n" % line)
+ last_line = line
+ else:
+ error_lines += line
+
+ # Check for test process returning error
+ if ret != 0:
+ LOG.write(" FAIL: Exit status %i\n" % ret)
+ last_line = "FAIL"
+
+ # Dump stderr to log
+ for error_line in error_lines:
+ LOG.write("%s\n" % line)
+
+ if not last_line == "PASS":
+ last_line = "FAIL"
+
+ # Print rest result
+ print(last_line)
+ return
+
+# Open testcase index
+with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
+ # Parse testcase index, looking for testcases
+ for line in TINDEX:
+ # Skip comments
+ if line[0] == '#' or line.isspace():
+ continue
+
+ # Found one; decompose
+ decomposed = filter(None, line.split('\t'))
+
+ # Strip whitespace
+ test = decomposed[0].strip()
+ desc = decomposed[1].strip()
+ data = None
+ if len(decomposed) > 2:
+ data = decomposed[2].strip()
+
+ # Append prefix & EXE extension to binary name
+ test = prefix + test
+ if exeext:
+ test += exeext
+
+ print("Test: " + desc)
+
+ if data:
+ # Testcase has external data files
+
+ # Open datafile index
+ with open(os.path.join(directory, "data/" + data + "/INDEX"), "r") as DINDEX:
+ # Parse datafile index, looking for datafiles
+ for dline in DINDEX:
+ if dline[0] == '#' or dline.isspace():
+ continue
+
+ # Found one; decompose
+ ddecomposed = filter(None, dline.split('\t'))
+
+ # Strip whitespace
+ dtest = ddecomposed[0].strip()
+ ddesc = ddecomposed[1].strip()
+
+ LOG.write("Running %s %s\n" % (
+ os.path.join(builddir, test),
+ os.path.join(directory, "data/" + data + "/" + dtest)))
+
+ # Make message fit on an 80 column terminal
+ msg = " ==> " + test + " [" + data + "/" + dtest + "]"
+ msg += "." * (80 - len(msg) - 8)
+
+ sys.stdout.write(msg)
+
+ # Run testcase
+ run_test(os.path.join(builddir, test),
+ os.path.join(directory, "data/" + data + "/" + dtest))
+ else:
+ # Testcase has no external data files
+ LOG.write("Running %s\n" % (os.path.join(builddir, test)))
+
+ # Make message fit on an 80 column terminal
+ msg = " ==> " + test
+ msg += "." * (80 - len(msg) - 8)
+
+ sys.stdout.write(msg)
+
+ # Run testcase
+ run_test(os.path.join(builddir, test))
+
+ print("")
-----------------------------------------------------------------------
--
NetSurf Project build system
5 years, 4 months