This source file includes following definitions.
- hasProperty
- getProperty
- NPP_GetValue
#include "PluginTest.h"
#include <stdio.h>
#include <string.h>
using namespace std;
class PluginScriptableObjectOverridesAllProperties : public PluginTest {
public:
PluginScriptableObjectOverridesAllProperties(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
{
}
private:
class PluginObject : public Object<PluginObject> {
public:
PluginObject()
{
}
virtual ~PluginObject()
{
}
bool hasProperty(NPIdentifier propertyName)
{
return true;
}
bool getProperty(NPIdentifier propertyName, NPVariant* result)
{
static const char* message = "My name is ";
char* propertyString = pluginTest()->NPN_UTF8FromIdentifier(propertyName);
int bufferLength = strlen(propertyString) + strlen(message) + 1;
char* resultBuffer = static_cast<char*>(pluginTest()->NPN_MemAlloc(bufferLength));
snprintf(resultBuffer, bufferLength, "%s%s", message, propertyString);
STRINGZ_TO_NPVARIANT(resultBuffer, *result);
return true;
}
};
virtual NPError NPP_GetValue(NPPVariable variable, void *value) OVERRIDE
{
if (variable != NPPVpluginScriptableNPObject)
return NPERR_GENERIC_ERROR;
*(NPObject**)value = PluginObject::create(this);
return NPERR_NO_ERROR;
}
};
static PluginTest::Register<PluginScriptableObjectOverridesAllProperties> pluginScriptableObjectOverridesAllProperties("plugin-scriptable-object-overrides-all-properties");