Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Use perl type without perl

by xiaoyafeng (Chaplain)
on Sep 25, 2012 at 11:50 UTC ( #995530=perlquestion: print w/ replies, xml ) Need Help??
xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Is there a way to use perl type(SV, AV, HV) without perl interpreter? I mean don't invoke perl interpreter or struct. I tried to build a dll with a func roughly like below, but complain "error C2065: 'my_perl' : undeclared identifier":
#include "windows.h" #include <stdio.h> #include <tchar.h> #include "perl.h" #include "EXTERN.h" SV* Utl_Stats() { HV* infoHV = newHV(); SV* info = newSV(0); hv_store(infoHV, "name1", 5, newSVnv(1), 0); hv_store(infoHV, "name2", 5, newSVnv(2), 0); hv_store(infoHV, "name3", 5, newSVnv(3), 0); sv_setsv(info, sv_2mortal(newRV_noinc((SV*) infoHV))); return info; }
Thanks in advance!!!!




I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Comment on Use perl type without perl
Download Code
Replies are listed 'Best First'.
Re: Use perl type without perl
by zwon (Monsignor) on Sep 25, 2012 at 12:25 UTC
    No, you should create interpreter, many macros expect it to exist. See perlembed.
Re: Use perl type without perl
by rurban (Scribe) on Sep 25, 2012 at 13:06 UTC
    If you use a non-threaded perl, you probably will never need my_perl.

    Otherwise, follow "perlembed" as already said.

      If you use a non-threaded perl, you probably will never need my_perl.

      Could you please elaborate it? I'm curious why non-threaded perl can do what thread perl can't do. Thanks




      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

        In a single-threaded perl, there is only one copy of stuff like current working directory, environment etc.

        In a multi-threaded perl, each thread needs its own copy of that information.

        So, for the single-threaded perl, the PERL_CONTEXT can be known at compile time and linked statically into code. A single static pointer to a struct that contains all the per-thread information is all that is required, because there is only one thread.

        In a multi-threaded perl, each function that needs access to the "current PERL_CONTEXT" need to be able to find the appropriate context for the thread it is running in; hence it needs the my_perl variable which tells it which context that is.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        div class=
Re: Use perl type without perl
by bulk88 (Priest) on Sep 25, 2012 at 17:37 UTC
    What is going to call Utl_Stats? make the prototype "SV* Utl_Stats(pTHX)" and in the caller write " = Utl_Stats(aTHX);".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://995530]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2015-08-30 03:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (346 votes), past polls