Reply to topic  [ 2 posts ] 
codger bug 
Author Message
Yorick Guru

Joined: Wed Nov 24, 2004 12:51 pm
Posts: 97
Location: Observatoire de Lyon (France)
Post codger bug
There is a bug in Yorick's codger. Prototype definitions with the last argument name on a single line (as for the foo2 in the example below) results in the next definition (foo3 in the example) to be skipped. You can trigger this with the following example. Create a first file, say codger_bug.i, with (beware of keeping the same newlines):
Code:
if (is_func(plug_in)) plug_in, "codger_bug";
extern foo1;
/* PROTOTYPE double foo1(long n, double array x); */
extern foo2;
/* PROTOTYPE double foo2(long n, double array
   x); */
extern foo3;
/* PROTOTYPE double foo3(long n, double
   array x); */
extern foo4;
/* PROTOTYPE double foo4(long n, double array x); */
Create a second file, say codger_bug.c, with:
Code:
double foo1(long n, double x[]) {
  double s = 0.0; long i; for (i=0;i<n;++i) s += x[i]; return s; }
double foo2(long n, double x[]) {
  double s = 0.0; long i; for (i=0;i<n;++i) s += x[i]; return s + s; }
double foo3(long n, double x[]) {
  double s = 0.0; long i; for (i=0;i<n;++i) s += x[i]; return 3.0*s; }
double foo4(long n, double x[]) {
  double s = 0.0; long i; for (i=0;i<n;++i) s += x[i]; return 4.0*s; }
Then type:
Code:
yorick -batch make.i
make
nm codger_bug.so| grep foo
as you can see from the output (or you can look at ywrap.c), there is no entry for Y_foo3.


Tue Jul 29, 2008 3:28 am
Profile WWW
Yorick Guru

Joined: Wed Nov 24, 2004 12:51 pm
Posts: 97
Location: Observatoire de Lyon (France)
Post codger feature
BTW, it would be nice if the cogder could be a little bit smarter about array argument definitions and recognize constructions like
Code:
double array x
double x[]
double *x
There surely must be a reason for the actual limitation of the codger but I cannot see it...

The alternative could be to write a script to automatically convert definitions in C headers files into "PROTOTYPE" comments. Would be cool if this script could "update" a Yorick *.i file with "PROTOTYPE" comments, so that you just have to write a basic .i file with "extern" declarations and mostly empty "PROTOTYPE" comments for the functions you want to import into Yorick (just specify the name of the Yorick builtin function and the name of the C / FORTRAN function). This would avoid typo errors plaguing the coding of plugins.


Tue Jul 29, 2008 3:42 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.