Penguin

Differences between current version and predecessor to the previous major change of perlcall(1).

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Monday, June 3, 2002 6:50:42 pm by perry
Older page: version 1 Last edited on Monday, June 3, 2002 6:50:42 pm by perry Revert
@@ -618,26 +618,26 @@
 __Passing Parameters__ 
  
  
 Now let's make a slightly more complex example. This time we 
-want to call a Perl subroutine, LeftString, which 
+want to call a Perl subroutine, ! LeftString, which 
 will take 2 parameters--a string ($s) and an integer ($n). 
 The subroutine will simply print the first $n 
 characters of the string. 
  
  
 So the Perl subroutine would look like this 
  
  
- sub LeftString 
+ sub ! LeftString 
 
 my($s, $n) = @_ ; 
 print substr($s, 0, $n), 
-The C function required to call ''LeftString'' would look like this. 
+The C function required to call ''! LeftString'' would look like this. 
  
  
  static void 
-call_LeftString(a, b) 
+call_! LeftString(a, b) 
 char * a ; 
 int b ; 
 
 dSP ; 
@@ -650,9 +650,9 @@
  call_pv( 
  FREETMPS ; 
 LEAVE ; 
 
-Here are a few notes on the C function ''call_LeftString''. 
+Here are a few notes on the C function ''call_! LeftString''. 
  
  
 1. 
  
@@ -767,9 +767,9 @@
  
 6. 
  
  
-Finally, ''LeftString'' can now be called via the 
+Finally, ''! LeftString'' can now be called via the 
 ''call_pv'' function. The only flag specified this time 
 is G_DISCARD. Because we are passing 2 parameters to the 
 Perl subroutine this time, we have not specified 
 G_NOARGS. 
@@ -902,18 +902,18 @@
  
 Here is the Perl subroutine 
  
  
- sub AddSubtract 
+ sub ! AddSubtract 
 
 my($a, $b) = @_ ; 
 ($a+$b, $a-$b) ; 
 
 and this is the C function 
  
  
  static void 
-call_AddSubtract(a, b) 
+call_! AddSubtract(a, b) 
 int a ; 
 int b ; 
 
 dSP ; 
@@ -932,12 +932,12 @@
  PUTBACK ; 
 FREETMPS ; 
 LEAVE ; 
 
-If ''call_AddSubtract'' is called like this 
+If ''call_! AddSubtract'' is called like this 
  
  
- call_AddSubtract(7, 4) ; 
+ call_! AddSubtract(7, 4) ; 
 then here is the output 
  
  
  7 - 4 = 3 
@@ -968,9 +968,9 @@
 in a scalar context, like this 
  
  
  static void 
-call_AddSubScalar(a, b) 
+call_! AddSubScalar(a, b) 
 int a ; 
 int b ; 
 
 dSP ; 
@@ -989,18 +989,18 @@
  PUTBACK ; 
 FREETMPS ; 
 LEAVE ; 
 
-The other modification made is that ''call_AddSubScalar'' will print the number of items returned from the Perl subroutine and their value (for simplicity it assumes that they are integer). So if ''call_AddSubScalar'' is called 
+The other modification made is that ''call_! AddSubScalar'' will print the number of items returned from the Perl subroutine and their value (for simplicity it assumes that they are integer). So if ''call_! AddSubScalar'' is called 
  
  
- call_AddSubScalar(7, 4) ; 
+ call_! AddSubScalar(7, 4) ; 
 then the output will be 
  
  
  Items Returned = 1 
 Value 1 = 3 
-In this case the main point to note is that only the last item in the list is returned from the subroutine, ''AddSubtract'' actually made it back to ''call_AddSubScalar''. 
+In this case the main point to note is that only the last item in the list is returned from the subroutine, ''! AddSubtract'' actually made it back to ''call_! AddSubScalar''. 
  
  
 __Returning Data from Perl via the parameter 
 list__ 
@@ -1305,18 +1305,18 @@
 Here is a Perl subroutine which prints whatever parameters 
 are passed to it. 
  
  
- sub PrintList 
+ sub ! PrintList 
 
 my(@list) = @_ ; 
  foreach (@list) { print 
-and here is an example of ''call_argv'' which will call ''PrintList''. 
+and here is an example of ''call_argv'' which will call ''! PrintList''. 
  
  
  static char * words[[] = { 
  static void 
-call_PrintList() 
+call_! PrintList() 
 
 dSP ; 
  call_argv( 
 Note that it is not necessary to call PUSHMARK in this instance. This is because ''call_argv'' will do it for you. 
@@ -1407,19 +1407,19 @@
 context in which it is currently executing. 
  
  
  void 
-PrintContext() 
+! PrintContext() 
 CODE: 
 I32 gimme = GIMME_V; 
 if (gimme == G_VOID) 
 printf ( 
 and here is some Perl to test it 
  
  
- PrintContext ;  
-$a = PrintContext ;  
-@a = PrintContext ; 
+ ! PrintContext ;  
+$a = ! PrintContext ;  
+@a = ! PrintContext ; 
 The output from that will be 
  
  
  Context is Void 
@@ -1609,20 +1609,20 @@
 want to be called for that file. 
  
  
 Say the i/o library has a function asynch_read 
-which associates a C function ProcessRead with a 
+which associates a C function ! ProcessRead with a 
 file handle fh--this assumes that it has also 
 provided some routine to open the file and so obtain the 
 file handle. 
  
  
- asynch_read(fh, ProcessRead)  
-This may expect the C ''ProcessRead'' function of this form 
+ asynch_read(fh, ! ProcessRead)  
+This may expect the C ''! ProcessRead'' function of this form 
  
  
  void 
-ProcessRead(fh, buffer) 
+! ProcessRead(fh, buffer) 
 int fh ; 
 char * buffer ; 
 
 ... 
@@ -1692,9 +1692,9 @@
 parameter like this 
  
  
  void 
-ProcessRead(buffer) 
+! ProcessRead(buffer) 
 char * buffer ; 
 
 ... 
 
@@ -1707,18 +1707,18 @@
  
  
  #define MAX_CB 3 
 #define NULL_HANDLE -1 
-typedef void (*FnMap)() ;  
- struct MapStruct {  
-FnMap Function ;  
-SV * PerlSub ; 
+typedef void (*! FnMap)() ;  
+ struct ! MapStruct {  
+! FnMap Function ;  
+SV * ! PerlSub ; 
 int Handle ; 
 } ; 
  static void fn1() ; 
 static void fn2() ; 
 static void fn3() ; 
- static struct MapStruct Map [[MAX_CB] = 
+ static struct ! MapStruct Map [[MAX_CB] = 
 
 { fn1, NULL, NULL_HANDLE }, 
 { fn2, NULL, NULL_HANDLE }, 
 { fn3, NULL, NULL_HANDLE } 
@@ -1732,9 +1732,9 @@
  PUSHMARK(SP) ; 
 XPUSHs(sv_2mortal(newSVpv(buffer, 0))) ; 
 PUTBACK ; 
  /* Call the Perl sub */ 
-call_sv(Map[[index].PerlSub, G_DISCARD) ; 
+call_sv(Map[[index].! PerlSub, G_DISCARD) ; 
 
  static void 
 fn1(buffer) 
 char * buffer ; 
@@ -1770,12 +1770,12 @@
 index = null_index ; 
  /* Save the file handle */ 
 Map[[index].Handle = fh ; 
  /* Remember the Perl sub */ 
-if (Map[[index].PerlSub == (SV*)NULL)  
-Map[[index].PerlSub = newSVsv(callback) ; 
+if (Map[[index].! PerlSub == (SV*)NULL)  
+Map[[index].! PerlSub = newSVsv(callback) ; 
 else 
-SvSetSV(Map[[index].PerlSub, callback) ; 
+SvSetSV(Map[[index].! PerlSub, callback) ; 
  asynch_read(fh, Map[[index].Function) ; 
  void 
 array_asynch_close(fh) 
 int fh 
@@ -1785,10 +1785,10 @@
 for (index = 0; index 
  if (index == MAX_CB) 
 croak ( 
  Map[[index].Handle = NULL_HANDLE ; 
-SvREFCNT_dec(Map[[index].PerlSub) ;  
-Map[[index].PerlSub = (SV*)NULL ; 
+SvREFCNT_dec(Map[[index].! PerlSub) ;  
+Map[[index].! PerlSub = (SV*)NULL ; 
  asynch_close(fh) ; 
 In this case the functions fn1, fn2, and fn3 are used to remember the Perl subroutine to be called. Each of the functions holds a separate hard-wired index which is used in the function Pcb to access the Map array and actually call the Perl subroutine. 
  
  
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.