/platform/external/webkit/WebCore/bridge/qt/qt_instance.h

https://github.com/aharish/totoro-gb-opensource-update2 · C Header · 95 lines · 54 code · 23 blank · 18 comment · 0 complexity · 9b5ae2f2d663b7721fc6ea68bea9355f MD5 · raw file

  1. /*
  2. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. *
  18. */
  19. #ifndef BINDINGS_QT_INSTANCE_H_
  20. #define BINDINGS_QT_INSTANCE_H_
  21. #include "Bridge.h"
  22. #include "runtime_root.h"
  23. #include <QtScript/qscriptengine.h>
  24. #include <qhash.h>
  25. #include <qpointer.h>
  26. #include <qset.h>
  27. namespace JSC {
  28. namespace Bindings {
  29. class QtClass;
  30. class QtField;
  31. class QtRuntimeMetaMethod;
  32. class QtInstance : public Instance {
  33. public:
  34. ~QtInstance();
  35. virtual Class* getClass() const;
  36. virtual RuntimeObjectImp* newRuntimeObject(ExecState*);
  37. virtual void begin();
  38. virtual void end();
  39. virtual JSValue valueOf(ExecState*) const;
  40. virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
  41. void markAggregate(MarkStack&);
  42. virtual JSValue invokeMethod(ExecState*, const MethodList&, const ArgList&);
  43. virtual void getPropertyNames(ExecState*, PropertyNameArray&);
  44. JSValue stringValue(ExecState* exec) const;
  45. JSValue numberValue(ExecState* exec) const;
  46. JSValue booleanValue() const;
  47. QObject* getObject() const { return m_object; }
  48. QObject* hashKey() const { return m_hashkey; }
  49. static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership);
  50. virtual bool getOwnPropertySlot(JSObject*, ExecState*, const Identifier&, PropertySlot&);
  51. virtual void put(JSObject*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
  52. void removeCachedMethod(JSObject*);
  53. static QtInstance* getInstance(JSObject*);
  54. private:
  55. static PassRefPtr<QtInstance> create(QObject *instance, PassRefPtr<RootObject> rootObject, QScriptEngine::ValueOwnership ownership)
  56. {
  57. return adoptRef(new QtInstance(instance, rootObject, ownership));
  58. }
  59. friend class QtClass;
  60. friend class QtField;
  61. QtInstance(QObject*, PassRefPtr<RootObject>, QScriptEngine::ValueOwnership ownership); // Factory produced only..
  62. mutable QtClass* m_class;
  63. QPointer<QObject> m_object;
  64. QObject* m_hashkey;
  65. mutable QHash<QByteArray, JSObject*> m_methods;
  66. mutable QHash<QString, QtField*> m_fields;
  67. mutable QtRuntimeMetaMethod* m_defaultMethod;
  68. QScriptEngine::ValueOwnership m_ownership;
  69. };
  70. } // namespace Bindings
  71. } // namespace JSC
  72. #endif