/***************************************************************************
                            QMetaObject.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <qtc/qt_QMetaObject.h>
#include <qtobjc/QMetaObject.h>
#include <qtobjc/QMetaProperty.h>

@implementation  QMetaObject

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


- initWithText: (NSString *)class_name superclass: (QMetaObject *)superclass slot_data: (QMetaData*)slot_data n_slots: (int)n_slots signal_data: (QMetaData*)signal_data n_signals: (int)n_signals prop_data: (QMetaProperty*)prop_data n_props: (int)n_props enum_data: (QMetaEnum*)enum_data n_enums: (int)n_enums class_info: (QClassInfo*)class_info n_info: (int)n_info
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QMetaObject((char*) [class_name cString], (qt_QMetaObject *) [superclass qt], (qt_QMetaData*) [slot_data qt], (int)n_slots, (qt_QMetaData*) [signal_data qt], (int)n_signals, (qt_QMetaProperty*) [prop_data qt], (int)n_props, (qt_QMetaEnum*) [enum_data qt], (int)n_enums, (qt_QClassInfo*) [class_info qt], (int)n_info)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			qt_del_QMetaObject((qt_QMetaObject *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) className
{
	return (NSString *) [NSString stringWithCString: qt_QMetaObject_className((qt_QMetaObject *)[self qt])];
}

- (NSString *) superClassName
{
	return (NSString *) [NSString stringWithCString: qt_QMetaObject_superClassName((qt_QMetaObject *)[self qt])];
}

- (QMetaObject*) superClass
{
	return (QMetaObject*) [QtSupport objectForQtKey: qt_QMetaObject_superClass((qt_QMetaObject *)[self qt]) withClass: [QMetaObject class] allocatedInObjcWorld: YES];
}

- (BOOL) inherits: (NSString *)clname
{
	return (BOOL) qt_QMetaObject_inherits((qt_QMetaObject *)[self qt], (char*) [clname cString]);
}

- (int) numSlots: (BOOL)super
{
	return (int) qt_QMetaObject_numSlots((qt_QMetaObject *)[self qt], (int)super);
}

- (int) numSlots
{
	return (int) qt_QMetaObject_numSlots((qt_QMetaObject *)[self qt], 0);
}

- (int) numSignals: (BOOL)super
{
	return (int) qt_QMetaObject_numSignals((qt_QMetaObject *)[self qt], (int)super);
}

- (int) numSignals
{
	return (int) qt_QMetaObject_numSignals((qt_QMetaObject *)[self qt], 0);
}

- (int) findSlot: (NSString *)arg1 super: (BOOL)super
{
	return (int) qt_QMetaObject_findSlot((qt_QMetaObject *)[self qt], (char*) [arg1 cString], (int)super);
}

- (int) findSlot: (NSString *)arg1 
{
	return (int) qt_QMetaObject_findSlot((qt_QMetaObject *)[self qt], (char*) [arg1 cString], 0);
}

- (int) findSignal: (NSString *)arg1 super: (BOOL)super
{
	return (int) qt_QMetaObject_findSignal((qt_QMetaObject *)[self qt], (char*) [arg1 cString], (int)super);
}

- (int) findSignal: (NSString *)arg1 
{
	return (int) qt_QMetaObject_findSignal((qt_QMetaObject *)[self qt], (char*) [arg1 cString], 0);
}

- (QMetaData*) slotAt: (int)index super: (BOOL)super
{
	return (QMetaData*) [QtSupport objectForQtKey: qt_QMetaObject_slot((qt_QMetaObject *)[self qt], (int)index, (int)super) withClass: [QMetaData class] allocatedInObjcWorld: YES];
}

- (QMetaData*) slotAt: (int)index
{
	return (QMetaData*) [QtSupport objectForQtKey: qt_QMetaObject_slot((qt_QMetaObject *)[self qt], (int)index, 0) withClass: [QMetaData class] allocatedInObjcWorld: YES];
}

- (QMetaData*) signalAt: (int)index super: (BOOL)super
{
	return (QMetaData*) [QtSupport objectForQtKey: qt_QMetaObject_signal((qt_QMetaObject *)[self qt], (int)index, (int)super) withClass: [QMetaData class] allocatedInObjcWorld: YES];
}

- (QMetaData*) signalAt: (int)index
{
	return (QMetaData*) [QtSupport objectForQtKey: qt_QMetaObject_signal((qt_QMetaObject *)[self qt], (int)index, 0) withClass: [QMetaData class] allocatedInObjcWorld: YES];
}

- (NSArray *) slotNames: (BOOL)super
{
static qt_QStrList * _qlist = 0L;
	_qlist = qt_QMetaObject_slotNames((qt_QMetaObject *)[self qt], (int)super);
	return (NSArray *) [NSMutableArray arrayWithQStrList: _qlist];
}

- (NSArray *) signalNames: (BOOL)super
{
static qt_QStrList * _qlist = 0L;
	_qlist = qt_QMetaObject_signalNames((qt_QMetaObject *)[self qt], (int)super);
	return (NSArray *) [NSMutableArray arrayWithQStrList: _qlist];
}

- (int) slotOffset
{
	return (int) qt_QMetaObject_slotOffset((qt_QMetaObject *)[self qt]);
}

- (int) signalOffset
{
	return (int) qt_QMetaObject_signalOffset((qt_QMetaObject *)[self qt]);
}

- (int) propertyOffset
{
	return (int) qt_QMetaObject_propertyOffset((qt_QMetaObject *)[self qt]);
}

- (int) numClassInfo: (BOOL)super
{
	return (int) qt_QMetaObject_numClassInfo((qt_QMetaObject *)[self qt], (int)super);
}

- (int) numClassInfo
{
	return (int) qt_QMetaObject_numClassInfo((qt_QMetaObject *)[self qt], 0);
}

- (QClassInfo*) classInfoAt: (int)index super: (BOOL)super
{
	return (QClassInfo*) [QtSupport objectForQtKey: qt_QMetaObject_classInfo((qt_QMetaObject *)[self qt], (int)index, (int)super) withClass: [QClassInfo class] allocatedInObjcWorld: YES];
}

- (QClassInfo*) classInfoAt: (int)index
{
	return (QClassInfo*) [QtSupport objectForQtKey: qt_QMetaObject_classInfo((qt_QMetaObject *)[self qt], (int)index, 0) withClass: [QClassInfo class] allocatedInObjcWorld: YES];
}

- (NSString *) classInfo: (NSString *)name super: (BOOL)super
{
	return (NSString *) [NSString stringWithCString: qt_QMetaObject_classInfo1((qt_QMetaObject *)[self qt], (char*) [name cString], (int)super)];
}

- (QMetaProperty*) property: (int)index super: (BOOL)super
{
	return (QMetaProperty*) [QtSupport objectForQtKey: qt_QMetaObject_property((qt_QMetaObject *)[self qt], (int)index, (int)super) withClass: [QMetaProperty class] allocatedInObjcWorld: YES];
}

- (QMetaProperty*) property: (int)index 
{
	return (QMetaProperty*) [QtSupport objectForQtKey: qt_QMetaObject_property((qt_QMetaObject *)[self qt], (int)index, 0) withClass: [QMetaProperty class] allocatedInObjcWorld: YES];
}

- (int) findProperty: (NSString *)name super: (BOOL)super
{
	return (int) qt_QMetaObject_findProperty((qt_QMetaObject *)[self qt], (char*) [name cString], (int)super);
}

- (int) findProperty: (NSString *)name 
{
	return (int) qt_QMetaObject_findProperty((qt_QMetaObject *)[self qt], (char*) [name cString], 0);
}

- (int) indexOfProperty: (QMetaProperty*)arg1 super: (BOOL)super
{
	return (int) qt_QMetaObject_indexOfProperty((qt_QMetaObject *)[self qt], (qt_QMetaProperty*) [arg1 qt], (int)super);
}

- (int) indexOfProperty: (QMetaProperty*)arg1 
{
	return (int) qt_QMetaObject_indexOfProperty((qt_QMetaObject *)[self qt], (qt_QMetaProperty*) [arg1 qt], 0);
}

- (QMetaProperty*) resolveProperty: (QMetaProperty*)arg1
{
	return (QMetaProperty*) [QtSupport objectForQtKey: qt_QMetaObject_resolveProperty((qt_QMetaObject *)[self qt], (qt_QMetaProperty*) [arg1 qt]) withClass: [QMetaProperty class] allocatedInObjcWorld: YES];
}

//- (int) resolveProperty: (int)arg1
//{
//	return (int) qt_QMetaObject_resolveProperty1((qt_QMetaObject *)[self qt], (int)arg1);
//}

- (NSArray *) propertyNames: (BOOL)super
{
static qt_QStrList * _qlist = 0L;
	_qlist = qt_QMetaObject_propertyNames((qt_QMetaObject *)[self qt], (int)super);
	return (NSArray *) [NSMutableArray arrayWithQStrList: _qlist];
}

- (int) numProperties: (BOOL)super
{
	return (int) qt_QMetaObject_numProperties((qt_QMetaObject *)[self qt], (int)super);
}

- (int) numProperties
{
	return (int) qt_QMetaObject_numProperties((qt_QMetaObject *)[self qt], 0);
}

- (QMetaEnum*) enumerator: (NSString *)name super: (BOOL)super
{
	return (QMetaEnum*) [QtSupport objectForQtKey: qt_QMetaObject_enumerator((qt_QMetaObject *)[self qt], (char*) [name cString], (int)super) withClass: [QMetaEnum class] allocatedInObjcWorld: YES];
}

- (QMetaEnum*) enumerator: (NSString *)name 
{
	return (QMetaEnum*) [QtSupport objectForQtKey: qt_QMetaObject_enumerator((qt_QMetaObject *)[self qt], (char*) [name cString], 0) withClass: [QMetaEnum class] allocatedInObjcWorld: YES];
}

//+ (QMetaObject*) new_metaobject: (NSString *)arg1 metaobject: (QMetaObject *)arg2 const: (QMetaData*)const int: (int)arg3 const: (QMetaData*)const int: (int)arg4 prop_data: (QMetaProperty*)prop_data n_props: (int)n_props enum_data: (QMetaEnum*)enum_data n_enums: (int)n_enums class_info: (QClassInfo*)class_info n_info: (int)n_info
//{
//	return (QMetaObject*) [QtSupport objectForQtKey: qt_QMetaObject_new_metaobject((char*) [arg1 cString], (qt_QMetaObject *) [arg2 qt], (qt_QMetaData*) [const qt], (int)arg3, (qt_QMetaData*) [const qt], (int)arg4, (qt_QMetaProperty*) [prop_data qt], (int)n_props, (qt_QMetaEnum*) [enum_data qt], (int)n_enums, (qt_QClassInfo*) [class_info qt], (int)n_info) withClass: [QMetaObject class] allocatedInObjcWorld: YES];
//}

+ (QMetaObject*) metaObject: (NSString *)class_name
{
	return (QMetaObject*) [QtSupport objectForQtKey: qt_QMetaObject_metaObject((char*) [class_name cString]) withClass: [QMetaObject class] allocatedInObjcWorld: YES];
}

@end
