Lichen

Changeset

462:f78e88fc7321
2017-01-12 Paul Boddie raw files shortlog changelog graph Added a convenience macro for testing instance compatibility.
templates/progops.h (file) translator.py (file)
     1.1 --- a/templates/progops.h	Thu Jan 12 16:32:06 2017 +0100
     1.2 +++ b/templates/progops.h	Thu Jan 12 18:03:01 2017 +0100
     1.3 @@ -74,4 +74,8 @@
     1.4  
     1.5  int __BOOL(__attr attr);
     1.6  
     1.7 +/* Convenience definitions. */
     1.8 +
     1.9 +#define __ISINSTANCE(__ATTR, __TYPE) __BOOL(__fn_native_introspection_isinstance((__attr[]) {{0, 0}, __ATTR, __TYPE}))
    1.10 +
    1.11  #endif /* __PROGOPS_H__ */
     2.1 --- a/translator.py	Thu Jan 12 16:32:06 2017 +0100
     2.2 +++ b/translator.py	Thu Jan 12 18:03:01 2017 +0100
     2.3 @@ -1510,7 +1510,7 @@
     2.4  
     2.5              if name is not None:
     2.6                  name_ref = self.process_structure_node(name)
     2.7 -                self.writeline("else if (__BOOL(__fn_native_introspection_isinstance((__attr[]) {{0, 0}, __tmp_exc.arg, %s})))" % name_ref)
     2.8 +                self.writeline("else if (__ISINSTANCE(__tmp_exc.arg, %s))" % name_ref)
     2.9              else:
    2.10                  self.writeline("else if (1)")
    2.11