On Wed, 3 Apr 2024 12:16:50 -0400, DFS wrote:
I cannot.
Here’s another example. First, without #end comments:
class xattr(ct.Structure) :
_fields_ = \
[
("fsx_xflags", ct.c_uint32),
("fsx_extsize", ct.c_uint32),
("fsx_nextents", ct.c_uint32),
("fsx_projid", ct.c_uint32),
("fsx_cowextsize", ct.c_uint32),
("fsx_pad", 8 * ct.c_ubyte),
]
def copy(self) :
celf = type(self)
res = celf()
for f in celf._fields_ :
setattr(res, f[0], getattr(self, f[0]))
return \
res
def __repr__(self) :
return \
(
"(%s)"
%
", ".join
(
"%%s = %s" % ("%d", "%#0.8x")[f == "fsx_xflags"]
%
(f, getattr(self, f))
for f in
("fsx_xflags", "fsx_extsize", "fsx_nextents", "fsx_projid", "fsx_cowextsize")
)
)
XFLAG_REALTIME = 0x00000001
XFLAG_PREALLOC = 0x00000002
Where does the “xattr” class end? Does it include those symbolic
parameters at the bottom? Can you see that clearly? Compare this way:
class xattr(ct.Structure) :
_fields_ = \
[
("fsx_xflags", ct.c_uint32),
("fsx_extsize", ct.c_uint32),
("fsx_nextents", ct.c_uint32),
("fsx_projid", ct.c_uint32),
("fsx_cowextsize", ct.c_uint32),
("fsx_pad", 8 * ct.c_ubyte),
]
def copy(self) :
celf = type(self)
res = celf()
for f in celf._fields_ :
setattr(res, f[0], getattr(self, f[0]))
#end for
return \
res
#end copy
def __repr__(self) :
return \
(
"(%s)"
%
", ".join
(
"%%s = %s" % ("%d", "%#0.8x")[f == "fsx_xflags"]
%
(f, getattr(self, f))
for f in
("fsx_xflags", "fsx_extsize", "fsx_nextents", "fsx_projid", "fsx_cowextsize")
)
)
#end __repr__
#end xattr
XFLAG_REALTIME = 0x00000001
XFLAG_PREALLOC = 0x00000002