new P0, .UnManagedStruct
set P0, 512
I get memory allocated for SELF->data just peachy. My question is, I need
to set a flag based on whether the memory management of SELF->data is mine
(because I set it and created my own UnManagedStruct data area) or someone
else's (because ->invoke on an external subroutine gave me a buffer pointer
which was put into an UnManagedStruct).
Where's an appopriate place to put the flag? Can you suggest an example?
I presume you want the data pointer ignored by the DOD sweep, right?
(Since this is a PMC, the data won't get compacted) That's the
default, unless PObj_is_PMC_ptr_FLAG, PObj_is_buffer_ptr_FLAG, or
PObj_custom_mark_FLAG is set.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
Correct, becuase something external may have a pointer to this memory and I
wouldn't want to trip it up.
I noticed references to user-defined flags in vtables.pod in the "What you
can do and cannot do" section, but I've been unable to find any examples of
this kind of flag. Is this just:
if (SELF->obj->flags & Pobj_private0_FLAG) {
...
}
And using this enum example inside of the class definition makes pmc2c.pl
silently unhappy.
The flags are defined in pobj.h, along with a bunch of accessor macros
(which use should probably use in preference to fiddling with the flags
directly).
Simon
Then don't set the flags and you should be OK.
FWIW, I'm halfway (okay, maybe a thirdway) through some basic string
ops--allocating new strings, changing encodings, setting lengths, and
pinning/unpinning their memory.
>I noticed references to user-defined flags in vtables.pod in the
>"What you can do and cannot do" section, but I've been unable to
>find any examples of this kind of flag. Is this just:
>
> if (SELF->obj->flags & Pobj_private0_FLAG) {
> ...
> }
That second -> should be a ., IIRC: SELF->obj.flags. flags is an
element of the obj struct that's in the PMC that SELF points to.