variant -> value

This commit is contained in:
David Rose 2009-07-01 17:05:17 +00:00
parent 30b413df8b
commit 204467f5af
29 changed files with 604 additions and 604 deletions

View File

@ -19,41 +19,41 @@
p3d_lock.h p3d_plugin.h \
p3d_plugin_config.h \
p3d_plugin_common.h \
p3dBoolVariant.h \
p3dBoolValue.h \
p3dDownload.h p3dDownload.I \
p3dFileDownload.h p3dFileDownload.I \
p3dFileParams.h p3dFileParams.I \
p3dFloatVariant.h \
p3dFloatValue.h \
p3dInstance.h p3dInstance.I \
p3dInstanceManager.h p3dInstanceManager.I \
p3dIntVariant.h \
p3dListVariant.h \
p3dIntValue.h \
p3dListValue.h \
p3dMultifileReader.h p3dMultifileReader.I \
p3dPackage.h p3dPackage.I \
p3dSession.h p3dSession.I \
p3dSplashWindow.h p3dSplashWindow.I \
p3dStringVariant.h \
p3dVariant.h p3dVariant.I \
p3dStringValue.h \
p3dValue.h p3dValue.I \
p3dWinSplashWindow.h p3dWinSplashWindow.I \
p3dWindowParams.h p3dWindowParams.I
#define INCLUDED_SOURCES \
p3d_plugin.cxx \
p3dBoolVariant.cxx \
p3dBoolValue.cxx \
p3dDownload.cxx \
p3dFileDownload.cxx \
p3dFileParams.cxx \
p3dFloatVariant.cxx \
p3dFloatValue.cxx \
p3dInstance.cxx \
p3dInstanceManager.cxx \
p3dIntVariant.cxx \
p3dListVariant.cxx \
p3dIntValue.cxx \
p3dListValue.cxx \
p3dMultifileReader.cxx \
p3dPackage.cxx \
p3dSession.cxx \
p3dSplashWindow.cxx \
p3dStringVariant.cxx \
p3dVariant.cxx \
p3dStringValue.cxx \
p3dValue.cxx \
p3dWinSplashWindow.cxx \
p3dWindowParams.cxx

View File

