1 /* $RCSfile: usersub.c,v $$Revision: 4.0.1.1 $$Date: 91/11/05 19:07:24 $
4 * Revision 4.0.1.1 91/11/05 19:07:24 lwall
5 * patch11: there are now subroutines for calling back from C into Perl
7 * Revision 4.0 91/03/20 01:56:34 lwall
10 * Revision 3.0.1.1 90/08/09 04:06:10 lwall
11 * patch19: Initial revision
24 /* Be sure to refetch the stack pointer after calling these routines. */
27 callback(subname, sp, gimme, hasargs, numargs)
29 int sp; /* stack pointer after args are pushed */
30 int gimme; /* called in array or scalar context */
31 int hasargs; /* whether to create a @_ array for routine */
32 int numargs; /* how many args are pushed on the stack */
34 static ARG myarg[3]; /* fake syntax tree node */
42 if (!myarg[0].arg_ptr.arg_str)
43 myarg[0].arg_ptr.arg_str = str_make("",0);
45 myarg[1].arg_type = A_WORD;
46 myarg[1].arg_ptr.arg_stab = stabent(subname, FALSE);
48 myarg[2].arg_type = hasargs ? A_EXPR : A_NULL;
50 return do_subr(myarg, gimme, arglast);
54 callv(subname, sp, gimme, argv)
56 register int sp; /* current stack pointer */
57 int gimme; /* called in array or scalar context */
58 register char **argv; /* null terminated arg list, NULL for no arglist */
60 register int items = 0;
61 int hasargs = (argv != 0);
63 astore(stack, ++sp, Nullstr); /* reserve spot for 1st return arg */
66 astore(stack, ++sp, str_2mortal(str_make(*argv,0)));
71 return callback(subname, sp, gimme, hasargs, items);