mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-18 08:35:19 +00:00
policyrep: Misc cython tweaks.
This commit is contained in:
parent
8f77510bcb
commit
6e67c3b8b4
@ -45,7 +45,7 @@ cdef class Bounds(PolicySymbol):
|
||||
b.policy = policy
|
||||
return b
|
||||
|
||||
def __init__(self, parent, child):
|
||||
def __cinit__(self, parent, child):
|
||||
self.ruletype = BoundsRuletype.typebounds
|
||||
self.parent = parent
|
||||
self.child = child
|
||||
@ -97,10 +97,11 @@ cdef class TypeboundsIterator(HashtabIterator):
|
||||
Type.factory(self.policy, datum))
|
||||
|
||||
def __len__(self):
|
||||
cdef sepol.type_datum_t *datum
|
||||
cdef sepol.hashtab_node_t *node
|
||||
cdef uint32_t bucket = 0
|
||||
cdef size_t count = 0
|
||||
cdef:
|
||||
sepol.type_datum_t *datum
|
||||
sepol.hashtab_node_t *node
|
||||
uint32_t bucket = 0
|
||||
size_t count = 0
|
||||
|
||||
while bucket < self.table[0].size:
|
||||
node = self.table[0].htable[bucket]
|
||||
|
@ -44,7 +44,7 @@ cdef class MLSRule(PolicyRule):
|
||||
r.handle = symbol
|
||||
return r
|
||||
|
||||
def __init__(self, rng):
|
||||
def __cinit__(self, rng):
|
||||
self.ruletype = MLSRuletype.range_transition
|
||||
self.rng = rng
|
||||
|
||||
|
@ -45,7 +45,7 @@ cdef class RoleAllow(PolicyRule):
|
||||
r.handle = symbol
|
||||
return r
|
||||
|
||||
def __init__(self):
|
||||
def __cinit__(self):
|
||||
self.ruletype = RBACRuletype.allow
|
||||
|
||||
def __str__(self):
|
||||
@ -106,7 +106,7 @@ cdef class RoleTransition(PolicyRule):
|
||||
r.handle = symbol
|
||||
return r
|
||||
|
||||
def __init__(self):
|
||||
def __cinit__(self):
|
||||
self.ruletype = RBACRuletype.role_transition
|
||||
|
||||
def __str__(self):
|
||||
|
@ -22,11 +22,9 @@ cdef class PolicyRule(PolicySymbol):
|
||||
|
||||
"""This is base class for policy rules."""
|
||||
|
||||
# This is initialized to False
|
||||
cdef readonly bint extended
|
||||
|
||||
def __init__(self):
|
||||
self.extended = False
|
||||
|
||||
def __str__(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -25,8 +25,7 @@ cdef class PolicySymbol:
|
||||
|
||||
"""This is a base class for all policy objects."""
|
||||
|
||||
cdef:
|
||||
readonly SELinuxPolicy policy
|
||||
cdef readonly SELinuxPolicy policy
|
||||
|
||||
def __hash__(self):
|
||||
return hash(str(self))
|
||||
@ -145,6 +144,7 @@ cdef class EbitmapIterator(PolicyIterator):
|
||||
cdef:
|
||||
sepol.ebitmap_node_t *node
|
||||
size_t curr
|
||||
size_t count = 0
|
||||
|
||||
count = 0
|
||||
curr = sepol.ebitmap_start(self.bmap, &node)
|
||||
@ -184,7 +184,7 @@ cdef class HashtabIterator(PolicyIterator):
|
||||
sepol.hashtab_node_t *curr
|
||||
unsigned int bucket
|
||||
|
||||
def _next_bucket(self):
|
||||
cdef void _next_bucket(self):
|
||||
"""Internal method for advancing to the next bucket."""
|
||||
self.bucket += 1
|
||||
if self.bucket < self.table[0].size:
|
||||
@ -192,7 +192,7 @@ cdef class HashtabIterator(PolicyIterator):
|
||||
else:
|
||||
self.node = NULL
|
||||
|
||||
def _next_node(self):
|
||||
cdef void _next_node(self):
|
||||
"""Internal method for advancing to the next node."""
|
||||
if self.node != NULL and self.node.next != NULL:
|
||||
self.node = self.node.next
|
||||
|
@ -282,7 +282,7 @@ cdef class AVRuleXperm(AVRule):
|
||||
r._conditional_block = conditional_block
|
||||
return r
|
||||
|
||||
def __init__(self):
|
||||
def __cinit__(self):
|
||||
self.extended = True
|
||||
|
||||
def __str__(self):
|
||||
@ -481,7 +481,7 @@ cdef class FileNameTERule(PolicyRule):
|
||||
r.datum = datum
|
||||
return r
|
||||
|
||||
def __init__(self):
|
||||
def __cinit__(self):
|
||||
self.ruletype = TERuletype.type_transition
|
||||
|
||||
def __str__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user