#ifndef _JNI_CLASS_H_
#define _JNI_CLASS_H_
#include <CoreFoundation/CoreFoundation.h>
#include <JavaVM/jni.h>
#include <runtime.h>
#include <jni_runtime.h>
#include <runtime.h>
namespace KJS {
namespace Bindings {
class JavaClass : public Class
{
protected:
void _commonInit (jobject aClass);
JavaClass (const char *name);
JavaClass (jobject aClass);
public:
static JavaClass *classForInstance (jobject anInstance);
static JavaClass *classForName (const char *name);
void _commonDelete() {
free((void *)_name);
CFRelease (_fields);
CFRelease (_methods);
delete [] _constructors;
}
~JavaClass () {
_commonDelete();
}
void _commonCopy(const JavaClass &other) {
long i;
_name = strdup (other._name);
_methods = CFDictionaryCreateCopy (NULL, other._methods);
_fields = CFDictionaryCreateCopy (NULL, other._fields);
_numConstructors = other._numConstructors;
_constructors = new JavaConstructor[_numConstructors];
for (i = 0; i < _numConstructors; i++) {
_constructors[i] = other._constructors[i];
}
}
JavaClass (const JavaClass &other)
: Class() {
_commonCopy (other);
};
JavaClass &operator=(const JavaClass &other)
{
if (this == &other)
return *this;
_commonDelete();
_commonCopy (other);
return *this;
}
virtual const char *name() const { return _name; };
virtual MethodList *methodsNamed(const char *name) const;
virtual Field *fieldNamed(const char *name) const;
virtual Constructor *constructorAt(long i) const {
return &_constructors[i];
};
virtual long numConstructors() const { return _numConstructors; };
void setClassName(const char *n);
bool isNumberClass() const;
bool isBooleanClass() const;
bool isStringClass() const;
private:
const char *_name;
CFDictionaryRef _fields;
CFDictionaryRef _methods;
JavaConstructor *_constructors;
long _numConstructors;
};
}
}
#endif