<commit_before>#
# file: EstdIntrusiveForwardListPrettyPrinter.py
#
# author: Copyright (C) 2017 <NAME> http://www.distortec.com http://www.freddiechopin.info
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
# distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from gdb import lookup_type
from PrettyPrinters.estd.GenericIntrusiveListIterator import GenericIntrusiveListIterator

def isNodeValid(node):
	nextNode = node['nextNode_']
	sizeType = lookup_type('size_t')
	# value of "next" pointer must be  properly aligned
	if nextNode.cast(sizeType) % nextNode.type.sizeof != 0:
		return False
	return True

class EstdIntrusiveForwardListPrettyPrinter:
	'Print estd::IntrusiveForwardList'

	class Iterator(GenericIntrusiveListIterator):
		'Iterate over estd::IntrusiveForwardList'

		def __init__(self, begin, end, nodePointer, u):
			super().__init__(begin, end, isNodeValid, nodePointer, u)

	def __init__(self, value, name = 'estd::IntrusiveForwardList'):
		self.value = value
		self.name = name

	def children(self):
		rootNode = self.value['intrusiveForwardListBase_']['rootNode_']
		if isNodeValid(rootNode) == False:
			return iter([])
		return self.Iterator(rootNode['nextNode_'], 0, self.value.type.template_argument(1),
				self.value.type.template_argument(2).strip_typedefs())

	def display_hint(self):
		# https://bugs.eclipse.org/bugs/show_bug.cgi?id=512795
		return 'array'

	def to_string(self):
		return self.name<commit_msg>Convert isNodeValid() for estd::IntrusiveForwardList to staticmethod<commit_after>#
# file: EstdIntrusiveForwardListPrettyPrinter.py
#
# author: Copyright (C) 2017 <NAME> http://www.distortec.com http://www.freddiechopin.info
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
# distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from gdb import lookup_type
from PrettyPrinters.estd.GenericIntrusiveListIterator import GenericIntrusiveListIterator

class EstdIntrusiveForwardListPrettyPrinter:
	'Print estd::IntrusiveForwardList'

	class Iterator(GenericIntrusiveListIterator):
		'Iterate over estd::IntrusiveForwardList'

		def __init__(self, begin, end, nodePointer, u):
			super().__init__(begin, end, EstdIntrusiveForwardListPrettyPrinter.isNodeValid, nodePointer, u)

	def __init__(self, value, name = 'estd::IntrusiveForwardList'):
		self.value = value
		self.name = name

	def children(self):
		rootNode = self.value['intrusiveForwardListBase_']['rootNode_']
		if EstdIntrusiveForwardListPrettyPrinter.isNodeValid(rootNode) == False:
			return iter([])
		return self.Iterator(rootNode['nextNode_'], 0, self.value.type.template_argument(1),
				self.value.type.template_argument(2).strip_typedefs())

	def display_hint(self):
		# https://bugs.eclipse.org/bugs/show_bug.cgi?id=512795
		return 'array'

	@staticmethod
	def isNodeValid(node):
		nextNode = node['nextNode_']
		sizeType = lookup_type('size_t')
		# value of "next" pointer must be  properly aligned
		if nextNode.cast(sizeType) % nextNode.type.sizeof != 0:
			return False
		return True

	def to_string(self):
		return self.name
{'fraction_non_alphanumeric': 0.11104237550262913, 'fraction_numerical': 0.011135168574079802, 'mean_word_length': 5.480961923847695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3957112', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1028, 'n_words': 257}