Beispiel #1
0
    def mangler(self, name, argtypes):
        def repl(m):
            ch = m.group(0)
            return "_%X_" % ord(ch)

        qualified = name + '.' + '.'.join(transform_arg_name(a) for a in argtypes)
        mangled = VALID_CHARS.sub(repl, qualified)
        return mangled
Beispiel #2
0
    def mangler(self, name, argtypes):
        def repl(m):
            ch = m.group(0)
            return "_%X_" % ord(ch)

        qualified = name + '.' + '.'.join(
            transform_arg_name(a) for a in argtypes)
        mangled = VALID_CHARS.sub(repl, qualified)
        return mangled
Beispiel #3
0
    def test_record_arg_transform(self):
        """
        Testing that transforming the name of a record type argument to a
        function does not result in the fields of the record being used to
        uniquely identify them, and that no other condition results in the
        transformed name being excessively long.
        """
        rec = numpy_support.from_dtype(recordtype3)
        transformed = transform_arg_name(rec)
        self.assertNotIn('first', transformed)
        self.assertNotIn('second', transformed)
        # len(transformed) is generally 10, but could be longer if a large
        # number of typecodes are in use. Checking <16 should provide enough
        # tolerance.
        self.assertLess(len(transformed), 16)

        struct_arr = types.Array(rec, 1, 'C')
        transformed = transform_arg_name(struct_arr)
        self.assertIn('array', transformed)
        self.assertNotIn('first', transformed)
        self.assertNotIn('second', transformed)
        # Length is usually 34 - 5 chars tolerance as above.
        self.assertLess(len(transformed), 40)
    def test_record_arg_transform(self):
        """
        Testing that transforming the name of a record type argument to a
        function does not result in the fields of the record being used to
        uniquely identify them, and that no other condition results in the
        transformed name being excessively long.
        """
        rec = numpy_support.from_dtype(recordtype3)
        transformed = transform_arg_name(rec)
        self.assertNotIn('first', transformed)
        self.assertNotIn('second', transformed)
        # len(transformed) is generally 10, but could be longer if a large
        # number of typecodes are in use. Checking <16 should provide enough
        # tolerance.
        self.assertLess(len(transformed), 16)

        struct_arr = types.Array(rec, 1, 'C')
        transformed = transform_arg_name(struct_arr)
        self.assertIn('array', transformed)
        self.assertNotIn('first', transformed)
        self.assertNotIn('second', transformed)
        # Length is usually 34 - 5 chars tolerance as above.
        self.assertLess(len(transformed), 40)
Beispiel #5
0
 def mangler(self, name, argtypes):
     qualified = name + '.' + '.'.join(
         transform_arg_name(a) for a in argtypes)
     return self.mangle_name(qualified)
Beispiel #6
0
 def mangler(self, name, argtypes):
     qualified = name + '.' + '.'.join(transform_arg_name(a)
                                       for a in argtypes)
     return self.mangle_name(qualified)