Fix qstrcmp calls

pull/1/head
Timothy Pearson 13 years ago
parent 3cf84d62aa
commit c86db6ae4f

@ -19,7 +19,7 @@
v = TQt::Variant.new([1, 2, 3]) v = TQt::Variant.new([1, 2, 3])
The TQt::Variant v will contain a list of 3 TQVariants with typeName 'int' The TQt::Variant v will contain a list of 3 TQVariants with typeName 'int'
* Change all instances of strcmp() to qstrcmp() * Change all instances of strcmp() to tqstrcmp()
2006-11-20 Richard Dale <rdale@foton.es> 2006-11-20 Richard Dale <rdale@foton.es>

@ -138,7 +138,7 @@ void *value_to_ptr(VALUE ruby_value) { // ptr on success, null on fail
VALUE getPointerObject(void *ptr); VALUE getPointerObject(void *ptr);
bool isTQObject(Smoke *smoke, Smoke::Index classId) { bool isTQObject(Smoke *smoke, Smoke::Index classId) {
if(qstrcmp(smoke->classes[classId].className, "TQObject") == 0) if(tqstrcmp(smoke->classes[classId].className, "TQObject") == 0)
return true; return true;
for(Smoke::Index *p = smoke->inheritanceList + smoke->classes[classId].parents; for(Smoke::Index *p = smoke->inheritanceList + smoke->classes[classId].parents;
*p; *p;
@ -346,7 +346,7 @@ public:
void unsupported() { void unsupported() {
rb_raise(rb_eArgError, "Cannot handle '%s' as return-type of %s::%s", rb_raise(rb_eArgError, "Cannot handle '%s' as return-type of %s::%s",
type().name(), type().name(),
qstrcmp(_smoke->className(method().classId), "TQGlobalSpace") == 0 ? "" : _smoke->className(method().classId), tqstrcmp(_smoke->className(method().classId), "TQGlobalSpace") == 0 ? "" : _smoke->className(method().classId),
_smoke->methodNames[method().name]); _smoke->methodNames[method().name]);
} }
Smoke *smoke() { return _smoke; } Smoke *smoke() { return _smoke; }
@ -411,7 +411,7 @@ public:
} }
void unsupported() { void unsupported() {
if (qstrcmp(_smoke->className(method().classId), "TQGlobalSpace") == 0) { if (tqstrcmp(_smoke->className(method().classId), "TQGlobalSpace") == 0) {
rb_raise(rb_eArgError, "Cannot handle '%s' as argument to %s", rb_raise(rb_eArgError, "Cannot handle '%s' as argument to %s",
type().name(), type().name(),
_smoke->methodNames[method().name]); _smoke->methodNames[method().name]);
@ -954,15 +954,15 @@ get_VALUEtype(VALUE ruby_value)
const char *r = ""; const char *r = "";
if(ruby_value == Qnil) if(ruby_value == Qnil)
r = "u"; r = "u";
else if(TYPE(ruby_value) == T_FIXNUM || TYPE(ruby_value) == T_BIGNUM || qstrcmp(classname, "TQt::Integer") == 0) else if(TYPE(ruby_value) == T_FIXNUM || TYPE(ruby_value) == T_BIGNUM || tqstrcmp(classname, "TQt::Integer") == 0)
r = "i"; r = "i";
else if(TYPE(ruby_value) == T_FLOAT) else if(TYPE(ruby_value) == T_FLOAT)
r = "n"; r = "n";
else if(TYPE(ruby_value) == T_STRING) else if(TYPE(ruby_value) == T_STRING)
r = "s"; r = "s";
else if(ruby_value == Qtrue || ruby_value == Qfalse || qstrcmp(classname, "TQt::Boolean") == 0) else if(ruby_value == Qtrue || ruby_value == Qfalse || tqstrcmp(classname, "TQt::Boolean") == 0)
r = "B"; r = "B";
else if(qstrcmp(classname, "TQt::Enum") == 0) { else if(tqstrcmp(classname, "TQt::Enum") == 0) {
VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qenum_type"), 1, ruby_value); VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qenum_type"), 1, ruby_value);
r = StringValuePtr(temp); r = StringValuePtr(temp);
} else if(TYPE(ruby_value) == T_DATA) { } else if(TYPE(ruby_value) == T_DATA) {
@ -1365,9 +1365,9 @@ static Smoke::Index new_qvariant_qmap = 0;
while (qt_Smoke->ambiguousMethodList[i] != 0) { while (qt_Smoke->ambiguousMethodList[i] != 0) {
const char * argType = qt_Smoke->types[qt_Smoke->argumentList[qt_Smoke->methods[qt_Smoke->ambiguousMethodList[i]].args]].name; const char * argType = qt_Smoke->types[qt_Smoke->argumentList[qt_Smoke->methods[qt_Smoke->ambiguousMethodList[i]].args]].name;
if (qstrcmp(argType, "const TQValueList<TQVariant>&" ) == 0) { if (tqstrcmp(argType, "const TQValueList<TQVariant>&" ) == 0) {
new_qvariant_qlist = qt_Smoke->ambiguousMethodList[i]; new_qvariant_qlist = qt_Smoke->ambiguousMethodList[i];
} else if (qstrcmp(argType, "const TQMap<TQString,TQVariant>&" ) == 0) { } else if (tqstrcmp(argType, "const TQMap<TQString,TQVariant>&" ) == 0) {
new_qvariant_qmap = qt_Smoke->ambiguousMethodList[i]; new_qvariant_qmap = qt_Smoke->ambiguousMethodList[i];
} }
@ -1483,11 +1483,11 @@ static TQString * pred = 0;
VALUE retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+3, temp_stack); VALUE retval = rb_funcall2(qt_internal_module, rb_intern("do_method_missing"), argc+3, temp_stack);
if (_current_method == -1) { if (_current_method == -1) {
const char * op = rb_id2name(SYM2ID(argv[0])); const char * op = rb_id2name(SYM2ID(argv[0]));
if ( qstrcmp(op, "-") == 0 if ( tqstrcmp(op, "-") == 0
|| qstrcmp(op, "+") == 0 || tqstrcmp(op, "+") == 0
|| qstrcmp(op, "/") == 0 || tqstrcmp(op, "/") == 0
|| qstrcmp(op, "%") == 0 || tqstrcmp(op, "%") == 0
|| qstrcmp(op, "|") == 0 ) || tqstrcmp(op, "|") == 0 )
{ {
// Look for operator methods of the form 'operator+=', 'operator-=' and so on.. // Look for operator methods of the form 'operator+=', 'operator-=' and so on..
char op1[3]; char op1[3];
@ -1862,7 +1862,7 @@ qt_invoke(int /*argc*/, VALUE * argv, VALUE self)
// Now, I need to find out if this means me // Now, I need to find out if this means me
int index; int index;
char *slotname; char *slotname;
bool isSignal = qstrcmp(rb_id2name(rb_frame_last_func()), "qt_emit") == 0; bool isSignal = tqstrcmp(rb_id2name(rb_frame_last_func()), "qt_emit") == 0;
VALUE mocArgs = getslotinfo(self, id, slotname, index, isSignal); VALUE mocArgs = getslotinfo(self, id, slotname, index, isSignal);
if(mocArgs == Qnil) { if(mocArgs == Qnil) {
// No ruby slot/signal found, assume the target is a C++ one // No ruby slot/signal found, assume the target is a C++ one
@ -2040,17 +2040,17 @@ setMocType(VALUE /*self*/, VALUE ptr, VALUE idx_value, VALUE name_value, VALUE s
MocArgument *arg = 0; MocArgument *arg = 0;
Data_Get_Struct(ptr, MocArgument, arg); Data_Get_Struct(ptr, MocArgument, arg);
arg[idx].st.set(qt_Smoke, typeId); arg[idx].st.set(qt_Smoke, typeId);
if(qstrcmp(static_type, "ptr") == 0) if(tqstrcmp(static_type, "ptr") == 0)
arg[idx].argType = xmoc_ptr; arg[idx].argType = xmoc_ptr;
else if(qstrcmp(static_type, "bool") == 0) else if(tqstrcmp(static_type, "bool") == 0)
arg[idx].argType = xmoc_bool; arg[idx].argType = xmoc_bool;
else if(qstrcmp(static_type, "int") == 0) else if(tqstrcmp(static_type, "int") == 0)
arg[idx].argType = xmoc_int; arg[idx].argType = xmoc_int;
else if(qstrcmp(static_type, "double") == 0) else if(tqstrcmp(static_type, "double") == 0)
arg[idx].argType = xmoc_double; arg[idx].argType = xmoc_double;
else if(qstrcmp(static_type, "char*") == 0) else if(tqstrcmp(static_type, "char*") == 0)
arg[idx].argType = xmoc_charstar; arg[idx].argType = xmoc_charstar;
else if(qstrcmp(static_type, "TQString") == 0) else if(tqstrcmp(static_type, "TQString") == 0)
arg[idx].argType = xmoc_QString; arg[idx].argType = xmoc_QString;
return Qtrue; return Qtrue;
} }
@ -2156,16 +2156,16 @@ make_QUParameter(VALUE /*self*/, VALUE name_value, VALUE type_value, VALUE /*ext
TQUParameter *p = new TQUParameter; TQUParameter *p = new TQUParameter;
p->name = new char[strlen(name) + 1]; p->name = new char[strlen(name) + 1];
strcpy((char*)p->name, name); strcpy((char*)p->name, name);
if(qstrcmp(type, "bool") == 0) if(tqstrcmp(type, "bool") == 0)
p->type = &static_QUType_bool; p->type = &static_QUType_bool;
else if(qstrcmp(type, "int") == 0) else if(tqstrcmp(type, "int") == 0)
p->type = &static_QUType_int; p->type = &static_QUType_int;
else if(qstrcmp(type, "double") == 0) else if(tqstrcmp(type, "double") == 0)
p->type = &static_QUType_double; p->type = &static_QUType_double;
else if(qstrcmp(type, "char*") == 0 || qstrcmp(type, "const char*") == 0) else if(tqstrcmp(type, "char*") == 0 || tqstrcmp(type, "const char*") == 0)
p->type = &static_QUType_charstar; p->type = &static_QUType_charstar;
else if(qstrcmp(type, "TQString") == 0 || qstrcmp(type, "TQString&") == 0 || else if(tqstrcmp(type, "TQString") == 0 || tqstrcmp(type, "TQString&") == 0 ||
qstrcmp(type, "const TQString") == 0 || qstrcmp(type, "const TQString&") == 0) tqstrcmp(type, "const TQString") == 0 || tqstrcmp(type, "const TQString&") == 0)
p->type = &static_QUType_TQString; p->type = &static_QUType_TQString;
else else
p->type = &static_QUType_ptr; p->type = &static_QUType_ptr;
@ -2503,10 +2503,10 @@ findAllMethods(int argc, VALUE * argv, VALUE /*self*/)
#define PUSH_QTRUBY_METHOD \ #define PUSH_QTRUBY_METHOD \
if ( (methodRef.flags & (Smoke::mf_internal|Smoke::mf_ctor|Smoke::mf_dtor)) == 0 \ if ( (methodRef.flags & (Smoke::mf_internal|Smoke::mf_ctor|Smoke::mf_dtor)) == 0 \
&& qstrcmp(qt_Smoke->methodNames[methodRef.name], "operator=") != 0 \ && tqstrcmp(qt_Smoke->methodNames[methodRef.name], "operator=") != 0 \
&& qstrcmp(qt_Smoke->methodNames[methodRef.name], "operator!=") != 0 \ && tqstrcmp(qt_Smoke->methodNames[methodRef.name], "operator!=") != 0 \
&& qstrcmp(qt_Smoke->methodNames[methodRef.name], "operator--") != 0 \ && tqstrcmp(qt_Smoke->methodNames[methodRef.name], "operator--") != 0 \
&& qstrcmp(qt_Smoke->methodNames[methodRef.name], "operator++") != 0 \ && tqstrcmp(qt_Smoke->methodNames[methodRef.name], "operator++") != 0 \
&& tqstrncmp(qt_Smoke->methodNames[methodRef.name], "operator ", strlen("operator ")) != 0 \ && tqstrncmp(qt_Smoke->methodNames[methodRef.name], "operator ", strlen("operator ")) != 0 \
&& ( (flags == 0 && (methodRef.flags & (Smoke::mf_static|Smoke::mf_enum|Smoke::mf_protected)) == 0) \ && ( (flags == 0 && (methodRef.flags & (Smoke::mf_static|Smoke::mf_enum|Smoke::mf_protected)) == 0) \
|| ( flags == Smoke::mf_static \ || ( flags == Smoke::mf_static \
@ -2737,7 +2737,7 @@ create_qobject_class(VALUE /*self*/, VALUE package_value)
if (TQString(package).startsWith("TQt::")) { if (TQString(package).startsWith("TQt::")) {
klass = rb_define_class_under(qt_module, package+strlen("TQt::"), qt_base_class); klass = rb_define_class_under(qt_module, package+strlen("TQt::"), qt_base_class);
if (qstrcmp(package, "TQt::Application") == 0) { if (tqstrcmp(package, "TQt::Application") == 0) {
rb_define_singleton_method(klass, "new", (VALUE (*) (...)) new_qapplication, -1); rb_define_singleton_method(klass, "new", (VALUE (*) (...)) new_qapplication, -1);
rb_define_method(klass, "ARGV", (VALUE (*) (...)) qapplication_argv, 0); rb_define_method(klass, "ARGV", (VALUE (*) (...)) qapplication_argv, 0);
} }
@ -2778,16 +2778,16 @@ create_qt_class(VALUE /*self*/, VALUE package_value)
klass = kde_package_to_class(package, qt_base_class); klass = kde_package_to_class(package, qt_base_class);
} }
if (qstrcmp(package, "TQt::MetaObject") == 0) { if (tqstrcmp(package, "TQt::MetaObject") == 0) {
qmetaobject_class = klass; qmetaobject_class = klass;
} else if (qstrcmp(package, "TQt::Variant") == 0) { } else if (tqstrcmp(package, "TQt::Variant") == 0) {
qvariant_class = klass; qvariant_class = klass;
rb_define_singleton_method(qvariant_class, "new", (VALUE (*) (...)) new_qvariant, -1); rb_define_singleton_method(qvariant_class, "new", (VALUE (*) (...)) new_qvariant, -1);
} else if (qstrcmp(package, "TQt::ByteArray") == 0) { } else if (tqstrcmp(package, "TQt::ByteArray") == 0) {
rb_define_method(klass, "data", (VALUE (*) (...)) qbytearray_data, 0); rb_define_method(klass, "data", (VALUE (*) (...)) qbytearray_data, 0);
rb_define_method(klass, "size", (VALUE (*) (...)) qbytearray_size, 0); rb_define_method(klass, "size", (VALUE (*) (...)) qbytearray_size, 0);
rb_define_method(klass, "setRawData", (VALUE (*) (...)) qbytearray_setRawData, 1); rb_define_method(klass, "setRawData", (VALUE (*) (...)) qbytearray_setRawData, 1);
} else if (qstrcmp(package, "TQt::Char") == 0) { } else if (tqstrcmp(package, "TQt::Char") == 0) {
rb_define_method(klass, "to_s", (VALUE (*) (...)) qchar_to_s, 0); rb_define_method(klass, "to_s", (VALUE (*) (...)) qchar_to_s, 0);
} }

@ -184,15 +184,15 @@ smokeruby_free(void * p)
unmapPointer(o, o->classId, 0); unmapPointer(o, o->classId, 0);
object_count --; object_count --;
if ( qstrcmp(className, "TQObject") == 0 if ( tqstrcmp(className, "TQObject") == 0
|| qstrcmp(className, "TQListBoxItem") == 0 || tqstrcmp(className, "TQListBoxItem") == 0
|| qstrcmp(className, "TQStyleSheetItem") == 0 || tqstrcmp(className, "TQStyleSheetItem") == 0
|| qstrcmp(className, "KCommand") == 0 || tqstrcmp(className, "KCommand") == 0
|| qstrcmp(className, "KNamedCommand") == 0 || tqstrcmp(className, "KNamedCommand") == 0
|| qstrcmp(className, "KMacroCommand") == 0 || tqstrcmp(className, "KMacroCommand") == 0
|| qstrcmp(className, "KAboutData") == 0 || tqstrcmp(className, "KAboutData") == 0
|| qstrcmp(className, "KCmdLineArgs") == 0 || tqstrcmp(className, "KCmdLineArgs") == 0
|| qstrcmp(className, "TQSqlCursor") == 0 ) || tqstrcmp(className, "TQSqlCursor") == 0 )
{ {
// Don't delete instances of these classes for now // Don't delete instances of these classes for now
free(o); free(o);
@ -203,19 +203,19 @@ smokeruby_free(void * p)
free(o); free(o);
return; return;
} }
} else if (qstrcmp(className, "TQIconViewItem") == 0) { } else if (tqstrcmp(className, "TQIconViewItem") == 0) {
TQIconViewItem * item = (TQIconViewItem *) o->ptr; TQIconViewItem * item = (TQIconViewItem *) o->ptr;
if (item->iconView() != 0) { if (item->iconView() != 0) {
free(o); free(o);
return; return;
} }
} else if (qstrcmp(className, "TQCheckListItem") == 0) { } else if (tqstrcmp(className, "TQCheckListItem") == 0) {
TQCheckListItem * item = (TQCheckListItem *) o->ptr; TQCheckListItem * item = (TQCheckListItem *) o->ptr;
if (item->parent() != 0 || item->listView() != 0) { if (item->parent() != 0 || item->listView() != 0) {
free(o); free(o);
return; return;
} }
} else if (qstrcmp(className, "TQListViewItem") == 0) { } else if (tqstrcmp(className, "TQListViewItem") == 0) {
TQListViewItem * item = (TQListViewItem *) o->ptr; TQListViewItem * item = (TQListViewItem *) o->ptr;
if (item->parent() != 0 || item->listView() != 0) { if (item->parent() != 0 || item->listView() != 0) {
free(o); free(o);
@ -227,7 +227,7 @@ smokeruby_free(void * p)
free(o); free(o);
return; return;
} }
} else if (qstrcmp(className, "TQPopupMenu") == 0) { } else if (tqstrcmp(className, "TQPopupMenu") == 0) {
TQPopupMenu * item = (TQPopupMenu *) o->ptr; TQPopupMenu * item = (TQPopupMenu *) o->ptr;
if (item->parentWidget(false) != 0) { if (item->parentWidget(false) != 0) {
free(o); free(o);
@ -401,7 +401,7 @@ matches_arg(Smoke *smoke, Smoke::Index meth, Smoke::Index argidx, const char *ar
{ {
Smoke::Index *arg = smoke->argumentList + smoke->methods[meth].args + argidx; Smoke::Index *arg = smoke->argumentList + smoke->methods[meth].args + argidx;
SmokeType type = SmokeType(smoke, *arg); SmokeType type = SmokeType(smoke, *arg);
return type.name() && qstrcmp(type.name(), argtype) == 0; return type.name() && tqstrcmp(type.name(), argtype) == 0;
} }
void * void *
@ -809,9 +809,9 @@ static void
init_codec() { init_codec() {
VALUE temp = rb_gv_get("$KCODE"); VALUE temp = rb_gv_get("$KCODE");
KCODE = StringValuePtr(temp); KCODE = StringValuePtr(temp);
if (qstrcmp(KCODE, "EUC") == 0) { if (tqstrcmp(KCODE, "EUC") == 0) {
codec = TQTextCodec::codecForName("eucJP"); codec = TQTextCodec::codecForName("eucJP");
} else if (qstrcmp(KCODE, "SJIS") == 0) { } else if (tqstrcmp(KCODE, "SJIS") == 0) {
codec = TQTextCodec::codecForName("Shift-JIS"); codec = TQTextCodec::codecForName("Shift-JIS");
} }
} }
@ -823,13 +823,13 @@ qstringFromRString(VALUE rstring) {
} }
TQString * s; TQString * s;
if (qstrcmp(KCODE, "UTF8") == 0) if (tqstrcmp(KCODE, "UTF8") == 0)
s = new TQString(TQString::fromUtf8(StringValuePtr(rstring), RSTRING(rstring)->len)); s = new TQString(TQString::fromUtf8(StringValuePtr(rstring), RSTRING(rstring)->len));
else if (qstrcmp(KCODE, "EUC") == 0) else if (tqstrcmp(KCODE, "EUC") == 0)
s = new TQString(codec->toUnicode(StringValuePtr(rstring))); s = new TQString(codec->toUnicode(StringValuePtr(rstring)));
else if (qstrcmp(KCODE, "SJIS") == 0) else if (tqstrcmp(KCODE, "SJIS") == 0)
s = new TQString(codec->toUnicode(StringValuePtr(rstring))); s = new TQString(codec->toUnicode(StringValuePtr(rstring)));
else if(qstrcmp(KCODE, "NONE") == 0) else if(tqstrcmp(KCODE, "NONE") == 0)
s = new TQString(TQString::fromLatin1(StringValuePtr(rstring))); s = new TQString(TQString::fromLatin1(StringValuePtr(rstring)));
else else
s = new TQString(TQString::fromLocal8Bit(StringValuePtr(rstring), RSTRING(rstring)->len)); s = new TQString(TQString::fromLocal8Bit(StringValuePtr(rstring), RSTRING(rstring)->len));
@ -842,13 +842,13 @@ rstringFromTQString(TQString * s) {
init_codec(); init_codec();
} }
if (qstrcmp(KCODE, "UTF8") == 0) if (tqstrcmp(KCODE, "UTF8") == 0)
return rb_str_new2(s->utf8()); return rb_str_new2(s->utf8());
else if (qstrcmp(KCODE, "EUC") == 0) else if (tqstrcmp(KCODE, "EUC") == 0)
return rb_str_new2(codec->fromUnicode(*s)); return rb_str_new2(codec->fromUnicode(*s));
else if (qstrcmp(KCODE, "SJIS") == 0) else if (tqstrcmp(KCODE, "SJIS") == 0)
return rb_str_new2(codec->fromUnicode(*s)); return rb_str_new2(codec->fromUnicode(*s));
else if (qstrcmp(KCODE, "NONE") == 0) else if (tqstrcmp(KCODE, "NONE") == 0)
return rb_str_new2(s->latin1()); return rb_str_new2(s->latin1());
else else
return rb_str_new2(s->local8Bit()); return rb_str_new2(s->local8Bit());
@ -1779,7 +1779,7 @@ void marshall_ValueItemList(Marshall *m) {
smokeruby_object *o = value_obj_info(item); smokeruby_object *o = value_obj_info(item);
// Special case for the TQValueList<TQVariant> type // Special case for the TQValueList<TQVariant> type
if ( qstrcmp(ItemSTR, "TQVariant") == 0 if ( tqstrcmp(ItemSTR, "TQVariant") == 0
&& (!o || !o->ptr || o->classId != o->smoke->idClass("TQVariant")) ) && (!o || !o->ptr || o->classId != o->smoke->idClass("TQVariant")) )
{ {
// If the value isn't a TQt::Variant, then try and construct // If the value isn't a TQt::Variant, then try and construct

@ -66,7 +66,7 @@ public:
bool operator ==(const SmokeType &b) const { bool operator ==(const SmokeType &b) const {
const SmokeType &a = *this; const SmokeType &a = *this;
if(a.name() == b.name()) return true; if(a.name() == b.name()) return true;
if(a.name() && b.name() && qstrcmp(a.name(), b.name()) == 0) if(a.name() && b.name() && tqstrcmp(a.name(), b.name()) == 0)
return true; return true;
return false; return false;
} }
@ -100,7 +100,7 @@ public:
bool operator ==(const SmokeClass &b) const { bool operator ==(const SmokeClass &b) const {
const SmokeClass &a = *this; const SmokeClass &a = *this;
if(a.className() == b.className()) return true; if(a.className() == b.className()) return true;
if(a.className() && b.className() && qstrcmp(a.className(), b.className()) == 0) if(a.className() && b.className() && tqstrcmp(a.className(), b.className()) == 0)
return true; return true;
return false; return false;
} }

Loading…
Cancel
Save