Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting properties in PMC init

14 views
Skip to first unread message

K Stol

unread,
May 15, 2003, 7:11:14 AM5/15/03
to perl6-i...@perl.org
Hello,

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

Nick Kostirya

unread,
May 15, 2003, 8:39:19 AM5/15/03
to perl6-i...@perl.org
For successful building parrot under Win32 need define snprintf as _snprintf
into longopt.c file.

#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.

Bruce Gray

unread,
May 15, 2003, 8:58:45 AM5/15/03
to perl6-i...@perl.org, Nick Kostirya

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

Leopold Toetsch

unread,
May 15, 2003, 8:02:23 AM5/15/03
to K Stol, perl6-i...@perl.org
In perl.perl6.internals, you wrote:

> 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

Leopold Toetsch

unread,
May 15, 2003, 8:06:56 AM5/15/03
to K Stol, perl6-i...@perl.org
In perl.perl6.internals, you wrote:

> 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 Wilmes

unread,
May 16, 2003, 9:09:02 PM5/16/03
to Nick Kostirya, perl6-i...@perl.org

I wouldn't assume that I knew what I was doing ;-) These days, i think
something with Parrot_sprintf would be the way to go.. I'm pretty out of
touch though.

--Josh

0 new messages