I was wondering if it is possible to call "setprop" from within the init function from a PMC.
I want all PMC's of a particular type to have some property.
so:
void init {
/* do init stuff */
/* create a keystring, called "keystring" */
/* create some value, in this case also a string: "valuestring" */
/* looked up prototype in "include/parrot/vtables.h", not sure about 2nd argument */
SELF->vtable->setprop(INTERP, SELF, (PMC *)keystring, (PMC *)valuestring);
}
This will compile, but when I "getprop" in PASM, it won't run. So, I'm doing something wrong.
Has anybody an idea?
Thanks in advance.
Klaas-Jan
#ifdef _WIN32
# define snprintf _snprintf
#endif
'josh' did it for spf_vtable.c before (Revision : 1.17; Date : 2003/1/4
3:29:36; Description: Indenting fixes, etc.)
With this patch
All tests successful, 24 subtests skipped.
Files=47, Tests=686, 590 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00
CPU)
Nick.
Thank you for your work on this.
Unfortunately, this exact change was submitted earlier this week (by me),
and contested; Brent Dax thinks that Parrot_snprintf should be used
instead. The longopt author, Luke Palmer, did not disagree. See:
http://bugs6.perl.org/rt2/Ticket/Display.html?id=22174
Ticket #22174 [PATCH] snprintf link errors on Win32
Later today, I will submit a patch to match Brent's request. If he and Luke
raise no objection, I will commit it, otherwise I will commit the original
patch until we work out a better solution.
--
Hope this helps,
Bruce Gray
> I was wondering if it is possible to call "setprop" from within the init =
> function from a PMC.
> I want all PMC's of a particular type to have some property.
Should be no problem. When C<init> gets called on a newly created PMC
everything is already in place. The only thing to worry about is loosing
the newly created PMC due to infant mortality. So placing the call
between Parrot_DOD_block / _unblock is probably necessary.
leo
> SELF->vtable->setprop(INTERP, SELF, (PMC *)keystring, (PMC =
> *)valuestring);
Ah hoppala:
> This will compile, but when I "getprop" in PASM, it won't run. So, I'm =
> doing something wrong.=20
Third parameter is a real STRING (the key), last is a PMC in your case
a PerlString - the value. No casts necessary/allowed.
Please have a look at default.pmc and the property tests.
> Klaas-Jan
leo
--Josh