@ -37,21 +37,21 @@ P3D_instance_start_func *P3D_instance_start;
P3D_instance_finish_func *P3D_instance_finish;
P3D_instance_setup_window_func *P3D_instance_setup_window;
P3D_variant_finish_func *P3D_variant_finish;
P3D_variant_copy_func *P3D_variant_copy;
P3D_new_none_variant_func *P3D_new_none_variant;
P3D_new_bool_variant_func *P3D_new_bool_variant;
P3D_variant_get_bool_func *P3D_variant_get_bool;
P3D_new_int_variant_func *P3D_new_int_variant;
P3D_variant_get_int_func *P3D_variant_get_int;
P3D_new_float_variant_func *P3D_new_float_variant;
P3D_variant_get_float_func *P3D_variant_get_float;
P3D_new_string_variant_func *P3D_new_string_variant;
P3D_variant_get_string_length_func *P3D_variant_get_string_length;
P3D_variant_extract_string_func *P3D_variant_extract_string;
P3D_new_list_variant_func *P3D_new_list_variant;
P3D_variant_get_list_length_func *P3D_variant_get_list_length;
P3D_variant_get_list_item_func *P3D_variant_get_list_item;
P3D_value_finish_func *P3D_value_finish;
P3D_value_copy_func *P3D_value_copy;
P3D_new_none_value_func *P3D_new_none_value;
P3D_new_bool_value_func *P3D_new_bool_value;
P3D_value_get_bool_func *P3D_value_get_bool;
P3D_new_int_value_func *P3D_new_int_value;
P3D_value_get_int_func *P3D_value_get_int;
P3D_new_float_value_func *P3D_new_float_value;
P3D_value_get_float_func *P3D_value_get_float;
P3D_new_string_value_func *P3D_new_string_value;
P3D_value_get_string_length_func *P3D_value_get_string_length;
P3D_value_extract_string_func *P3D_value_extract_string;
P3D_new_list_value_func *P3D_new_list_value;
P3D_value_get_list_length_func *P3D_value_get_list_length;
P3D_value_get_list_item_func *P3D_value_get_list_item;
P3D_instance_get_property_func *P3D_instance_get_property;
P3D_instance_get_property_list_func *P3D_instance_get_property_list;
P3D_instance_set_property_func *P3D_instance_set_property;
@ -185,21 +185,21 @@ load_plugin(const string &p3d_plugin_filename) {
P3D_instance_finish = (P3D_instance_finish_func *)get_func(module, "P3D_instance_finish");
P3D_instance_setup_window = (P3D_instance_setup_window_func *)get_func(module, "P3D_instance_setup_window");
P3D_variant_finish = (P3D_variant_finish_func *)get_func(module, "P3D_variant_finish");
P3D_variant_copy = (P3D_variant_copy_func *)get_func(module, "P3D_variant_copy");
P3D_new_none_variant = (P3D_new_none_variant_func *)get_func(module, "P3D_new_none_variant");
P3D_new_bool_variant = (P3D_new_bool_variant_func *)get_func(module, "P3D_new_bool_variant");
P3D_variant_get_bool = (P3D_variant_get_bool_func *)get_func(module, "P3D_variant_get_bool");
P3D_new_int_variant = (P3D_new_int_variant_func *)get_func(module, "P3D_new_int_variant");
P3D_variant_get_int = (P3D_variant_get_int_func *)get_func(module, "P3D_variant_get_int");
P3D_new_float_variant = (P3D_new_float_variant_func *)get_func(module, "P3D_new_float_variant");
P3D_variant_get_float = (P3D_variant_get_float_func *)get_func(module, "P3D_variant_get_float");
P3D_new_string_variant = (P3D_new_string_variant_func *)get_func(module, "P3D_new_string_variant");
P3D_variant_get_string_length = (P3D_variant_get_string_length_func *)get_func(module, "P3D_variant_get_string_length");
P3D_variant_extract_string = (P3D_variant_extract_string_func *)get_func(module, "P3D_variant_extract_string");
P3D_new_list_variant = (P3D_new_list_variant_func *)get_func(module, "P3D_new_list_variant");
P3D_variant_get_list_length = (P3D_variant_get_list_length_func *)get_func(module, "P3D_variant_get_list_length");
P3D_variant_get_list_item = (P3D_variant_get_list_item_func *)get_func(module, "P3D_variant_get_list_item");
P3D_value_finish = (P3D_value_finish_func *)get_func(module, "P3D_value_finish");
P3D_value_copy = (P3D_value_copy_func *)get_func(module, "P3D_value_copy");
P3D_new_none_value = (P3D_new_none_value_func *)get_func(module, "P3D_new_none_value");
P3D_new_bool_value = (P3D_new_bool_value_func *)get_func(module, "P3D_new_bool_value");
P3D_value_get_bool = (P3D_value_get_bool_func *)get_func(module, "P3D_value_get_bool");
P3D_new_int_value = (P3D_new_int_value_func *)get_func(module, "P3D_new_int_value");
P3D_value_get_int = (P3D_value_get_int_func *)get_func(module, "P3D_value_get_int");
P3D_new_float_value = (P3D_new_float_value_func *)get_func(module, "P3D_new_float_value");
P3D_value_get_float = (P3D_value_get_float_func *)get_func(module, "P3D_value_get_float");
P3D_new_string_value = (P3D_new_string_value_func *)get_func(module, "P3D_new_string_value");
P3D_value_get_string_length = (P3D_value_get_string_length_func *)get_func(module, "P3D_value_get_string_length");
P3D_value_extract_string = (P3D_value_extract_string_func *)get_func(module, "P3D_value_extract_string");
P3D_new_list_value = (P3D_new_list_value_func *)get_func(module, "P3D_new_list_value");
P3D_value_get_list_length = (P3D_value_get_list_length_func *)get_func(module, "P3D_value_get_list_length");
P3D_value_get_list_item = (P3D_value_get_list_item_func *)get_func(module, "P3D_value_get_list_item");
P3D_instance_get_property = (P3D_instance_get_property_func *)get_func(module, "P3D_instance_get_property");
P3D_instance_get_property_list = (P3D_instance_get_property_list_func *)get_func(module, "P3D_instance_get_property_list");
P3D_instance_set_property = (P3D_instance_set_property_func *)get_func(module, "P3D_instance_set_property");
@ -220,21 +220,21 @@ load_plugin(const string &p3d_plugin_filename) {
P3D_instance_finish == NULL ||
P3D_instance_setup_window == NULL ||
P3D_variant_finish == NULL ||
P3D_variant_copy == NULL ||
P3D_new_none_variant == NULL ||
P3D_new_bool_variant == NULL ||
P3D_variant_get_bool == NULL ||
P3D_new_int_variant == NULL ||
P3D_variant_get_int == NULL ||
P3D_new_float_variant == NULL ||
P3D_variant_get_float == NULL ||
P3D_new_string_variant == NULL ||
P3D_variant_get_string_length == NULL ||
P3D_variant_extract_string == NULL ||
P3D_new_list_variant == NULL ||
P3D_variant_get_list_length == NULL ||
P3D_variant_get_list_item == NULL ||
P3D_value_finish == NULL ||
P3D_value_copy == NULL ||
P3D_new_none_value == NULL ||
P3D_new_bool_value == NULL ||
P3D_value_get_bool == NULL ||
P3D_new_int_value == NULL ||
P3D_value_get_int == NULL ||
P3D_new_float_value == NULL ||
P3D_value_get_float == NULL ||
P3D_new_string_value == NULL ||
P3D_value_get_string_length == NULL ||
P3D_value_extract_string == NULL ||
P3D_new_list_value == NULL ||
P3D_value_get_list_length == NULL ||
P3D_value_get_list_item == NULL ||
P3D_instance_get_property == NULL ||
P3D_instance_get_property_list == NULL ||
P3D_instance_set_property == NULL ||
@ -289,21 +289,21 @@ unload_plugin() {
P3D_instance_finish = NULL;
P3D_instance_setup_window = NULL;
P3D_variant_finish = NULL;
P3D_variant_copy = NULL;
P3D_new_none_variant = NULL;
P3D_new_bool_variant = NULL;
P3D_variant_get_bool = NULL;
P3D_new_int_variant = NULL;
P3D_variant_get_int = NULL;
P3D_new_float_variant = NULL;
P3D_variant_get_float = NULL;
P3D_new_string_variant = NULL;
P3D_variant_get_string_length = NULL;
P3D_variant_extract_string = NULL;
P3D_new_list_variant = NULL;
P3D_variant_get_list_length = NULL;
P3D_variant_get_list_item = NULL;
P3D_value_finish = NULL;
P3D_value_copy = NULL;
P3D_new_none_value = NULL;
P3D_new_bool_value = NULL;
P3D_value_get_bool = NULL;
P3D_new_int_value = NULL;
P3D_value_get_int = NULL;
P3D_new_float_value = NULL;
P3D_value_get_float = NULL;
P3D_new_string_value = NULL;
P3D_value_get_string_length = NULL;
P3D_value_extract_string = NULL;
P3D_new_list_value = NULL;
P3D_value_get_list_length = NULL;
P3D_value_get_list_item = NULL;
P3D_instance_get_property = NULL;
P3D_instance_get_property_list = NULL;
P3D_instance_set_property = NULL;

View File

@ -26,21 +26,21 @@ extern P3D_instance_start_func *P3D_instance_start;
extern P3D_instance_finish_func *P3D_instance_finish;
extern P3D_instance_setup_window_func *P3D_instance_setup_window;
extern P3D_variant_finish_func *P3D_variant_finish;
extern P3D_variant_copy_func *P3D_variant_copy;
extern P3D_new_none_variant_func *P3D_new_none_variant;
extern P3D_new_bool_variant_func *P3D_new_bool_variant;
extern P3D_variant_get_bool_func *P3D_variant_get_bool;
extern P3D_new_int_variant_func *P3D_new_int_variant;
extern P3D_variant_get_int_func *P3D_variant_get_int;
extern P3D_new_float_variant_func *P3D_new_float_variant;
extern P3D_variant_get_float_func *P3D_variant_get_float;
extern P3D_new_string_variant_func *P3D_new_string_variant;
extern P3D_variant_get_string_length_func *P3D_variant_get_string_length;
extern P3D_variant_extract_string_func *P3D_variant_extract_string;
extern P3D_new_list_variant_func *P3D_new_list_variant;
extern P3D_variant_get_list_length_func *P3D_variant_get_list_length;
extern P3D_variant_get_list_item_func *P3D_variant_get_list_item;
extern P3D_value_finish_func *P3D_value_finish;
extern P3D_value_copy_func *P3D_value_copy;
extern P3D_new_none_value_func *P3D_new_none_value;
extern P3D_new_bool_value_func *P3D_new_bool_value;
extern P3D_value_get_bool_func *P3D_value_get_bool;
extern P3D_new_int_value_func *P3D_new_int_value;
extern P3D_value_get_int_func *P3D_value_get_int;
extern P3D_new_float_value_func *P3D_new_float_value;
extern P3D_value_get_float_func *P3D_value_get_float;
extern P3D_new_string_value_func *P3D_new_string_value;
extern P3D_value_get_string_length_func *P3D_value_get_string_length;
extern P3D_value_extract_string_func *P3D_value_extract_string;
extern P3D_new_list_value_func *P3D_new_list_value;
extern P3D_value_get_list_length_func *P3D_value_get_list_length;
extern P3D_value_get_list_item_func *P3D_value_get_list_item;
extern P3D_instance_get_property_func *P3D_instance_get_property;
extern P3D_instance_get_property_list_func *P3D_instance_get_property_list;
extern P3D_instance_set_property_func *P3D_instance_set_property;

View File

@ -1,4 +1,4 @@
// Filename: p3dBoolVariant.cxx
// Filename: p3dBoolValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,71 +12,71 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dBoolVariant.h"
#include "p3dBoolValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::Constructor
// Function: P3DBoolValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DBoolVariant::
P3DBoolVariant(bool value) :
P3DVariant(P3D_VT_bool),
P3DBoolValue::
P3DBoolValue(bool value) :
P3DValue(P3D_VT_bool),
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::Copy Constructor
// Function: P3DBoolValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DBoolVariant::
P3DBoolVariant(const P3DBoolVariant &copy) :
P3DVariant(copy),
P3DBoolValue::
P3DBoolValue(const P3DBoolValue &copy) :
P3DValue(copy),
_value(copy._value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::make_copy
// Function: P3DBoolValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DBoolVariant::
P3DValue *P3DBoolValue::
make_copy() {
return new P3DBoolVariant(*this);
return new P3DBoolValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::get_bool
// Function: P3DBoolValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DBoolVariant::
bool P3DBoolValue::
get_bool() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::get_int
// Function: P3DBoolValue::get_int
// Access: Public, Virtual
// Description: Returns the variant value coerced to an integer, if
// Description: Returns the value value coerced to an integer, if
// possible.
////////////////////////////////////////////////////////////////////
int P3DBoolVariant::
int P3DBoolValue::
get_int() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::make_string
// Function: P3DBoolValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DBoolVariant::
void P3DBoolValue::
make_string(string &value) const {
if (_value) {
value = "True";
@ -86,15 +86,15 @@ make_string(string &value) const {
}
////////////////////////////////////////////////////////////////////
// Function: P3DBoolVariant::make_xml
// Function: P3DBoolValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DBoolVariant::
TiXmlElement *P3DBoolValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "bool");
xvariant->SetAttribute("value", (int)_value);
return xvariant;
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "bool");
xvalue->SetAttribute("value", (int)_value);
return xvalue;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dBoolVariant.h
// Filename: p3dBoolValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,23 +12,23 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DBOOLVARIANT_H
#define P3DBOOLVARIANT_H
#ifndef P3DBOOLVALUE_H
#define P3DBOOLVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DBoolVariant
// Description : A variant type that contains a boolean value.
// Class : P3DBoolValue
// Description : A value type that contains a boolean value.
////////////////////////////////////////////////////////////////////
class P3DBoolVariant : public P3DVariant {
class P3DBoolValue : public P3DValue {
public:
P3DBoolVariant(bool value);
P3DBoolVariant(const P3DBoolVariant &copy);
P3DBoolValue(bool value);
P3DBoolValue(const P3DBoolValue &copy);
public:
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual int get_int() const;
virtual void make_string(string &value) const;

View File

@ -1,4 +1,4 @@
// Filename: p3dFloatVariant.cxx
// Filename: p3dFloatValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,82 +12,82 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dFloatVariant.h"
#include "p3dFloatValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::Constructor
// Function: P3DFloatValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DFloatVariant::
P3DFloatVariant(double value) :
P3DVariant(P3D_VT_float),
P3DFloatValue::
P3DFloatValue(double value) :
P3DValue(P3D_VT_float),
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::Copy Constructor
// Function: P3DFloatValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DFloatVariant::
P3DFloatVariant(const P3DFloatVariant &copy) :
P3DVariant(copy),
P3DFloatValue::
P3DFloatValue(const P3DFloatValue &copy) :
P3DValue(copy),
_value(copy._value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::make_copy
// Function: P3DFloatValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DFloatVariant::
P3DValue *P3DFloatValue::
make_copy() {
return new P3DFloatVariant(*this);
return new P3DFloatValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::get_bool
// Function: P3DFloatValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DFloatVariant::
bool P3DFloatValue::
get_bool() const {
return (_value != 0.0);
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::get_int
// Function: P3DFloatValue::get_int
// Access: Public, Virtual
// Description: Returns the variant value coerced to an integer, if
// Description: Returns the value value coerced to an integer, if
// possible.
////////////////////////////////////////////////////////////////////
int P3DFloatVariant::
int P3DFloatValue::
get_int() const {
return (int)_value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::get_float
// Function: P3DFloatValue::get_float
// Access: Public, Virtual
// Description: Returns the variant value coerced to a floating-point
// Description: Returns the value value coerced to a floating-point
// value, if possible.
////////////////////////////////////////////////////////////////////
double P3DFloatVariant::
double P3DFloatValue::
get_float() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::make_string
// Function: P3DFloatValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DFloatVariant::
void P3DFloatValue::
make_string(string &value) const {
ostringstream strm;
strm << _value;
@ -96,15 +96,15 @@ make_string(string &value) const {
////////////////////////////////////////////////////////////////////
// Function: P3DFloatVariant::make_xml
// Function: P3DFloatValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DFloatVariant::
TiXmlElement *P3DFloatValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "float");
xvariant->SetDoubleAttribute("value", _value);
return xvariant;
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "float");
xvalue->SetDoubleAttribute("value", _value);
return xvalue;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dFloatVariant.h
// Filename: p3dFloatValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,23 +12,23 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DFLOATVARIANT_H
#define P3DFLOATVARIANT_H
#ifndef P3DFLOATVALUE_H
#define P3DFLOATVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DFloatVariant
// Description : A variant type that contains a floating-point value.
// Class : P3DFloatValue
// Description : A value type that contains a floating-point value.
////////////////////////////////////////////////////////////////////
class P3DFloatVariant : public P3DVariant {
class P3DFloatValue : public P3DValue {
public:
P3DFloatVariant(double value);
P3DFloatVariant(const P3DFloatVariant &copy);
P3DFloatValue(double value);
P3DFloatValue(const P3DFloatValue &copy);
public:
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual int get_int() const;
virtual double get_float() const;

View File

@ -19,8 +19,8 @@
#include "p3dPackage.h"
#include "p3dSplashWindow.h"
#include "p3dWinSplashWindow.h"
#include "p3dVariant.h"
#include "p3dNoneVariant.h"
#include "p3dValue.h"
#include "p3dNoneValue.h"
#include <sstream>
#include <algorithm>
@ -169,7 +169,7 @@ set_wparams(const P3DWindowParams &wparams) {
// Panda application, and the Javascript on the
// containing web page).
////////////////////////////////////////////////////////////////////
P3DVariant *P3DInstance::
P3DValue *P3DInstance::
get_property(const string &property_name) const {
return NULL;
}
@ -180,7 +180,7 @@ get_property(const string &property_name) const {
// Description: Returns a list of subordinate properties below the
// named property.
////////////////////////////////////////////////////////////////////
P3DVariant *P3DInstance::
P3DValue *P3DInstance::
get_property_list(const string &property_name) const {
return NULL;
}
@ -194,7 +194,7 @@ get_property_list(const string &property_name) const {
// false on failure.
////////////////////////////////////////////////////////////////////
bool P3DInstance::
set_property(const string &property_name, const P3DVariant *value) {
set_property(const string &property_name, const P3DValue *value) {
return false;
}
@ -204,9 +204,9 @@ set_property(const string &property_name, const P3DVariant *value) {
// Description: Calls the named property as a method, supplying the
// indicated parameters.
////////////////////////////////////////////////////////////////////
P3DVariant *P3DInstance::
call(const string &property_name, const P3DVariant *params) {
return new P3DNoneVariant;
P3DValue *P3DInstance::
call(const string &property_name, const P3DValue *params) {
return new P3DNoneValue;
}
@ -353,7 +353,7 @@ feed_url_stream(int unique_id,
// freshly allocated; it will be deleted by this method.
////////////////////////////////////////////////////////////////////
void P3DInstance::
feed_value(int unique_id, P3DVariant *variant) {
feed_value(int unique_id, P3DValue *value) {
if (_session != NULL) {
TiXmlDocument *doc = new TiXmlDocument;
TiXmlDeclaration *decl = new TiXmlDeclaration("1.0", "utf-8", "");
@ -361,9 +361,9 @@ feed_value(int unique_id, P3DVariant *variant) {
xcommand->SetAttribute("cmd", "feed_value");
xcommand->SetAttribute("instance_id", get_instance_id());
xcommand->SetAttribute("unique_id", unique_id);
if (variant != NULL) {
TiXmlElement *xvariant = variant->make_xml();
xcommand->LinkEndChild(xvariant);
if (value != NULL) {
TiXmlElement *xvalue = value->make_xml();
xcommand->LinkEndChild(xvalue);
}
doc->LinkEndChild(decl);
@ -372,8 +372,8 @@ feed_value(int unique_id, P3DVariant *variant) {
_session->send_command(doc);
}
if (variant != NULL) {
delete variant;
if (value != NULL) {
delete value;
}
}

View File

@ -28,7 +28,7 @@ class P3DSession;
class P3DSplashWindow;
class P3DDownload;
class P3DPackage;
class P3DVariant;
class P3DValue;
////////////////////////////////////////////////////////////////////
// Class : P3DInstance
@ -46,11 +46,11 @@ public:
void set_wparams(const P3DWindowParams &wparams);
inline const P3DWindowParams &get_wparams() const;
P3DVariant *get_property(const string &property_name) const;
P3DVariant *get_property_list(const string &property_name) const;
P3DValue *get_property(const string &property_name) const;
P3DValue *get_property_list(const string &property_name) const;
bool set_property(const string &property_name,
const P3DVariant *value);
P3DVariant *call(const string &property_name, const P3DVariant *params);
const P3DValue *value);
P3DValue *call(const string &property_name, const P3DValue *params);
bool has_request();
P3D_request *get_request();
@ -63,7 +63,7 @@ public:
size_t total_expected_data,
const unsigned char *this_data,
size_t this_data_size);
void feed_value(int unique_id, P3DVariant *value);
void feed_value(int unique_id, P3DValue *value);
inline int get_instance_id() const;
inline const string &get_session_key() const;

View File

@ -1,4 +1,4 @@
// Filename: p3dIntVariant.cxx
// Filename: p3dIntValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,71 +12,71 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dIntVariant.h"
#include "p3dIntValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::Constructor
// Function: P3DIntValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DIntVariant::
P3DIntVariant(int value) :
P3DVariant(P3D_VT_int),
P3DIntValue::
P3DIntValue(int value) :
P3DValue(P3D_VT_int),
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::Copy Constructor
// Function: P3DIntValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DIntVariant::
P3DIntVariant(const P3DIntVariant &copy) :
P3DVariant(copy),
P3DIntValue::
P3DIntValue(const P3DIntValue &copy) :
P3DValue(copy),
_value(copy._value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::make_copy
// Function: P3DIntValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DIntVariant::
P3DValue *P3DIntValue::
make_copy() {
return new P3DIntVariant(*this);
return new P3DIntValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::get_bool
// Function: P3DIntValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DIntVariant::
bool P3DIntValue::
get_bool() const {
return (_value != 0);
}
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::get_int
// Function: P3DIntValue::get_int
// Access: Public, Virtual
// Description: Returns the variant value coerced to an integer, if
// Description: Returns the value value coerced to an integer, if
// possible.
////////////////////////////////////////////////////////////////////
int P3DIntVariant::
int P3DIntValue::
get_int() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::make_string
// Function: P3DIntValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DIntVariant::
void P3DIntValue::
make_string(string &value) const {
ostringstream strm;
strm << _value;
@ -85,15 +85,15 @@ make_string(string &value) const {
////////////////////////////////////////////////////////////////////
// Function: P3DIntVariant::make_xml
// Function: P3DIntValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DIntVariant::
TiXmlElement *P3DIntValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "int");
xvariant->SetAttribute("value", _value);
return xvariant;
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "int");
xvalue->SetAttribute("value", _value);
return xvalue;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dIntVariant.h
// Filename: p3dIntValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,23 +12,23 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DINTVARIANT_H
#define P3DINTVARIANT_H
#ifndef P3DINTVALUE_H
#define P3DINTVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DIntVariant
// Description : A variant type that contains an integer value.
// Class : P3DIntValue
// Description : A value type that contains an integer value.
////////////////////////////////////////////////////////////////////
class P3DIntVariant : public P3DVariant {
class P3DIntValue : public P3DValue {
public:
P3DIntVariant(int value);
P3DIntVariant(const P3DIntVariant &copy);
P3DIntValue(int value);
P3DIntValue(const P3DIntValue &copy);
public:
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual int get_int() const;
virtual void make_string(string &value) const;

View File

@ -1,4 +1,4 @@
// Filename: p3dListVariant.cxx
// Filename: p3dListValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,28 +12,28 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dListVariant.h"
#include "p3dListValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::Default Constructor
// Function: P3DListValue::Default Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DListVariant::
P3DListVariant() : P3DVariant(P3D_VT_list) {
P3DListValue::
P3DListValue() : P3DValue(P3D_VT_list) {
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::Constructor
// Function: P3DListValue::Constructor
// Access: Public
// Description: Note that the ownership of the elements in the array
// (but not the array itself) is transferred to the
// list.
////////////////////////////////////////////////////////////////////
P3DListVariant::
P3DListVariant(P3DVariant * const elements[], int num_elements) :
P3DVariant(P3D_VT_list)
P3DListValue::
P3DListValue(P3DValue * const elements[], int num_elements) :
P3DValue(P3D_VT_list)
{
_elements.reserve(num_elements);
for (int i = 0; i < num_elements; ++i) {
@ -42,13 +42,13 @@ P3DListVariant(P3DVariant * const elements[], int num_elements) :
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::Copy Constructor
// Function: P3DListValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DListVariant::
P3DListVariant(const P3DListVariant &copy) :
P3DVariant(copy)
P3DListValue::
P3DListValue(const P3DListValue &copy) :
P3DValue(copy)
{
_elements.reserve(copy._elements.size());
Elements::const_iterator ei;
@ -58,12 +58,12 @@ P3DListVariant(const P3DListVariant &copy) :
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::Destructor
// Function: P3DListValue::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DListVariant::
~P3DListVariant() {
P3DListValue::
~P3DListValue() {
Elements::iterator ei;
for (ei = _elements.begin(); ei != _elements.end(); ++ei) {
delete (*ei);
@ -71,33 +71,33 @@ P3DListVariant::
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::make_copy
// Function: P3DListValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DListVariant::
P3DValue *P3DListValue::
make_copy() {
return new P3DListVariant(*this);
return new P3DListValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::get_bool
// Function: P3DListValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DListVariant::
bool P3DListValue::
get_bool() const {
return !_elements.empty();
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::make_string
// Function: P3DListValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DListVariant::
void P3DListValue::
make_string(string &value) const {
ostringstream strm;
strm << "[";
@ -113,23 +113,23 @@ make_string(string &value) const {
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::get_list_length
// Function: P3DListValue::get_list_length
// Access: Public, Virtual
// Description: Returns the length of the variant value as a list.
// Description: Returns the length of the value value as a list.
////////////////////////////////////////////////////////////////////
int P3DListVariant::
int P3DListValue::
get_list_length() const {
return _elements.size();
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::get_list_item
// Function: P3DListValue::get_list_item
// Access: Public, Virtual
// Description: Returns the nth item in the variant as a list. The
// return value is a freshly-allocated P3DVariant object
// Description: Returns the nth item in the value as a list. The
// return value is a freshly-allocated P3DValue object
// that must be deleted by the caller, or NULL on error.
////////////////////////////////////////////////////////////////////
P3DVariant *P3DListVariant::
P3DValue *P3DListValue::
get_list_item(int n) const {
if (n >= 0 && n < (int)_elements.size()) {
return _elements[n]->make_copy();
@ -139,31 +139,31 @@ get_list_item(int n) const {
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::append_item
// Function: P3DListValue::append_item
// Access: Public, Virtual
// Description: Appends a new item to the end of the list. Ownership
// of the item is transferred to the list.
////////////////////////////////////////////////////////////////////
void P3DListVariant::
append_item(P3DVariant *item) {
void P3DListValue::
append_item(P3DValue *item) {
_elements.push_back(item);
}
////////////////////////////////////////////////////////////////////
// Function: P3DListVariant::make_xml
// Function: P3DListValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DListVariant::
TiXmlElement *P3DListValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "list");
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "list");
Elements::const_iterator ei;
for (ei = _elements.begin(); ei != _elements.end(); ++ei) {
TiXmlElement *xchild = (*ei)->make_xml();
xvariant->LinkEndChild(xchild);
xvalue->LinkEndChild(xchild);
}
return xvariant;
return xvalue;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dListVariant.h
// Filename: p3dListValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,37 +12,37 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DLISTVARIANT_H
#define P3DLISTVARIANT_H
#ifndef P3DLISTVALUE_H
#define P3DLISTVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DListVariant
// Description : A variant type that contains a list of other variants.
// Class : P3DListValue
// Description : A value type that contains a list of other values.
////////////////////////////////////////////////////////////////////
class P3DListVariant : public P3DVariant {
class P3DListValue : public P3DValue {
public:
P3DListVariant();
P3DListVariant(P3DVariant * const elements[], int num_elements);
P3DListVariant(const P3DListVariant &copy);
P3DListValue();
P3DListValue(P3DValue * const elements[], int num_elements);
P3DListValue(const P3DListValue &copy);
public:
virtual ~P3DListVariant();
virtual ~P3DListValue();
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual void make_string(string &value) const;
virtual int get_list_length() const;
virtual P3DVariant *get_list_item(int n) const;
virtual P3DValue *get_list_item(int n) const;
void append_item(P3DVariant *item);
void append_item(P3DValue *item);
virtual TiXmlElement *make_xml() const;
private:
typedef vector<P3DVariant *> Elements;
typedef vector<P3DValue *> Elements;
Elements _elements;
};

View File

@ -1,4 +1,4 @@
// Filename: p3dNoneVariant.cxx
// Filename: p3dNoneValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,58 +12,58 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dNoneVariant.h"
#include "p3dNoneValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DNoneVariant::Constructor
// Function: P3DNoneValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DNoneVariant::
P3DNoneVariant() : P3DVariant(P3D_VT_none) {
P3DNoneValue::
P3DNoneValue() : P3DValue(P3D_VT_none) {
}
////////////////////////////////////////////////////////////////////
// Function: P3DNoneVariant::make_copy
// Function: P3DNoneValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DNoneVariant::
P3DValue *P3DNoneValue::
make_copy() {
return new P3DNoneVariant(*this);
return new P3DNoneValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DNoneVariant::get_bool
// Function: P3DNoneValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DNoneVariant::
bool P3DNoneValue::
get_bool() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: P3DNoneVariant::make_string
// Function: P3DNoneValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DNoneVariant::
void P3DNoneValue::
make_string(string &value) const {
value = "None";
}
////////////////////////////////////////////////////////////////////
// Function: P3DNoneVariant::make_xml
// Function: P3DNoneValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DNoneVariant::
TiXmlElement *P3DNoneValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "none");
return xvariant;
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "none");
return xvalue;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dNoneVariant.h
// Filename: p3dNoneValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,23 +12,23 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DNONEVARIANT_H
#define P3DNONEVARIANT_H
#ifndef P3DNONEVALUE_H
#define P3DNONEVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DNoneVariant
// Description : A variant type that contains no value, similar to
// Class : P3DNoneValue
// Description : A value type that contains no value, similar to
// Python's None type.
////////////////////////////////////////////////////////////////////
class P3DNoneVariant : public P3DVariant {
class P3DNoneValue : public P3DValue {
public:
P3DNoneVariant();
P3DNoneValue();
public:
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual void make_string(string &value) const;

View File

@ -330,7 +330,7 @@ py_request_func(PyObject *args) {
}
xrequest->SetAttribute("property_name", property_name);
append_xml_variant(xrequest, value);
append_xml_value(xrequest, value);
nout << "sending " << doc << "\n" << flush;
_pipe_write << doc << flush;
@ -345,7 +345,7 @@ py_request_func(PyObject *args) {
xrequest->SetAttribute("property_name", property_name);
xrequest->SetAttribute("unique_id", unique_id);
append_xml_variant(xrequest, params);
append_xml_value(xrequest, params);
nout << "sending " << doc << "\n" << flush;
_pipe_write << doc << flush;
@ -597,28 +597,28 @@ terminate_session() {
}
////////////////////////////////////////////////////////////////////
// Function: P3DPythonRun::append_xml_variant
// Function: P3DPythonRun::append_xml_value
// Access: Private
// Description: Converts the indicated PyObject to the appropriate
// XML representation of a P3D_variant type, and appends
// XML representation of a P3D_value type, and appends
// it to the child list of the indicated element.
////////////////////////////////////////////////////////////////////
void P3DPythonRun::
append_xml_variant(TiXmlElement *xelement, PyObject *value) {
TiXmlElement *xvariant = new TiXmlElement("variant");
append_xml_value(TiXmlElement *xelement, PyObject *value) {
TiXmlElement *xvalue = new TiXmlElement("value");
if (value == Py_None) {
// None.
xvariant->SetAttribute("type", "none");
xvalue->SetAttribute("type", "none");
} else if (PyBool_Check(value)) {
// A bool value.
xvariant->SetAttribute("type", "bool");
xvariant->SetAttribute("value", PyObject_IsTrue(value));
xvalue->SetAttribute("type", "bool");
xvalue->SetAttribute("value", PyObject_IsTrue(value));
} else if (PyInt_Check(value)) {
// A plain integer value.
xvariant->SetAttribute("type", "int");
xvariant->SetAttribute("value", PyInt_AsLong(value));
xvalue->SetAttribute("type", "int");
xvalue->SetAttribute("value", PyInt_AsLong(value));
} else if (PyLong_Check(value)) {
// A long integer value. This gets converted either as an integer
@ -627,70 +627,70 @@ append_xml_variant(TiXmlElement *xelement, PyObject *value) {
if (PyErr_Occurred()) {
// It won't fit as an integer; make it a double.
PyErr_Clear();
xvariant->SetAttribute("type", "float");
xvariant->SetDoubleAttribute("value", PyLong_AsDouble(value));
xvalue->SetAttribute("type", "float");
xvalue->SetDoubleAttribute("value", PyLong_AsDouble(value));
} else {
// It fits as an integer.
xvariant->SetAttribute("type", "int");
xvariant->SetAttribute("value", lvalue);
xvalue->SetAttribute("type", "int");
xvalue->SetAttribute("value", lvalue);
}
} else if (PyFloat_Check(value)) {
// A floating-point value.
xvariant->SetAttribute("type", "float");
xvariant->SetDoubleAttribute("value", PyFloat_AsDouble(value));
xvalue->SetAttribute("type", "float");
xvalue->SetDoubleAttribute("value", PyFloat_AsDouble(value));
} else if (PyUnicode_Check(value)) {
// A unicode value. Convert to utf-8 for the XML encoding.
xvariant->SetAttribute("type", "string");
xvalue->SetAttribute("type", "string");
PyObject *as_str = PyUnicode_AsUTF8String(value);
if (as_str != NULL) {
char *buffer;
Py_ssize_t length;
if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) {
string str(buffer, length);
xvariant->SetAttribute("value", str);
xvalue->SetAttribute("value", str);
}
Py_DECREF(as_str);
}
} else if (PyString_Check(value)) {
// A string value.
xvariant->SetAttribute("type", "string");
xvalue->SetAttribute("type", "string");
char *buffer;
Py_ssize_t length;
if (PyString_AsStringAndSize(value, &buffer, &length) != -1) {
string str(buffer, length);
xvariant->SetAttribute("value", str);
xvalue->SetAttribute("value", str);
}
} else if (PySequence_Check(value)) {
// A sequence or list value.
xvariant->SetAttribute("type", "list");
xvalue->SetAttribute("type", "list");
Py_ssize_t length = PySequence_Length(value);
for (Py_ssize_t i = 0; i < length; ++i) {
PyObject *obj = PySequence_GetItem(value, i);
append_xml_variant(xvariant, obj);
append_xml_value(xvalue, obj);
}
} else {
// Some other kind of object. Don't know what else to do with it;
// we'll make it a string.
xvariant->SetAttribute("type", "string");
xvalue->SetAttribute("type", "string");
PyObject *as_str = PyObject_Str(value);
if (as_str != NULL) {
char *buffer;
Py_ssize_t length;
if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) {
string str(buffer, length);
xvariant->SetAttribute("value", str);
xvalue->SetAttribute("value", str);
}
Py_DECREF(as_str);
}
}
xelement->LinkEndChild(xvariant);
xelement->LinkEndChild(xvalue);
}
////////////////////////////////////////////////////////////////////

View File

@ -88,7 +88,7 @@ private:
void terminate_session();
private:
void append_xml_variant(TiXmlElement *xelement, PyObject *value);
void append_xml_value(TiXmlElement *xelement, PyObject *value);
private:
// This method runs only within the read thread.

View File

@ -462,24 +462,24 @@ rt_make_p3d_request(TiXmlElement *xrequest) {
} else if (strcmp(rtype, "set_property") == 0) {
const char *property_name = xrequest->Attribute("property_name");
TiXmlElement *xvariant = xrequest->FirstChildElement("variant");
if (property_name != NULL && xvariant != NULL) {
TiXmlElement *xvalue = xrequest->FirstChildElement("value");
if (property_name != NULL && xvalue != NULL) {
request = new P3D_request;
request->_request_type = P3D_RT_set_property;
request->_request._set_property._property_name = strdup(property_name);
request->_request._set_property._value = rt_from_xml_variant(xvariant);
request->_request._set_property._value = rt_from_xml_value(xvalue);
}
} else if (strcmp(rtype, "call") == 0) {
const char *property_name = xrequest->Attribute("property_name");
TiXmlElement *xvariant = xrequest->FirstChildElement("variant");
TiXmlElement *xvalue = xrequest->FirstChildElement("value");
int unique_id;
if (property_name != NULL && xvariant != NULL &&
if (property_name != NULL && xvalue != NULL &&
xrequest->QueryIntAttribute("unique_id", &unique_id) == TIXML_SUCCESS) {
request = new P3D_request;
request->_request_type = P3D_RT_call;
request->_request._call._property_name = strdup(property_name);
request->_request._call._params = rt_from_xml_variant(xvariant);
request->_request._call._params = rt_from_xml_value(xvalue);
request->_request._call._unique_id = unique_id;
}
@ -492,57 +492,57 @@ rt_make_p3d_request(TiXmlElement *xrequest) {
}
////////////////////////////////////////////////////////////////////
// Function: P3DSession::rt_from_xml_variant
// Function: P3DSession::rt_from_xml_value
// Access: Private
// Description: Converts the XML representation of the particular
// variant value into a corresponding P3DVariant object.
// value value into a corresponding P3DValue object.
// Returns the newly-allocated object.
////////////////////////////////////////////////////////////////////
P3DVariant *P3DSession::
rt_from_xml_variant(TiXmlElement *xvariant) {
const char *type = xvariant->Attribute("type");
P3DValue *P3DSession::
rt_from_xml_value(TiXmlElement *xvalue) {
const char *type = xvalue->Attribute("type");
if (strcmp(type, "none") == 0) {
return new P3DNoneVariant;
return new P3DNoneValue;
} else if (strcmp(type, "bool") == 0) {
int value;
if (xvariant->QueryIntAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DBoolVariant(value != 0);
if (xvalue->QueryIntAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DBoolValue(value != 0);
}
} else if (strcmp(type, "int") == 0) {
int value;
if (xvariant->QueryIntAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DIntVariant(value);
if (xvalue->QueryIntAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DIntValue(value);
}
} else if (strcmp(type, "float") == 0) {
double value;
if (xvariant->QueryDoubleAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DFloatVariant(value);
if (xvalue->QueryDoubleAttribute("value", &value) == TIXML_SUCCESS) {
return new P3DFloatValue(value);
}
} else if (strcmp(type, "string") == 0) {
// Using the string form here instead of the char * form, so we
// don't get tripped up on embedded null characters.
const string *value = xvariant->Attribute(string("value"));
const string *value = xvalue->Attribute(string("value"));
if (value != NULL) {
return new P3DStringVariant(*value);
return new P3DStringValue(*value);
}
} else if (strcmp(type, "list") == 0) {
P3DListVariant *list = new P3DListVariant;
P3DListValue *list = new P3DListValue;
TiXmlElement *xchild = xvariant->FirstChildElement("variant");
TiXmlElement *xchild = xvalue->FirstChildElement("value");
while (xchild != NULL) {
list->append_item(rt_from_xml_variant(xchild));
xchild = xchild->NextSiblingElement("variant");
list->append_item(rt_from_xml_value(xchild));
xchild = xchild->NextSiblingElement("value");
}
return list;
}
// Something went wrong in decoding.
return new P3DNoneVariant;
return new P3DNoneValue;
}
////////////////////////////////////////////////////////////////////

View File

@ -61,7 +61,7 @@ private:
void rt_terminate();
void rt_handle_request(TiXmlDocument *doc);
P3D_request *rt_make_p3d_request(TiXmlElement *xrequest);
P3DVariant *rt_from_xml_variant(TiXmlElement *xvariant);
P3DValue *rt_from_xml_value(TiXmlElement *xvalue);
#ifdef _WIN32
static DWORD WINAPI win_rt_thread_run(LPVOID data);

View File

@ -1,4 +1,4 @@
// Filename: p3dStringVariant.cxx
// Filename: p3dStringValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,95 +12,95 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dStringVariant.h"
#include "p3dStringValue.h"
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::Constructor
// Function: P3DStringValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DStringVariant::
P3DStringVariant(const string &value) :
P3DVariant(P3D_VT_string),
P3DStringValue::
P3DStringValue(const string &value) :
P3DValue(P3D_VT_string),
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::Copy Constructor
// Function: P3DStringValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
P3DStringVariant::
P3DStringVariant(const P3DStringVariant &copy) :
P3DVariant(copy),
P3DStringValue::
P3DStringValue(const P3DStringValue &copy) :
P3DValue(copy),
_value(copy._value)
{
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::Destructor
// Function: P3DStringValue::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DStringVariant::
~P3DStringVariant() {
P3DStringValue::
~P3DStringValue() {
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::make_copy
// Function: P3DStringValue::make_copy
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant *P3DStringVariant::
P3DValue *P3DStringValue::
make_copy() {
return new P3DStringVariant(*this);
return new P3DStringValue(*this);
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::get_bool
// Function: P3DStringValue::get_bool
// Access: Public, Virtual
// Description: Returns the variant value coerced to a boolean, if
// Description: Returns the value value coerced to a boolean, if
// possible.
////////////////////////////////////////////////////////////////////
bool P3DStringVariant::
bool P3DStringValue::
get_bool() const {
return !_value.empty();
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::make_string
// Function: P3DStringValue::make_string
// Access: Public, Virtual
// Description: Fills the indicated C++ string object with the value
// of this object coerced to a string.
////////////////////////////////////////////////////////////////////
void P3DStringVariant::
void P3DStringValue::
make_string(string &value) const {
value = _value;
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::make_xml
// Function: P3DStringValue::make_xml
// Access: Public, Virtual
// Description: Allocates and returns a new XML structure
// corresponding to this variant.
// corresponding to this value.
////////////////////////////////////////////////////////////////////
TiXmlElement *P3DStringVariant::
TiXmlElement *P3DStringValue::
make_xml() const {
TiXmlElement *xvariant = new TiXmlElement("variant");
xvariant->SetAttribute("type", "string");
xvariant->SetAttribute("value", _value);
return xvariant;
TiXmlElement *xvalue = new TiXmlElement("value");
xvalue->SetAttribute("type", "string");
xvalue->SetAttribute("value", _value);
return xvalue;
}
////////////////////////////////////////////////////////////////////
// Function: P3DStringVariant::output
// Function: P3DStringValue::output
// Access: Public, Virtual
// Description: Writes a formatted representation of the value to the
// indicated string. This is intended for developer
// assistance.
////////////////////////////////////////////////////////////////////
void P3DStringVariant::
void P3DStringValue::
output(ostream &out) const {
out << '"';
for (string::const_iterator si = _value.begin(); si != _value.end(); ++si) {

View File

@ -1,4 +1,4 @@
// Filename: p3dStringVariant.h
// Filename: p3dStringValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,25 +12,25 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DSTRINGVARIANT_H
#define P3DSTRINGVARIANT_H
#ifndef P3DSTRINGVALUE_H
#define P3DSTRINGVALUE_H
#include "p3d_plugin_common.h"
#include "p3dVariant.h"
#include "p3dValue.h"
////////////////////////////////////////////////////////////////////
// Class : P3DStringVariant
// Description : A variant type that contains a string value.
// Class : P3DStringValue
// Description : A value type that contains a string value.
////////////////////////////////////////////////////////////////////
class P3DStringVariant : public P3DVariant {
class P3DStringValue : public P3DValue {
public:
P3DStringVariant(const string &value);
P3DStringVariant(const P3DStringVariant &copy);
P3DStringValue(const string &value);
P3DStringValue(const P3DStringValue &copy);
public:
virtual ~P3DStringVariant();
virtual ~P3DStringValue();
virtual P3DVariant *make_copy();
virtual P3DValue *make_copy();
virtual bool get_bool() const;
virtual void make_string(string &value) const;

View File

@ -1,4 +1,4 @@
// Filename: p3dVariant.I
// Filename: p3dValue.I
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -14,21 +14,21 @@
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::Constructor
// Function: P3DValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
inline P3DVariant::
P3DVariant(P3D_variant_type type) {
inline P3DValue::
P3DValue(P3D_value_type type) {
_type = type;
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::Copy Constructor
// Function: P3DValue::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
inline P3DVariant::
P3DVariant(const P3DVariant &copy) {
inline P3DValue::
P3DValue(const P3DValue &copy) {
_type = copy._type;
}

View File

@ -1,4 +1,4 @@
// Filename: p3dVariant.cxx
// Filename: p3dValue.cxx
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,49 +12,49 @@
//
////////////////////////////////////////////////////////////////////
#include "p3dVariant.h"
#include "p3dValue.h"
#include <string.h> // memcpy
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::Destructor
// Function: P3DValue::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
P3DVariant::
~P3DVariant() {
P3DValue::
~P3DValue() {
_type = P3D_VT_none;
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::get_int
// Function: P3DValue::get_int
// Access: Public, Virtual
// Description: Returns the variant value coerced to an integer, if
// Description: Returns the value value coerced to an integer, if
// possible.
////////////////////////////////////////////////////////////////////
int P3DVariant::
int P3DValue::
get_int() const {
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::get_float
// Function: P3DValue::get_float
// Access: Public, Virtual
// Description: Returns the variant value coerced to a floating-point
// Description: Returns the value value coerced to a floating-point
// value, if possible.
////////////////////////////////////////////////////////////////////
double P3DVariant::
double P3DValue::
get_float() const {
return get_int();
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::get_string_length
// Function: P3DValue::get_string_length
// Access: Public, Virtual
// Description: Returns the length of the string that represents the
// variant value, not counting any null termination
// value value, not counting any null termination
// characters.
////////////////////////////////////////////////////////////////////
int P3DVariant::
int P3DValue::
get_string_length() const {
string result;
make_string(result);
@ -62,16 +62,16 @@ get_string_length() const {
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::extract_string
// Function: P3DValue::extract_string
// Access: Public, Virtual
// Description: Stores a string that represents the variant value in
// Description: Stores a string that represents the value value in
// the indicated buffer; a null character is included if
// there is space. Returns the number of characters
// needed in the output (which might be more than the
// actual number of characters stored if buffer_length
// was too small).
////////////////////////////////////////////////////////////////////
int P3DVariant::
int P3DValue::
extract_string(char *buffer, int buffer_length) const {
string result;
make_string(result);
@ -80,35 +80,35 @@ extract_string(char *buffer, int buffer_length) const {
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::get_list_length
// Function: P3DValue::get_list_length
// Access: Public, Virtual
// Description: Returns the length of the variant value as a list.
// Description: Returns the length of the value value as a list.
////////////////////////////////////////////////////////////////////
int P3DVariant::
int P3DValue::
get_list_length() const {
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::get_list_item
// Function: P3DValue::get_list_item
// Access: Public, Virtual
// Description: Returns the nth item in the variant as a list. The
// return value is a freshly-allocated P3DVariant object
// Description: Returns the nth item in the value as a list. The
// return value is a freshly-allocated P3DValue object
// that must be deleted by the caller, or NULL on error.
////////////////////////////////////////////////////////////////////
P3DVariant *P3DVariant::
P3DValue *P3DValue::
get_list_item(int n) const {
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: P3DVariant::output
// Function: P3DValue::output
// Access: Public, Virtual
// Description: Writes a formatted representation of the value to the
// indicated string. This is intended for developer
// assistance.
////////////////////////////////////////////////////////////////////
void P3DVariant::
void P3DValue::
output(ostream &out) const {
string value;
make_string(value);

View File

@ -1,4 +1,4 @@
// Filename: p3dVariant.h
// Filename: p3dValue.h
// Created by: drose (30Jun09)
//
////////////////////////////////////////////////////////////////////
@ -12,28 +12,28 @@
//
////////////////////////////////////////////////////////////////////
#ifndef P3DVARIANT_H
#define P3DVARIANT_H
#ifndef P3DVALUE_H
#define P3DVALUE_H
#include "p3d_plugin_common.h"
////////////////////////////////////////////////////////////////////
// Class : P3DVariant
// Description : The C++ implementation of P3D_variant, corresponding
// Class : P3DValue
// Description : The C++ implementation of P3D_value, corresponding
// to a single atomic value that is passed around
// between scripting languages. This is an abstract
// base class; the actual implementations are provided
// by the various specialized classes, below.
////////////////////////////////////////////////////////////////////
class P3DVariant : public P3D_variant {
class P3DValue : public P3D_value {
protected:
inline P3DVariant(P3D_variant_type type);
inline P3DVariant(const P3DVariant &copy);
inline P3DValue(P3D_value_type type);
inline P3DValue(const P3DValue &copy);
public:
virtual ~P3DVariant();
virtual ~P3DValue();
virtual P3DVariant *make_copy()=0;
virtual P3DValue *make_copy()=0;
virtual bool get_bool() const=0;
virtual int get_int() const;
virtual double get_float() const;
@ -43,17 +43,17 @@ public:
virtual void make_string(string &value) const=0;
virtual int get_list_length() const;
virtual P3DVariant *get_list_item(int n) const;
virtual P3DValue *get_list_item(int n) const;
virtual TiXmlElement *make_xml() const=0;
virtual void output(ostream &out) const;
};
#include "p3dVariant.I"
#include "p3dValue.I"
inline ostream &operator << (ostream &out, const P3DVariant &variant) {
variant.output(out);
inline ostream &operator << (ostream &out, const P3DValue &value) {
value.output(out);
return out;
}

View File

@ -16,12 +16,12 @@
#include "p3dInstanceManager.h"
#include "p3dInstance.h"
#include "p3dWindowParams.h"
#include "p3dNoneVariant.h"
#include "p3dBoolVariant.h"
#include "p3dIntVariant.h"
#include "p3dFloatVariant.h"
#include "p3dStringVariant.h"
#include "p3dListVariant.h"
#include "p3dNoneValue.h"
#include "p3dBoolValue.h"
#include "p3dIntValue.h"
#include "p3dFloatValue.h"
#include "p3dStringValue.h"
#include "p3dListValue.h"
#include <assert.h>
@ -117,181 +117,181 @@ P3D_instance_setup_window(P3D_instance *instance,
}
void
P3D_variant_finish(P3D_variant *variant) {
P3D_value_finish(P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
if (variant != NULL) {
delete (P3DVariant *)variant;
if (value != NULL) {
delete (P3DValue *)value;
}
RELEASE_LOCK(_lock);
}
P3D_variant *
P3D_variant_copy(const P3D_variant *variant) {
P3D_value *
P3D_value_copy(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = ((P3DVariant *)variant)->make_copy();
P3D_value *result = ((P3DValue *)value)->make_copy();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_none_variant() {
P3D_value *
P3D_new_none_value() {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DNoneVariant();
P3D_value *result = new P3DNoneValue();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_bool_variant(bool value) {
P3D_value *
P3D_new_bool_value(bool value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DBoolVariant(value);
P3D_value *result = new P3DBoolValue(value);
RELEASE_LOCK(_lock);
return result;
}
bool
P3D_variant_get_bool(const P3D_variant *variant) {
P3D_value_get_bool(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
bool result = ((const P3DVariant *)variant)->get_bool();
bool result = ((const P3DValue *)value)->get_bool();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_int_variant(int value) {
P3D_value *
P3D_new_int_value(int value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DIntVariant(value);
P3D_value *result = new P3DIntValue(value);
RELEASE_LOCK(_lock);
return result;
}
int
P3D_variant_get_int(const P3D_variant *variant) {
P3D_value_get_int(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
int result = ((const P3DVariant *)variant)->get_int();
int result = ((const P3DValue *)value)->get_int();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_float_variant(double value) {
P3D_value *
P3D_new_float_value(double value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DFloatVariant(value);
P3D_value *result = new P3DFloatValue(value);
RELEASE_LOCK(_lock);
return result;
}
double
P3D_variant_get_float(const P3D_variant *variant) {
P3D_value_get_float(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
double result = ((const P3DVariant *)variant)->get_float();
double result = ((const P3DValue *)value)->get_float();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_string_variant(const char *value, int length) {
P3D_value *
P3D_new_string_value(const char *value, int length) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DStringVariant(string(value, length));
P3D_value *result = new P3DStringValue(string(value, length));
RELEASE_LOCK(_lock);
return result;
}
int
P3D_variant_get_string_length(const P3D_variant *variant) {
P3D_value_get_string_length(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
int result = ((const P3DVariant *)variant)->get_string_length();
int result = ((const P3DValue *)value)->get_string_length();
RELEASE_LOCK(_lock);
return result;
}
int
P3D_variant_extract_string(const P3D_variant *variant, char *buffer,
P3D_value_extract_string(const P3D_value *value, char *buffer,
int buffer_length) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
int result =
((const P3DVariant *)variant)->extract_string(buffer, buffer_length);
((const P3DValue *)value)->extract_string(buffer, buffer_length);
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_new_list_variant(P3D_variant * const elements[], int num_elements) {
P3D_value *
P3D_new_list_value(P3D_value * const elements[], int num_elements) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = new P3DListVariant((P3DVariant * const *)elements, num_elements);
P3D_value *result = new P3DListValue((P3DValue * const *)elements, num_elements);
RELEASE_LOCK(_lock);
return result;
}
int
P3D_variant_get_list_length(const P3D_variant *variant) {
P3D_value_get_list_length(const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
int result = ((const P3DVariant *)variant)->get_list_length();
int result = ((const P3DValue *)value)->get_list_length();
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_variant_get_list_item(const P3D_variant *variant, int n) {
P3D_value *
P3D_value_get_list_item(const P3D_value *value, int n) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = ((const P3DVariant *)variant)->get_list_item(n);
P3D_value *result = ((const P3DValue *)value)->get_list_item(n);
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_value *
P3D_instance_get_property(const P3D_instance *instance,
const char *property_name) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = ((const P3DInstance *)instance)->get_property(property_name);
P3D_value *result = ((const P3DInstance *)instance)->get_property(property_name);
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_value *
P3D_instance_get_property_list(const P3D_instance *instance,
const char *property_name) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result = ((const P3DInstance *)instance)->get_property_list(property_name);
P3D_value *result = ((const P3DInstance *)instance)->get_property_list(property_name);
RELEASE_LOCK(_lock);
return result;
}
bool
P3D_instance_set_property(P3D_instance *instance, const char *property_name,
const P3D_variant *value) {
const P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
bool result =
((P3DInstance *)instance)->set_property(property_name, (const P3DVariant *)value);
((P3DInstance *)instance)->set_property(property_name, (const P3DValue *)value);
RELEASE_LOCK(_lock);
return result;
}
P3D_variant *
P3D_value *
P3D_instance_call(P3D_instance *instance, const char *property_name,
const P3D_variant *params) {
const P3D_value *params) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
P3D_variant *result =
((P3DInstance *)instance)->call(property_name, (P3DVariant *)params);
P3D_value *result =
((P3DInstance *)instance)->call(property_name, (P3DValue *)params);
RELEASE_LOCK(_lock);
return result;
}
@ -359,9 +359,9 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id,
void
P3D_instance_feed_value(P3D_instance *instance, int unique_id,
P3D_variant *variant) {
P3D_value *value) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_lock);
((P3DInstance *)instance)->feed_value(unique_id, (P3DVariant *)variant);
((P3DInstance *)instance)->feed_value(unique_id, (P3DValue *)value);
RELEASE_LOCK(_lock);
}

View File

@ -264,7 +264,7 @@ P3D_instance_setup_window_func(P3D_instance *instance,
plugin via JavaScript or related interfaces on the browser. */
/* This enumeration indicates which fundamental type is represented by
a particular P3D_variant object, below. */
a particular P3D_value object, below. */
typedef enum {
P3D_VT_none,
P3D_VT_bool,
@ -272,76 +272,76 @@ typedef enum {
P3D_VT_float,
P3D_VT_string,
P3D_VT_list
} P3D_variant_type;
} P3D_value_type;
/* This structure represents a concrete value of some arbitrary type.
Instances of this structure may be assigned to property names, or
passed into or returned from function calls. */
typedef struct {
P3D_variant_type _type;
P3D_value_type _type;
/* Additional opaque data may be stored here. */
} P3D_variant;
} P3D_value;
/* Deallocates a P3D_variant previously allocated with one of the
/* Deallocates a P3D_value previously allocated with one of the
below calls, or returned from a function such as
P3D_variant_get_property(). After this has been called, the
variant's pointer must no longer be used. */
P3D_value_get_property(). After this has been called, the
value's pointer must no longer be used. */
typedef void
P3D_variant_finish_func(P3D_variant *variant);
P3D_value_finish_func(P3D_value *value);
/* Returns a duplicate copy of the indicated variant. The return
value should be eventually passed to P3D_variant_finish(),
/* Returns a duplicate copy of the indicated value. The return
value should be eventually passed to P3D_value_finish(),
above. */
typedef P3D_variant *
P3D_variant_copy_func(const P3D_variant *variant);
typedef P3D_value *
P3D_value_copy_func(const P3D_value *value);
/* Allocates a new P3D_variant of type none. This variant has no
/* Allocates a new P3D_value of type none. This value has no
particular value and corresponds to Python's None type or C's void
type. */
typedef P3D_variant *
P3D_new_none_variant_func();
typedef P3D_value *
P3D_new_none_value_func();
/* Allocates a new P3D_variant of type bool. */
typedef P3D_variant *
P3D_new_bool_variant_func(bool value);
/* Allocates a new P3D_value of type bool. */
typedef P3D_value *
P3D_new_bool_value_func(bool value);
/* Retrieves the boolean value associated with this type. If the
variant's type is not P3D_VT_bool, this implicitly coerces the
value's type is not P3D_VT_bool, this implicitly coerces the
value to a boolean value. */
typedef bool
P3D_variant_get_bool_func(const P3D_variant *variant);
P3D_value_get_bool_func(const P3D_value *value);
/* Allocates a new P3D_variant of type int. */
typedef P3D_variant *
P3D_new_int_variant_func(int value);
/* Allocates a new P3D_value of type int. */
typedef P3D_value *
P3D_new_int_value_func(int value);
/* Retrieves the integer value associated with this type. If the
variant's type is not P3D_VT_int, this implicitly coerces the value
value's type is not P3D_VT_int, this implicitly coerces the value
to an integer value. */
typedef int
P3D_variant_get_int_func(const P3D_variant *variant);
P3D_value_get_int_func(const P3D_value *value);
/* Allocates a new P3D_variant of type float. */
typedef P3D_variant *
P3D_new_float_variant_func(double value);
/* Allocates a new P3D_value of type float. */
typedef P3D_value *
P3D_new_float_value_func(double value);
/* Retrieves the floating-point value associated with this type. If
the variant's type is not P3D_VT_float, this implicitly coerces the
the value's type is not P3D_VT_float, this implicitly coerces the
value to a floating-point value. */
typedef double
P3D_variant_get_float_func(const P3D_variant *variant);
P3D_value_get_float_func(const P3D_value *value);
/* Allocates a new P3D_variant of type string. */
typedef P3D_variant *
P3D_new_string_variant_func(const char *value, int length);
/* Allocates a new P3D_value of type string. */
typedef P3D_value *
P3D_new_string_value_func(const char *value, int length);
/* Retrieves the length of the string value associated with this type.
This is the number of bytes that must be allocated to hold the
results of P3D_variant_extract_string(), not including any
results of P3D_value_extract_string(), not including any
terminating null byte. */
typedef int
P3D_variant_get_string_length_func(const P3D_variant *variant);
P3D_value_get_string_length_func(const P3D_value *value);
/* Stores the string value associated with this type in the indicated
buffer, which has the specified length. The return value is the
@ -352,46 +352,46 @@ P3D_variant_get_string_length_func(const P3D_variant *variant);
P3D_VT_string, this implicitly coerces the value to a string
value. */
typedef int
P3D_variant_extract_string_func(const P3D_variant *variant, char *buffer,
P3D_value_extract_string_func(const P3D_value *value, char *buffer,
int buffer_length);
/* Allocates a new P3D_variant of type list. This is a list of an
arbitrary number of P3D_variant objects. The indicated P3D_variant
/* Allocates a new P3D_value of type list. This is a list of an
arbitrary number of P3D_value objects. The indicated P3D_value
objects are stored directly within the list; ownership of the
objects in this array (but not the array pointer itself) is passed
to the list. The caller must no longer call P3D_variant_finish()
to the list. The caller must no longer call P3D_value_finish()
on any objects added to the list (but should still call
P3D_variant_finish() on the list itself). */
typedef P3D_variant *
P3D_new_list_variant_func(P3D_variant * const elements[], int num_elements);
P3D_value_finish() on the list itself). */
typedef P3D_value *
P3D_new_list_value_func(P3D_value * const elements[], int num_elements);
/* Returns the number of items in the list, if the variant's type is
/* Returns the number of items in the list, if the value's type is
of P3D_VT_list. */
typedef int
P3D_variant_get_list_length_func(const P3D_variant *variant);
P3D_value_get_list_length_func(const P3D_value *value);
/* Returns the nth item in the list. The caller inherits ownership of
this object, and should call P3D_variant_finish() on it. */
typedef P3D_variant *
P3D_variant_get_list_item_func(const P3D_variant *variant, int n);
this object, and should call P3D_value_finish() on it. */
typedef P3D_value *
P3D_value_get_list_item_func(const P3D_value *value, int n);
/* Retrieves the named property from the instance, if any. The
property name may be a dot-delimited sequence to reference nested
properties. Returns NULL if the instance does not have the named
property. If not NULL, you should pass the return value to
P3D_variant_finish(). */
typedef P3D_variant *
P3D_value_finish(). */
typedef P3D_value *
P3D_instance_get_property_func(const P3D_instance *instance,
const char *property_name);
/* Returns a list of properties on the instance below the named
property. The property name may be a dot-delimited sequence to
reference nested properties. Returns NULL if the instance does not
have the named property; otherwise, returns a list variant that
contains a list of string variants, one for each property stored on
have the named property; otherwise, returns a list value that
contains a list of string values, one for each property stored on
the named property. If not NULL, you should pass the return value
to P3D_variant_finish(). */
typedef P3D_variant *
to P3D_value_finish(). */
typedef P3D_value *
P3D_instance_get_property_list_func(const P3D_instance *instance,
const char *property_name);
@ -401,21 +401,21 @@ P3D_instance_get_property_list_func(const P3D_instance *instance,
false on failure (for instance, because a parent property does not
exist). Pass NULL for the value to delete the last property. The
caller retains ownership of the value object, and should eventually
delete with P3D_variant_finish(). */
delete with P3D_value_finish(). */
typedef bool
P3D_instance_set_property_func(P3D_instance *instance, const char *property_name,
const P3D_variant *value);
const P3D_value *value);
/* Calls the named property as a function. The property name may be a
dot-delimited sequence. The params variant is an object of type
dot-delimited sequence. The params value is an object of type
P3D_VT_list, which contains the list of parameters to the function.
The caller retains ownership of the params object. The return
value is NULL on error, or a newly-allocated variant on success; if
value is NULL on error, or a newly-allocated value on success; if
not NULL, you should pass the return value to
P3D_variant_finish(). */
typedef P3D_variant *
P3D_value_finish(). */
typedef P3D_value *
P3D_instance_call_func(P3D_instance *instance, const char *property_name,
const P3D_variant *params);
const P3D_value *params);
/* Some scriptable properties on the host may be queried or modified
via requests, below. */
@ -518,12 +518,12 @@ typedef struct {
P3D_request_finish()). */
typedef struct {
const char *_property_name;
const P3D_variant *_value;
const P3D_value *_value;
} P3D_request_set_property;
/* A request to call a function on a host object. The property_name
will be a dot-delimited string corresponding to a nested object, as
above. The _params pointer will be a list variant, which contains
above. The _params pointer will be a list value, which contains
the parameter values to pass to the function. The host does not
receive ownership of the _params pointer and should not store it or
delete it. The host should respond to this request by calling
@ -532,7 +532,7 @@ typedef struct {
not a callable object. */
typedef struct {
const char *_property_name;
const P3D_variant *_params;
const P3D_value *_params;
int _unique_id;
} P3D_request_call;
@ -652,14 +652,14 @@ P3D_instance_feed_url_stream_func(P3D_instance *instance, int unique_id,
/* This function is called by the host in response to a get_property
or call request. The instance and unique_id parameters are from
the original request; the variant should be a freshly-allocated
P3D_variant that represents the requested property value or the
the original request; the value should be a freshly-allocated
P3D_value that represents the requested property value or the
return value from the function call, or NULL on error. Ownership
of the variant value is passed into the plugin; the host should
*not* call P3D_variant_finish() on this pointer. */
of the value value is passed into the plugin; the host should
*not* call P3D_value_finish() on this pointer. */
typedef void
P3D_instance_feed_value_func(P3D_instance *instance, int unique_id,
P3D_variant *variant);
P3D_value *value);
#ifdef P3D_FUNCTION_PROTOTYPES
@ -672,21 +672,21 @@ EXPCL_P3D_PLUGIN P3D_instance_start_func P3D_instance_start;
EXPCL_P3D_PLUGIN P3D_instance_finish_func P3D_instance_finish;
EXPCL_P3D_PLUGIN P3D_instance_setup_window_func P3D_instance_setup_window;
EXPCL_P3D_PLUGIN P3D_variant_finish_func P3D_variant_finish;
EXPCL_P3D_PLUGIN P3D_variant_copy_func P3D_variant_copy;
EXPCL_P3D_PLUGIN P3D_new_none_variant_func P3D_new_none_variant;
EXPCL_P3D_PLUGIN P3D_new_bool_variant_func P3D_new_bool_variant;
EXPCL_P3D_PLUGIN P3D_variant_get_bool_func P3D_variant_get_bool;
EXPCL_P3D_PLUGIN P3D_new_int_variant_func P3D_new_int_variant;
EXPCL_P3D_PLUGIN P3D_variant_get_int_func P3D_variant_get_int;
EXPCL_P3D_PLUGIN P3D_new_float_variant_func P3D_new_float_variant;
EXPCL_P3D_PLUGIN P3D_variant_get_float_func P3D_variant_get_float;
EXPCL_P3D_PLUGIN P3D_new_string_variant_func P3D_new_string_variant;
EXPCL_P3D_PLUGIN P3D_variant_get_string_length_func P3D_variant_get_string_length;
EXPCL_P3D_PLUGIN P3D_variant_extract_string_func P3D_variant_extract_string;
EXPCL_P3D_PLUGIN P3D_new_list_variant_func P3D_new_list_variant;
EXPCL_P3D_PLUGIN P3D_variant_get_list_length_func P3D_variant_get_list_length;
EXPCL_P3D_PLUGIN P3D_variant_get_list_item_func P3D_variant_get_list_item;
EXPCL_P3D_PLUGIN P3D_value_finish_func P3D_value_finish;
EXPCL_P3D_PLUGIN P3D_value_copy_func P3D_value_copy;
EXPCL_P3D_PLUGIN P3D_new_none_value_func P3D_new_none_value;
EXPCL_P3D_PLUGIN P3D_new_bool_value_func P3D_new_bool_value;
EXPCL_P3D_PLUGIN P3D_value_get_bool_func P3D_value_get_bool;
EXPCL_P3D_PLUGIN P3D_new_int_value_func P3D_new_int_value;
EXPCL_P3D_PLUGIN P3D_value_get_int_func P3D_value_get_int;
EXPCL_P3D_PLUGIN P3D_new_float_value_func P3D_new_float_value;
EXPCL_P3D_PLUGIN P3D_value_get_float_func P3D_value_get_float;
EXPCL_P3D_PLUGIN P3D_new_string_value_func P3D_new_string_value;
EXPCL_P3D_PLUGIN P3D_value_get_string_length_func P3D_value_get_string_length;
EXPCL_P3D_PLUGIN P3D_value_extract_string_func P3D_value_extract_string;
EXPCL_P3D_PLUGIN P3D_new_list_value_func P3D_new_list_value;
EXPCL_P3D_PLUGIN P3D_value_get_list_length_func P3D_value_get_list_length;
EXPCL_P3D_PLUGIN P3D_value_get_list_item_func P3D_value_get_list_item;
EXPCL_P3D_PLUGIN P3D_instance_get_property_func P3D_instance_get_property;
EXPCL_P3D_PLUGIN P3D_instance_get_property_list_func P3D_instance_get_property_list;
EXPCL_P3D_PLUGIN P3D_instance_set_property_func P3D_instance_set_property;

View File

@ -5,16 +5,16 @@
#include "p3dInstance.cxx"
#include "p3dInstanceManager.cxx"
#include "p3dMultifileReader.cxx"
#include "p3dNoneVariant.cxx"
#include "p3dNoneValue.cxx"
#include "p3dPackage.cxx"
#include "p3dSplashWindow.cxx"
#include "p3dSession.cxx"
#include "p3dWindowParams.cxx"
#include "p3dWinSplashWindow.cxx"
#include "p3dVariant.cxx"
#include "p3dBoolVariant.cxx"
#include "p3dIntVariant.cxx"
#include "p3dFloatVariant.cxx"
#include "p3dListVariant.cxx"
#include "p3dStringVariant.cxx"
#include "p3dValue.cxx"
#include "p3dBoolValue.cxx"
#include "p3dIntValue.cxx"
#include "p3dFloatValue.cxx"
#include "p3dListValue.cxx"
#include "p3dStringValue.cxx"

View File

@ -340,7 +340,7 @@ handle_request(P3D_request *request) {
_properties.find(request->_request._get_property._property_name);
if (pi != _properties.end()) {
// The named property has been set.
P3D_variant *dup_value = P3D_variant_copy((*pi).second);
P3D_value *dup_value = P3D_value_copy((*pi).second);
P3D_instance_feed_value(request->_instance,
request->_request._get_property._unique_id,
dup_value);
@ -360,9 +360,9 @@ handle_request(P3D_request *request) {
{
// Also output the new value.
int buffer_size =
P3D_variant_get_string_length(request->_request._set_property._value);
P3D_value_get_string_length(request->_request._set_property._value);
char *buffer = (char *)alloca(buffer_size);
P3D_variant_extract_string(request->_request._set_property._value, buffer, buffer_size);
P3D_value_extract_string(request->_request._set_property._value, buffer, buffer_size);
cerr.write(buffer, buffer_size);
cerr << "\n";
@ -370,10 +370,10 @@ handle_request(P3D_request *request) {
_properties.insert(Properties::value_type(request->_request._set_property._property_name, NULL)).first;
if ((*pi).second != NULL) {
// Delete the original property.
P3D_variant_finish((*pi).second);
P3D_value_finish((*pi).second);
}
(*pi).second =
P3D_variant_copy(request->_request._set_property._value);
P3D_value_copy(request->_request._set_property._value);
handled = true;
}
break;
@ -384,9 +384,9 @@ handle_request(P3D_request *request) {
{
// Also output the parameter list.
int buffer_size =
P3D_variant_get_string_length(request->_request._call._params);
P3D_value_get_string_length(request->_request._call._params);
char *buffer = (char *)alloca(buffer_size);
P3D_variant_extract_string(request->_request._call._params, buffer, buffer_size);
P3D_value_extract_string(request->_request._call._params, buffer, buffer_size);
cerr.write(buffer, buffer_size);
cerr << "\n";

View File

@ -62,7 +62,7 @@ private:
// We maintain a table of properties in the "browser", mainly so we
// can test this feature of the core plugin API.
typedef pmap<string, P3D_variant *> Properties;
typedef pmap<string, P3D_value *> Properties;
Properties _properties;
// This nested class keeps track of active URL requests.