[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dennou-ruby:000614] Re: new proto



���椵��

> *.fp �ե������ proto2c/proto_new ���� commit ���ޤ������ޤ�
> *.fp ��Ȥ��褦�ˤ��� proto2c/etc/dcl_gen �� commit ���ޤ�����

�����ۤ� check out ���ޤ�����etc/p_init �ˡ�

<<<<<<< p_init
=======
>>>>>>> 1.7

�Ȥ��ä��Ԥ��������Ƥޤ��Τǡ��������Ʋ�������

���ΤȤ�����ɤ�

ruby proto2c.rb proto_new/g*.fp proto_new/m*1_*.fp \
   proto_new/math2_[^o]*.fp > code

cat etc/p_header >  src/dcl.c
cat code         >> src/dcl.c
cat etc/p_init   >> src/dcl.c

�ˤ�äơ�dcl.c �Ȥ�����ĤΥե�����ˤ��Ƥ��饳��ѥ��뤹��褦
�ˤʤäƤޤ�����ʬ��Ǥ��ޤ��󤫡�

�� ���ʤߤ� [^o] �Ȥ���ɽ���� sh �ǤϤȤ���ʤ��褦�Ǥ���

�ҤȤĤΤ�꤫���Ȥ��ơ�void Init_dcl �ˤ�����

    rb_define_module_function(mDCL, "gropn", dcl_gropn, 1);

�Ȥ��ä�ʸ�򤸤��ˤ�֤ΤǤʤ����ѥå�������˲����ؿ����Ѱդ��ơ�
������Ǥ�֤��Ȥϲ�ǽ�Ǥ��礦�����Ĥޤꡢ

void
Init_dcl()
{
    mDCL = rb_define_module("DCL");
    init_grph2_grpack(mDCL);
    init_grph2_udpack(mDCL);
    ...
}

�Ȥ�������ʤ���С���������꤬����褦�˻פ��ޤ��������ơ�
init_grph2_grpack ���ϼ�ư��������Ф褤�Ǥ��礦��
��ư������ź�դ��� cproto2init.rb �Τ褦�ʥ�����ץȤǽ���ޤ���

������Ѥ���p_head�κǸ�ι�(mDCL�����)�����������Τ� 
package_header �Ȥ���ȡ�ź�աˡ�

   pack=grph2_grpack
   cat etc/package_header > ${pack}.c
   ruby proto2c.rb proto_new/${pack}.fp >> ${pack}.c
   ruby cproto2init.rb ${pack}.c >> ${pack}.c

�ǡ�grph2_grpack.c �κǸ��

void
init_grph2_grpack(mDCL)
VALUE mDCL;
{
    rb_define_module_function(mDCL, "gropn", dcl_gropn, 1);
    rb_define_module_function(mDCL, "grfrm", dcl_grfrm, 0);
    rb_define_module_function(mDCL, "grfig", dcl_grfig, 0);
    rb_define_module_function(mDCL, "grcls", dcl_grcls, 0);
    rb_define_module_function(mDCL, "grinit", dcl_grinit, 0);
    rb_define_module_function(mDCL, "grsvpt", dcl_grsvpt, 4);
    rb_define_module_function(mDCL, "grswnd", dcl_grswnd, 4);
    rb_define_module_function(mDCL, "grssim", dcl_grssim, 3);
    rb_define_module_function(mDCL, "grsmpl", dcl_grsmpl, 3);
    rb_define_module_function(mDCL, "grstxy", dcl_grstxy, 4);
    rb_define_module_function(mDCL, "grstrn", dcl_grstrn, 1);
    rb_define_module_function(mDCL, "grstrf", dcl_grstrf, 0);
}

�Ȥ�����ʬ���ä��ޤ�����äơ������

#include <stdio.h>
#include "ruby.h"

VALUE mDCL;
void init_grph2_grpack(VALUE mDCL);
void init_grph2_udpack(VALUE mDCL);
...

void
Init_dcl()
{
    mDCL = rb_define_module("DCL");
    init_grph2_grpack(mDCL);
    init_grph2_udpack(mDCL);
    ...
}

�Ȥ��ä��ե��������Хѥå�������˽�����Ǥ��ޤ���
ǡ���Ǥ��礦��

��Ƿ�� ��                     horinout@xxxxxx
�������������Ȳʳظ��楻�󥿡� (��Ķ�������ȸ��楻�󥿡�)
611-0011 �����Ըޥ���  phone:0774-38-3812  fax:0774-31-8463
# Program: cproto2init.rb
#          2000/11/20 Takeshi Horinouchi
# Usage:
#
#     % ruby cproto2init.rb cprotofile
#
#  Here, cprotofile is the name of the C program obtained by,
#  for example,
#
#     ruby proto2c.rb grph2_grpack.fp > grph2_grpack.c
#
#  The package name is determined from the file name such as
#  'grph2_grpack'.

package =  $*[0].gsub('.*/','').sub('\..*','')    # remove directory name
                                                  # and suffix

print ("void\n","init_",package,"(mDCL)\n","VALUE mDCL;\n","{\n")

while (line=gets)
   if ( line =~ "^static VALUE" )
      funcdef = gets.chop
      func = funcdef.sub('\(.*$','')
      nargs = funcdef.delete('^,').length
      method = func.sub('dcl_','')
      print ('    rb_define_module_function(mDCL, "',method,
	     '", ',func,", ",nargs,");\n")
   end
end

print "}\n"
/*
 * $Id: p_header,v 1.3 2000/11/18 18:48:42 keiko Exp $
 */

#include <stdio.h>
#include "ruby.h"
#include "f2c.h"
#include "numarray.h"

#define DFLT_SIZE 32

extern char    *dcl_obj2ccharary(VALUE, int, int);
extern integer *dcl_obj2cintegerary(VALUE);
extern real    *dcl_obj2crealary(VALUE);
extern complex *dcl_obj2ccomplexary(VALUE);
extern logical *dcl_obj2clogicalary(VALUE);

extern VALUE dcl_ccharary2obj(char *, int, int);
extern VALUE dcl_cintegerary2obj(integer *, int, char *);
extern VALUE dcl_crealary2obj(real *, int, char *);
extern VALUE dcl_ccomplexary2obj(complex *, int, char *);
extern VALUE dcl_clogicalary2obj(logical *, int, char *);

extern void dcl_freeccharary(char *);
extern void dcl_freecintegerary(integer *);
extern void dcl_freecrealary(real *);
extern void dcl_freeccomplexary(complex *);
extern void dcl_freeclogicalary(logical *);

/* for functions which return doublereal */
extern doublereal rave_(real *, integer *, integer *);
#include <stdio.h>
#include "ruby.h"

VALUE mDCL;

void init_grph2_grpack(VALUE mDCL);

void
Init_dcl()
{
    mDCL = rb_define_module("DCL");
    init_grph2_grpack(mDCL);
}