From e602db3d53cdfddb393ef5e3c079c8a9c30aafe0 Mon Sep 17 00:00:00 2001 From: Charlie Savage Date: Fri, 13 Jan 2006 05:50:57 +0000 Subject: [PATCH] Added new method called Swig_string_first_ucase which capitalizes the first letter in a string. This is needed for the Ruby module to allow backwards compatibility with swig 1.2.7 and before generated interfaces. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8409 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 38e0fea90..77460ee1c 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -209,6 +209,27 @@ String *Swig_string_ucase(String *s) { return ns; } +/* ----------------------------------------------------------------------------- + * Swig_string_first_ucase() + * + * Make the first character in the string uppercase, leave all the + * rest the same. This is used by the Ruby module to provide backwards + * compatibility with the old way of naming classes and constants. For + * more info see the Ruby documentation. + * + * firstUpper -> FirstUpper + * ----------------------------------------------------------------------------- */ + +String *Swig_string_first_ucase(String *s) { + String *ns = NewStringEmpty(); + char *cs = Char(s); + if (cs) { + Putc(toupper(cs[0]),ns); + Append(ns, cs + 1); +} + return ns; +} + /* ----------------------------------------------------------------------------- * Swig_string_typecode() * @@ -736,6 +757,7 @@ Swig_init() { DohEncoding("lowercase", Swig_string_lower); DohEncoding("camelcase", Swig_string_ccase); DohEncoding("undercase", Swig_string_ucase); + DohEncoding("firstuppercase", Swig_string_first_ucase); /* Initialize the swig keys */ Swig_keys_init();