[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02920] SWIG: virtual variable?

From: Yasushi Shoji <yashi@...>
Date: 2000-05-22 04:10:15 UTC
List: ruby-talk #2920
hello,

I just tried an example on swig.org
http://www.swig.org/tutorial.html

with latest swigruby.

My question is:

Why variable My_variable is defined as a global variable? Shouldn't it
defined under the module Example?

I don't know what rb_define_virtual_variable() does, so if I'm asking
some stupid question, please forgive me kindly ;p

regards,
--
           yashi


/* example.i */
%module example
%{
/* Put header files here (optional) */
%}

extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();

/* File : example.c */

#include <time.h>
double My_variable = 3.0;                                        
int fact(int n) {
	if (n <= 1) return 1;               
	else return n*fact(n-1);
}

int my_mod(int x, int y) {        
	return (x%y);                   
}                                                     

char *get_time()                                             
{                                                                
	time_t ltime;                                                
	time(&ltime);                                        
	return ctime(&ltime);                                        
}                        

#example_test.rb
require 'example'

print $My_variable, "\n"  # Example::My_variable doesn't work.
print Example.fact(5), "\n"
print Example.get_time, "\n"

#extconf.rb
require 'mkmf'

create_makefile('example')

In This Thread

Prev Next