@@ -1597,15 +1597,19 @@ def finalize_vars(self):
1597
1597
1598
1598
elif nestedEnum :
1599
1599
enum = nestedEnum
1600
- if enum ["type" ] is int :
1600
+ etype = enum .get ("type" )
1601
+ if etype is int :
1601
1602
var ["ctypes_type" ] = "ctypes.c_int"
1602
1603
var ["raw_type" ] = "int"
1603
1604
1604
- elif enum [ "type" ] is str :
1605
+ elif etype is str :
1605
1606
var ["ctypes_type" ] = "ctypes.c_char_p"
1606
1607
var ["raw_type" ] = "char*"
1607
1608
1608
- var ["enum" ] = var ["method" ]["path" ] + "::" + enum ["name" ]
1609
+ if "method" in var :
1610
+ var ["enum" ] = var ["method" ]["path" ] + "::" + enum ["name" ]
1611
+ else :
1612
+ var ["enum" ] = enum ["name" ]
1609
1613
var ["fundamental" ] = True
1610
1614
1611
1615
elif nestedStruct :
@@ -1663,10 +1667,11 @@ def finalize_vars(self):
1663
1667
if b in klass ._public_enums :
1664
1668
trace_print ("...found nested enum" , b )
1665
1669
enum = klass ._public_enums [b ]
1666
- if enum ["type" ] is int :
1670
+ etype = enum .get ("type" )
1671
+ if etype is int :
1667
1672
var ["ctypes_type" ] = "ctypes.c_int"
1668
1673
var ["raw_type" ] = "int"
1669
- elif enum [ "type" ] is str :
1674
+ elif etype is str :
1670
1675
var ["ctypes_type" ] = "ctypes.c_char_p"
1671
1676
var ["raw_type" ] = "char*"
1672
1677
try :
@@ -1700,10 +1705,11 @@ def finalize_vars(self):
1700
1705
): # falling back, this is a big ugly
1701
1706
enum = self .global_enums [b ]
1702
1707
assert a in enum ["namespace" ].split ("::" )
1703
- if enum ["type" ] is int :
1708
+ etype = enum .get ("type" )
1709
+ if etype is int :
1704
1710
var ["ctypes_type" ] = "ctypes.c_int"
1705
1711
var ["raw_type" ] = "int"
1706
- elif enum [ "type" ] is str :
1712
+ elif etype is str :
1707
1713
var ["ctypes_type" ] = "ctypes.c_char_p"
1708
1714
var ["raw_type" ] = "char*"
1709
1715
var ["fundamental" ] = True
@@ -1931,18 +1937,18 @@ def finalize(self):
1931
1937
1932
1938
elif meth ["returns" ] in cls ._public_enums :
1933
1939
enum = cls ._public_enums [meth ["returns" ]]
1934
- meth ["returns_enum" ] = enum [ "type" ]
1940
+ meth ["returns_enum" ] = enum . get ( "type" )
1935
1941
meth ["returns_fundamental" ] = True
1936
- if enum [ "type" ] == int :
1942
+ if enum . get ( "type" ) == int :
1937
1943
meth ["returns" ] = "int"
1938
1944
else :
1939
1945
meth ["returns" ] = "char*"
1940
1946
1941
1947
elif meth ["returns" ] in self .global_enums :
1942
1948
enum = self .global_enums [meth ["returns" ]]
1943
- meth ["returns_enum" ] = enum [ "type" ]
1949
+ meth ["returns_enum" ] = enum . get ( "type" )
1944
1950
meth ["returns_fundamental" ] = True
1945
- if enum [ "type" ] == int :
1951
+ if enum . get ( "type" ) == int :
1946
1952
meth ["returns" ] = "int"
1947
1953
else :
1948
1954
meth ["returns" ] = "char*"
@@ -1958,9 +1964,9 @@ def finalize(self):
1958
1964
meth ["returns_unknown" ] = True
1959
1965
elif b in self .global_enums :
1960
1966
enum = self .global_enums [b ]
1961
- meth ["returns_enum" ] = enum [ "type" ]
1967
+ meth ["returns_enum" ] = enum . get ( "type" )
1962
1968
meth ["returns_fundamental" ] = True
1963
- if enum [ "type" ] == int :
1969
+ if enum . get ( "type" ) == int :
1964
1970
meth ["returns" ] = "int"
1965
1971
else :
1966
1972
meth ["returns" ] = "char*"
@@ -1975,9 +1981,9 @@ def finalize(self):
1975
1981
if b in klass ._public_enums :
1976
1982
trace_print ("...found nested enum" , b )
1977
1983
enum = klass ._public_enums [b ]
1978
- meth ["returns_enum" ] = enum [ "type" ]
1984
+ meth ["returns_enum" ] = enum . get ( "type" )
1979
1985
meth ["returns_fundamental" ] = True
1980
- if enum [ "type" ] == int :
1986
+ if enum . get ( "type" ) == int :
1981
1987
meth ["returns" ] = "int"
1982
1988
else :
1983
1989
meth ["returns" ] = "char*"
0 commit comments