swig/Examples/test-suite/memberin1.i
Klaus Kämpf 23771ef027 Ruby: Replace all occurences of STR2CSTR macro with calls to StringValuePtr
STR2CSTR was deprecated in Ruby since years and got finally removed
in Ruby 1.9


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13967 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-12-14 15:48:31 +00:00

63 lines
1,017 B
OpenEdge ABL

%module memberin1
%{
class String {
private:
char *str;
public:
// Constructor
String(const char *s = 0) : str(0) {
if (s != 0) {
str = new char[strlen(s) + 1];
strcpy(str, s);
}
}
// Copy constructor
String(const String& other) {
delete [] str;
str = 0;
if (other.str != 0) {
str = new char[strlen(other.str) + 1];
strcpy(str, other.str);
}
}
// Assignment operator
String& operator=(const String& other) {
if (&other != this) {
delete [] str;
str = 0;
if (other.str != 0) {
str = new char[strlen(other.str) + 1];
strcpy(str, other.str);
}
}
return *this;
}
// String contents
const char *c_str() const { return str; }
// Destructor
~String() { delete [] str; }
};
%}
#ifdef SWIGRUBY
%typemap(in) String {
Check_Type($input, T_STRING);
$1 = String(StringValuePtr($input));
}
#endif
%typemap(memberin) String {
$1 = $input;
}
%inline %{
struct Person {
String name;
};
%}