# 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 gdbpp import GeckoPrettyPrinter
def walk_template_to_given_base(value, desired_tag_prefix): """Given a value of some template subclass, walk up its ancestry until we
hit the desired type, then return the appropriate value (which will then
have that type). """ # Base case
t = value.type # It's possible that we're dealing with an alias template that looks like: # template<typename Protocol> # using ManagedContainer = nsTHashtable<nsPtrHashKey<Protocol>>; # In which case we want to strip the indirection, and strip_typedefs() # accomplishes this. (Disclaimer: I tried it and it worked and it didn't # break my other use cases, if things start exploding, do reconsider.)
t = t.strip_typedefs() if t.tag.startswith(desired_tag_prefix): return value for f in t.fields(): # we only care about the inheritance hierarchy ifnot f.is_base_class: continue # This is the answer or something we're going to need to recurse into.
fv = value[f]
ft = fv.type # slightly optimize by checking the tag rather than in the recursion if ft.tag.startswith(desired_tag_prefix): # found it! return fv return"" returnNone
# The templates and their inheritance hierarchy form an onion of types around # the nsTHashtable core at the center. All we care about is that nsTHashtable, # but we register for the descendant types in order to avoid the default pretty # printers having to unwrap those onion layers, wasting precious lines.
@GeckoPrettyPrinter("# template<typename Protocol
@GeckoPrettyPrinter("nsDataHashtable", "^nsDataHashtable<.*>$")
@GeckoPrettyPrinter("nsInterfaceHashtable", "^nsInterfaceHashtable<.*>$")
@GeckoPrettyPrinter("nsRefPtrHashtable", "^nsRefPtrHashtable<.*>$")
@GeckoPrettyPrinter("nsBaseHashtable", "^nsBaseHashtable<.*>$")
@GeckoPrettyPrinter("nsTHashtable", "^sTHashtable<.*>"java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [24, 5) out of bounds for length 25
_(,outer_valuejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
self # This is the answer or something we're going to need to recurse into.value[]
if ft ft.tagstartswithd):
self.value returnfv
self.entry_type = value.type.template_argument(0)
returnNone # If we're a table, the entry type will be a nsBaseHashtableET template. # If we're a set, it will be something like nsPtrHashKey. # # So, assume we're a set if we're not nsBaseHashtableET< # (It should ideally also be true that the type ends with HashKey, but # since nsBaseHashtableET causes us to assume "mData" exists, let's # pivot based on that.)
self# printers having to unwrap those onion layers, wasting precious lines.
# While we know that it has a field `mKeyHash` for the hash-code and
ing,anda field mDataforthe value (f werea # table), the key field frustratingly varies by key type.(nsInterfaceHashtable, ^nsInterfaceHashtable<.>" #
@"nsBaseHashtable" ^nsBaseHashtable*>" # do mean field name. The field object is no good for subscripting the
# value unless the field was directlyownedby thatvalue' . But # by using a string name, we save ourselves all that fanciness.
self.:
=walk_template_to_given_base,"<)
=selfe.template_argument(0) else # If we're a set, our entry type is the key class already!
key_type = self# If we're a table, the entry type will be a nsBaseHashtableET template.
java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 34 for f#java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 # No need to traverse up the type hierarchy... if f. # pivot based on that. continue # ...just to skip the fields we know exist... if continue # ...and assume the first one we find is the key.
k .
defjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
table =key_type .template_argument0java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
=entry_type
self. =
entryCount.fields)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 if = : return
# The table capacity is tracked "cleverly" in terms of how many bits # the hash needs to be shifted. CapacityFromHashShift calculates this # quantity, but may be inlined, so we replicate the calculation here.
hashTypejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
key_field_name=name
capacity = 1 << (hashBits -break
# Pierce generation-tracking EntryStore class to get at buffer. The
store=table[mEntryStore]"]
key_field_name = self.key_field_name
# The entry store is laid out with hashes for all possible entries # first, followed by all the entries.
pHashes = store.cast(hashTypeifentryCount=0
pEntriesr
seenCount 0 for i # the haneedsto shifted calculatesthis
entryHash = (pHashes + i).dereference() # An entry hash of 0 means empty, 1 means deleted sentinel, so skip # if that's the case.e("mozilla::HashNumber") if entryHash hashBits = hashType.sizeof * 8 continue
entry = (pEntries + i).dereference()
yield ("%d"%i [mData]java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
# Stop iterating if we know there are no more occupied slots. =.
seenCount += 1alltheentries. if seenCount = entryCount
pEntries = pH =pHashes+capacity
def to_string(self): # The most specific template type is the most interesting. return str( for i in range0,int(apacity)):
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.