Author: everaldo
Date: 2007-06-13 01:57:33 -0400 (Wed, 13 Jun 2007)
New Revision: 79378

Modified:
   trunk/moon/plugin/ChangeLog
   trunk/moon/plugin/plugin-class.cpp
   trunk/moon/plugin/plugin-class.h
Log:
2007-06-13  Everaldo Canuto  <[EMAIL PROTECTED]>

        * plugin-class.cpp, plugin-class.h: 
        - Fix IndexOf method.
        - Create and uses macros PLUGIN_PROPERTIES and PLUGIN_METHODS to define 
        properties and methods.
        - Uses arrays to define properties and methods.
        - Create NPID macro to get string identifier.



Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-06-13 04:02:26 UTC (rev 79377)
+++ trunk/moon/plugin/ChangeLog 2007-06-13 05:57:33 UTC (rev 79378)
@@ -1,3 +1,12 @@
+2007-06-13  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * plugin-class.cpp, plugin-class.h: 
+       - Fix IndexOf method.
+       - Create and uses macros PLUGIN_PROPERTIES and PLUGIN_METHODS to define 
+       properties and methods.
+       - Uses arrays to define properties and methods.
+       - Create NPID macro to get string identifier.
+
 2007-06-12  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * plugin-class.cpp:  Fix dependency of PLUGINROOTCLASS_PCOUNT in 
property

Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp  2007-06-13 04:02:26 UTC (rev 79377)
+++ trunk/moon/plugin/plugin-class.cpp  2007-06-13 05:57:33 UTC (rev 79378)
@@ -204,10 +204,8 @@
 }
 
 int
