From 7322ef7cb7f8b2a1d42da0624773e76b0eba368d Mon Sep 17 00:00:00 2001 From: Lyle Johnson Date: Thu, 26 Aug 2004 01:48:40 +0000 Subject: [PATCH] Modified the "varin" typemap for a dimensionless char array to generate a warning message, and to raise an exception if the typemap is actually invoked at runtime. This is needed to avoid problems for the case when wrapping an extern char[] declaration, where the array size is truly unknown. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6151 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubystrings.swg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/ruby/rubystrings.swg b/Lib/ruby/rubystrings.swg index 1e18a79a1..00fc4d025 100644 --- a/Lib/ruby/rubystrings.swg +++ b/Lib/ruby/rubystrings.swg @@ -1,4 +1,5 @@ /* --- Input Values --- */ + %typemap(in) char * "$1 = StringValuePtr($input);"; %typemap(in) char [ANY] "$1 = StringValuePtr($input);"; @@ -59,9 +60,10 @@ #endif /* __cplusplus */ /* Special case for string array variables */ -%typemap(varin) char[] { - size_t size = sizeof($1); - strncpy($1,StringValuePtr($input),size); +%typemap(varin, + warning="462:Unable to set variable of type char []") char[] +{ + rb_raise(rb_eTypeError, "C/C++ variable '$name' is read-only."); } %typemap(varin) char[ANY] "strncpy($1,StringValuePtr($input),$1_dim0);";