-PluginClass::IndexOf (NPIdentifier name, const char *const names[])
+PluginClass::IndexOf (NPIdentifier name, const char *const names[], int count)
 {
-       int count = (sizeof (name) / sizeof (char *));
-
        for (int i = 0; i < count; i++) {
                if (name == NPN_GetStringIdentifier (names [i]))
                        return i;
@@ -218,70 +216,46 @@
 
 /*** PluginRootClass 
**********************************************************/
 
-static const char *const PluginRootClassPropertyNames [] = 
-{
-       "settings",
-       "content",
-       "version"
-};
-
 PluginRootClass::PluginRootClass (NPP instance)
 {
-       DEBUGMSG ("PluginRootClass::PluginRootClass");
-
        this->instance = instance;
        this->settings = new PluginSettings ();
        this->content = new PluginContent ();
 }
 
 bool
-PluginRootClass::ClassHasProperty (NPObject *npobj, NPIdentifier name)
-{
-       return IndexOf (name, PluginRootClassPropertyNames) > -1;
-}
-
-bool
 PluginRootClass::ClassGetProperty (NPObject *npobj, NPIdentifier name, 
NPVariant *result)
 {
-       int property = IndexOf (name, PluginRootClassPropertyNames);
-
-       if (name == NSID("settings"))
+       if (name == NPID ("settings"))
        {
-               NPObject *obj = NPN_CreateObject (this->instance, settings);
-
-               OBJECT_TO_NPVARIANT (obj, *result);
-
+               NPObject *object = NPN_CreateObject (this->instance, 
this->settings);
+               OBJECT_TO_NPVARIANT (object, *result);
                return true;
        } 
 
-       if (name == NPN_GetStringIdentifier ("version")) 
+       if (name == NPID ("content"))
        {
-               int len = strlen (PLUGIN_VERSION);
-               char *version = (char *) NPN_MemAlloc (len + 1);
-               memcpy (version, PLUGIN_VERSION, len + 1);
-               STRINGN_TO_NPVARIANT (version, len, *result);
-
+               NPObject *object = NPN_CreateObject (this->instance, 
this->content);
+               OBJECT_TO_NPVARIANT (object, *result);
                return true;
-       }
+       } 
 
        return false;
 }
 
-/*** PluginSettings 
***********************************************************/
-
 bool
-PluginSettings::ClassHasProperty (NPObject *npobj, NPIdentifier name)
+PluginRootClass::ClassInvoke (NPObject *npobj, NPIdentifier name, 
+                               const NPVariant *args, uint32_t argCount, 
NPVariant *result)
 {
-       if (name == NPN_GetStringIdentifier ("version"))
-               return true;
-
        return false;
 }
 
+/*** PluginSettings 
***********************************************************/
+
 bool
 PluginSettings::ClassGetProperty (NPObject *npobj, NPIdentifier name, 
NPVariant *result)
 {
-       if (name == NPN_GetStringIdentifier ("version")) 
+       if (name == NPID ("version")) 
        {
                int len = strlen (PLUGIN_VERSION);
                char *version = (char *) NPN_MemAlloc (len + 1);
@@ -297,18 +271,18 @@
 /*** PluginContent 
************************************************************/
 
 bool
-PluginContent::ClassHasProperty (NPObject *npobj, NPIdentifier name)
+PluginContent::ClassGetProperty (NPObject *npobj, NPIdentifier name, NPVariant 
*result)
 {
        return false;
 }
 
 bool
-PluginContent::ClassGetProperty (NPObject *npobj, NPIdentifier name, NPVariant 
*result)
+PluginContent::ClassInvoke (NPObject *npobj, NPIdentifier name, 
+                               const NPVariant *args, uint32_t argCount, 
NPVariant *result)
 {
        return false;
 }
 
-
 /*** PluginDependencyObject 
***************************************************/
 
 bool
@@ -363,5 +337,4 @@
        // TODO: convert_val_to_something_jscript_can_use ();
        //
        return TRUE;
-
 }

Modified: trunk/moon/plugin/plugin-class.h
===================================================================
--- trunk/moon/plugin/plugin-class.h    2007-06-13 04:02:26 UTC (rev 79377)
+++ trunk/moon/plugin/plugin-class.h    2007-06-13 05:57:33 UTC (rev 79378)
@@ -14,14 +14,27 @@
 
 /*** Macros 
*******************************************************************/
 
-#define NSID(x) NPN_GetStringIdentifier (x)
+#define NPID(x) NPN_GetStringIdentifier (x)
 
+#define PLUGIN_PROPERTIES(x) \
+       bool ClassHasProperty (NPObject *npobj, NPIdentifier name) \
+               { return IndexOf (name, x, (sizeof (x) / sizeof (char *))) > 
-1; }; \
+       virtual bool ClassGetProperty ( \
+               NPObject *npobj, NPIdentifier name, NPVariant *result);
+
+#define PLUGIN_METHODS(x) \
+       bool ClassHasMethod (NPObject *npobj, NPIdentifier name) \
+               { return IndexOf (name, x, (sizeof (x) / sizeof (char *))) > 
-1; }; \
+       virtual bool ClassInvoke ( \
+               NPObject *npobj, NPIdentifier name, const NPVariant *args,  \
+               uint32_t argCount, NPVariant *result);
+
 /*** PluginClass 
**************************************************************/
 
 class PluginClass : public NPClass
 {
  protected:
-       int IndexOf (NPIdentifier name, const char *const names[]);
+       int IndexOf (NPIdentifier name, const char *const names[], int count);
 
  public:
        PluginClass ();
@@ -44,24 +57,69 @@
 
 /*** PluginSettings 
***********************************************************/
 
+static const char *const PluginSettingsPropertyNames [7] = 
+{
+       "background",
+       "enableFramerateCounter",
+       "enableRedrawRegions",
+       "enableHtmlAccess",
+       "maxFrameRate",
+       "version",
+       "windowless"
+};
+
 class PluginSettings : public PluginClass
 {
  public:
-       virtual bool ClassHasProperty (NPObject *npobj, NPIdentifier name);
-       virtual bool ClassGetProperty (NPObject *npobj, NPIdentifier name, 
NPVariant *result);
+       PLUGIN_PROPERTIES (PluginSettingsPropertyNames);
 };
 
 /*** PluginContent 
************************************************************/
 
+static const char *const PluginContentPropertyNames [] = 
+{
+       "actualHeight",
+       "actualWidth",
+       "fullScreen"
+};
+
+static const char *const PluginContentMethodNames [] = 
+{
+       "createFromXaml",
+       "createFromXamlDownloader",
+       "findName"
+};
+
+// TODO:
+//onFullScreenChange = "eventhandlerFunction"
+//onResize = "eventhandlerFunction"
+
 class PluginContent : public PluginClass
 {
  public:
-       virtual bool ClassHasProperty (NPObject *npobj, NPIdentifier name);
-       virtual bool ClassGetProperty (NPObject *npobj, NPIdentifier name, 
NPVariant *result);
+       PLUGIN_PROPERTIES (PluginContentPropertyNames);
+       PLUGIN_METHODS (PluginContentMethodNames);
 };
 
 /*** PluginRootClass 
**********************************************************/
 
+static const char *const PluginRootClassPropertyNames [] = 
+{
+       "settings",
+       "content",
+       "initParams",
+       "isLoaded",
+       "source"
+};
+
+static const char *const PluginRootClassMethodNames [] = 
+{
+       "createObject"
+};
+
+// TODO:
+// onError = "eventhandlerFunction"
+
 class PluginRootClass : public PluginClass
 {
  private:
@@ -71,9 +129,9 @@
 
  public:
        PluginRootClass (NPP instance);
-
-       virtual bool ClassHasProperty (NPObject *npobj, NPIdentifier name);
-       virtual bool ClassGetProperty (NPObject *npobj, NPIdentifier name, 
NPVariant *result);
+       
+       PLUGIN_PROPERTIES (PluginRootClassPropertyNames);
+       PLUGIN_METHODS (PluginRootClassMethodNames);
 };
 
 /*** PluginDependencyObject 
***************************************************/

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to