Add properties with has/clear (interrogatedb v3.1)
This commit is contained in:
parent
07d2b64d74
commit
db6f0342cc
File diff suppressed because it is too large
Load Diff
|
|
@ -124,42 +124,43 @@ extern int cppyydebug;
|
|||
KW_LONG = 333,
|
||||
KW_LONGLONG = 334,
|
||||
KW_MAKE_PROPERTY = 335,
|
||||
KW_MAKE_SEQ = 336,
|
||||
KW_MUTABLE = 337,
|
||||
KW_NAMESPACE = 338,
|
||||
KW_NEW = 339,
|
||||
KW_NOEXCEPT = 340,
|
||||
KW_NULLPTR = 341,
|
||||
KW_OPERATOR = 342,
|
||||
KW_PRIVATE = 343,
|
||||
KW_PROTECTED = 344,
|
||||
KW_PUBLIC = 345,
|
||||
KW_REGISTER = 346,
|
||||
KW_RETURN = 347,
|
||||
KW_SHORT = 348,
|
||||
KW_SIGNED = 349,
|
||||
KW_SIZEOF = 350,
|
||||
KW_STATIC = 351,
|
||||
KW_STATIC_ASSERT = 352,
|
||||
KW_STATIC_CAST = 353,
|
||||
KW_STRUCT = 354,
|
||||
KW_TEMPLATE = 355,
|
||||
KW_THROW = 356,
|
||||
KW_TRUE = 357,
|
||||
KW_TRY = 358,
|
||||
KW_TYPEDEF = 359,
|
||||
KW_TYPENAME = 360,
|
||||
KW_UNION = 361,
|
||||
KW_UNSIGNED = 362,
|
||||
KW_USING = 363,
|
||||
KW_VIRTUAL = 364,
|
||||
KW_VOID = 365,
|
||||
KW_VOLATILE = 366,
|
||||
KW_WCHAR_T = 367,
|
||||
KW_WHILE = 368,
|
||||
START_CPP = 369,
|
||||
START_CONST_EXPR = 370,
|
||||
START_TYPE = 371
|
||||
KW_MAKE_PROPERTY2 = 336,
|
||||
KW_MAKE_SEQ = 337,
|
||||
KW_MUTABLE = 338,
|
||||
KW_NAMESPACE = 339,
|
||||
KW_NEW = 340,
|
||||
KW_NOEXCEPT = 341,
|
||||
KW_NULLPTR = 342,
|
||||
KW_OPERATOR = 343,
|
||||
KW_PRIVATE = 344,
|
||||
KW_PROTECTED = 345,
|
||||
KW_PUBLIC = 346,
|
||||
KW_REGISTER = 347,
|
||||
KW_RETURN = 348,
|
||||
KW_SHORT = 349,
|
||||
KW_SIGNED = 350,
|
||||
KW_SIZEOF = 351,
|
||||
KW_STATIC = 352,
|
||||
KW_STATIC_ASSERT = 353,
|
||||
KW_STATIC_CAST = 354,
|
||||
KW_STRUCT = 355,
|
||||
KW_TEMPLATE = 356,
|
||||
KW_THROW = 357,
|
||||
KW_TRUE = 358,
|
||||
KW_TRY = 359,
|
||||
KW_TYPEDEF = 360,
|
||||
KW_TYPENAME = 361,
|
||||
KW_UNION = 362,
|
||||
KW_UNSIGNED = 363,
|
||||
KW_USING = 364,
|
||||
KW_VIRTUAL = 365,
|
||||
KW_VOID = 366,
|
||||
KW_VOLATILE = 367,
|
||||
KW_WCHAR_T = 368,
|
||||
KW_WHILE = 369,
|
||||
START_CPP = 370,
|
||||
START_CONST_EXPR = 371,
|
||||
START_TYPE = 372
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
|
|
@ -241,42 +242,43 @@ extern int cppyydebug;
|
|||
#define KW_LONG 333
|
||||
#define KW_LONGLONG 334
|
||||
#define KW_MAKE_PROPERTY 335
|
||||
#define KW_MAKE_SEQ 336
|
||||
#define KW_MUTABLE 337
|
||||
#define KW_NAMESPACE 338
|
||||
#define KW_NEW 339
|
||||
#define KW_NOEXCEPT 340
|
||||
#define KW_NULLPTR 341
|
||||
#define KW_OPERATOR 342
|
||||
#define KW_PRIVATE 343
|
||||
#define KW_PROTECTED 344
|
||||
#define KW_PUBLIC 345
|
||||
#define KW_REGISTER 346
|
||||
#define KW_RETURN 347
|
||||
#define KW_SHORT 348
|
||||
#define KW_SIGNED 349
|
||||
#define KW_SIZEOF 350
|
||||
#define KW_STATIC 351
|
||||
#define KW_STATIC_ASSERT 352
|
||||
#define KW_STATIC_CAST 353
|
||||
#define KW_STRUCT 354
|
||||
#define KW_TEMPLATE 355
|
||||
#define KW_THROW 356
|
||||
#define KW_TRUE 357
|
||||
#define KW_TRY 358
|
||||
#define KW_TYPEDEF 359
|
||||
#define KW_TYPENAME 360
|
||||
#define KW_UNION 361
|
||||
#define KW_UNSIGNED 362
|
||||
#define KW_USING 363
|
||||
#define KW_VIRTUAL 364
|
||||
#define KW_VOID 365
|
||||
#define KW_VOLATILE 366
|
||||
#define KW_WCHAR_T 367
|
||||
#define KW_WHILE 368
|
||||
#define START_CPP 369
|
||||
#define START_CONST_EXPR 370
|
||||
#define START_TYPE 371
|
||||
#define KW_MAKE_PROPERTY2 336
|
||||
#define KW_MAKE_SEQ 337
|
||||
#define KW_MUTABLE 338
|
||||
#define KW_NAMESPACE 339
|
||||
#define KW_NEW 340
|
||||
#define KW_NOEXCEPT 341
|
||||
#define KW_NULLPTR 342
|
||||
#define KW_OPERATOR 343
|
||||
#define KW_PRIVATE 344
|
||||
#define KW_PROTECTED 345
|
||||
#define KW_PUBLIC 346
|
||||
#define KW_REGISTER 347
|
||||
#define KW_RETURN 348
|
||||
#define KW_SHORT 349
|
||||
#define KW_SIGNED 350
|
||||
#define KW_SIZEOF 351
|
||||
#define KW_STATIC 352
|
||||
#define KW_STATIC_ASSERT 353
|
||||
#define KW_STATIC_CAST 354
|
||||
#define KW_STRUCT 355
|
||||
#define KW_TEMPLATE 356
|
||||
#define KW_THROW 357
|
||||
#define KW_TRUE 358
|
||||
#define KW_TRY 359
|
||||
#define KW_TYPEDEF 360
|
||||
#define KW_TYPENAME 361
|
||||
#define KW_UNION 362
|
||||
#define KW_UNSIGNED 363
|
||||
#define KW_USING 364
|
||||
#define KW_VIRTUAL 365
|
||||
#define KW_VOID 366
|
||||
#define KW_VOLATILE 367
|
||||
#define KW_WCHAR_T 368
|
||||
#define KW_WHILE 369
|
||||
#define START_CPP 370
|
||||
#define START_CONST_EXPR 371
|
||||
#define START_TYPE 372
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ pop_struct() {
|
|||
%token KW_LONG
|
||||
%token KW_LONGLONG
|
||||
%token KW_MAKE_PROPERTY
|
||||
%token KW_MAKE_PROPERTY2
|
||||
%token KW_MAKE_SEQ
|
||||
%token KW_MUTABLE
|
||||
%token KW_NAMESPACE
|
||||
|
|
@ -529,6 +530,61 @@ declaration:
|
|||
setter_func, current_scope, @1.file);
|
||||
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
|
||||
}
|
||||
}
|
||||
| KW_MAKE_PROPERTY2 '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
|
||||
{
|
||||
CPPDeclaration *hasser = $5->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid has-function: " + $5->get_fully_scoped_name(), @5);
|
||||
}
|
||||
|
||||
CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid getter: " + $7->get_fully_scoped_name(), @7);
|
||||
}
|
||||
|
||||
if (hasser && getter) {
|
||||
CPPMakeProperty *make_property;
|
||||
make_property = new CPPMakeProperty($3,
|
||||
hasser->as_function_group(),
|
||||
getter->as_function_group(),
|
||||
NULL, NULL,
|
||||
current_scope, @1.file);
|
||||
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
|
||||
}
|
||||
}
|
||||
| KW_MAKE_PROPERTY2 '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
|
||||
{
|
||||
CPPDeclaration *hasser = $5->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid has-function: " + $5->get_fully_scoped_name(), @5);
|
||||
}
|
||||
|
||||
CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid getter: " + $7->get_fully_scoped_name(), @7);
|
||||
}
|
||||
|
||||
CPPDeclaration *setter = $9->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid setter: " + $9->get_fully_scoped_name(), @9);
|
||||
}
|
||||
|
||||
CPPDeclaration *clearer = $11->find_symbol(current_scope, global_scope, current_lexer);
|
||||
if (clearer == (CPPDeclaration *)NULL || clearer->get_subtype() != CPPDeclaration::ST_function_group) {
|
||||
yyerror("Reference to non-existent or invalid clear-function: " + $11->get_fully_scoped_name(), @11);
|
||||
}
|
||||
|
||||
if (hasser && getter && setter && clearer) {
|
||||
CPPMakeProperty *make_property;
|
||||
make_property = new CPPMakeProperty($3,
|
||||
hasser->as_function_group(),
|
||||
getter->as_function_group(),
|
||||
setter->as_function_group(),
|
||||
clearer->as_function_group(),
|
||||
current_scope, @1.file);
|
||||
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
|
||||
}
|
||||
}
|
||||
| KW_MAKE_SEQ '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,8 +26,30 @@ CPPMakeProperty(CPPIdentifier *ident,
|
|||
CPPScope *current_scope, const CPPFile &file) :
|
||||
CPPDeclaration(file),
|
||||
_ident(ident),
|
||||
_getter(getter),
|
||||
_setter(setter)
|
||||
_has_function(NULL),
|
||||
_get_function(getter),
|
||||
_set_function(setter),
|
||||
_clear_function(NULL)
|
||||
{
|
||||
_ident->_native_scope = current_scope;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CPPMakeProperty::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPPMakeProperty::
|
||||
CPPMakeProperty(CPPIdentifier *ident,
|
||||
CPPFunctionGroup *hasser, CPPFunctionGroup *getter,
|
||||
CPPFunctionGroup *setter, CPPFunctionGroup *clearer,
|
||||
CPPScope *current_scope, const CPPFile &file) :
|
||||
CPPDeclaration(file),
|
||||
_ident(ident),
|
||||
_has_function(hasser),
|
||||
_get_function(getter),
|
||||
_set_function(setter),
|
||||
_clear_function(clearer)
|
||||
{
|
||||
_ident->_native_scope = current_scope;
|
||||
}
|
||||
|
|
@ -69,12 +91,28 @@ get_fully_scoped_name() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CPPMakeProperty::
|
||||
output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
|
||||
out << "__make_property(" << _ident->get_local_name(scope)
|
||||
<< ", " << _getter->_name;
|
||||
out << "__make_property";
|
||||
|
||||
if (_setter != NULL) {
|
||||
out << ", " << _setter->_name;
|
||||
if (_has_function != NULL) {
|
||||
out.put('2');
|
||||
}
|
||||
|
||||
out << "(" << _ident->get_local_name(scope);
|
||||
|
||||
if (_has_function != NULL) {
|
||||
out << ", " << _has_function->_name;
|
||||
}
|
||||
|
||||
out << ", " << _get_function->_name;
|
||||
|
||||
if (_set_function != NULL) {
|
||||
out << ", " << _set_function->_name;
|
||||
}
|
||||
|
||||
if (_clear_function != NULL) {
|
||||
out << ", " << _clear_function->_name;
|
||||
}
|
||||
|
||||
out << ");";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ public:
|
|||
CPPFunctionGroup *getter, CPPFunctionGroup *setter,
|
||||
CPPScope *current_scope, const CPPFile &file);
|
||||
|
||||
CPPMakeProperty(CPPIdentifier *ident,
|
||||
CPPFunctionGroup *hasser, CPPFunctionGroup *getter,
|
||||
CPPFunctionGroup *setter, CPPFunctionGroup *clearer,
|
||||
CPPScope *current_scope, const CPPFile &file);
|
||||
|
||||
virtual string get_simple_name() const;
|
||||
virtual string get_local_name(CPPScope *scope = NULL) const;
|
||||
virtual string get_fully_scoped_name() const;
|
||||
|
|
@ -45,8 +50,10 @@ public:
|
|||
virtual CPPMakeProperty *as_make_property();
|
||||
|
||||
CPPIdentifier *_ident;
|
||||
CPPFunctionGroup *_getter;
|
||||
CPPFunctionGroup *_setter;
|
||||
CPPFunctionGroup *_has_function;
|
||||
CPPFunctionGroup *_get_function;
|
||||
CPPFunctionGroup *_set_function;
|
||||
CPPFunctionGroup *_clear_function;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2535,6 +2535,7 @@ check_keyword(const string &name) {
|
|||
if (name == "int") return KW_INT;
|
||||
if (name == "long") return KW_LONG;
|
||||
if (name == "__make_property") return KW_MAKE_PROPERTY;
|
||||
if (name == "__make_property2") return KW_MAKE_PROPERTY2;
|
||||
if (name == "__make_seq") return KW_MAKE_SEQ;
|
||||
if (name == "mutable") return KW_MUTABLE;
|
||||
if (name == "namespace") return KW_NAMESPACE;
|
||||
|
|
|
|||
|
|
@ -416,6 +416,7 @@ typedef struct _object PyObject;
|
|||
#define END_PUBLISH __end_publish
|
||||
#define BLOCKING __blocking
|
||||
#define MAKE_PROPERTY(property_name, ...) __make_property(property_name, __VA_ARGS__)
|
||||
#define MAKE_PROPERTY2(property_name, ...) __make_property2(property_name, __VA_ARGS__)
|
||||
#define MAKE_SEQ(seq_name, num_name, element_name) __make_seq(seq_name, num_name, element_name)
|
||||
#undef USE_STL_ALLOCATOR /* Don't try to parse these template classes in interrogate. */
|
||||
#define EXTENSION(x) __extension x
|
||||
|
|
@ -425,6 +426,7 @@ typedef struct _object PyObject;
|
|||
#define END_PUBLISH
|
||||
#define BLOCKING
|
||||
#define MAKE_PROPERTY(property_name, ...)
|
||||
#define MAKE_PROPERTY2(property_name, ...)
|
||||
#define MAKE_SEQ(seq_name, num_name, element_name)
|
||||
#define EXTENSION(x)
|
||||
#define EXTEND
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ InterfaceMaker::Property::
|
|||
Property(const InterrogateElement &ielement) :
|
||||
_ielement(ielement),
|
||||
_getter(NULL),
|
||||
_setter(NULL)
|
||||
_setter(NULL),
|
||||
_has_function(NULL),
|
||||
_clear_function(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ public:
|
|||
const InterrogateElement &_ielement;
|
||||
Function *_getter;
|
||||
Function *_setter;
|
||||
Function *_has_function;
|
||||
Function *_clear_function;
|
||||
};
|
||||
typedef vector<Property *> Properties;
|
||||
|
||||
|
|
|
|||
|
|
@ -1045,22 +1045,8 @@ write_class_details(ostream &out, Object *obj) {
|
|||
Properties::const_iterator pit;
|
||||
for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) {
|
||||
Property *property = (*pit);
|
||||
const InterrogateElement &ielem = property->_ielement;
|
||||
string expected_params;
|
||||
|
||||
if (property->_getter != NULL) {
|
||||
std::string fname = "PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *)";
|
||||
write_function_for_name(out, obj, property->_getter->_remaps,
|
||||
fname, expected_params, true,
|
||||
AT_no_args, RF_pyobject | RF_err_null);
|
||||
}
|
||||
|
||||
if (property->_setter != NULL) {
|
||||
std::string fname = "int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *)";
|
||||
write_function_for_name(out, obj, property->_setter->_remaps,
|
||||
fname, expected_params, true,
|
||||
AT_single_arg, RF_int);
|
||||
}
|
||||
write_getset(out, obj, property);
|
||||
}
|
||||
|
||||
// Write the constructors.
|
||||
|
|
@ -6443,6 +6429,86 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
|
|||
"\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: InterfaceMakerPythonName::write_getset
|
||||
// Access: Public
|
||||
// Description: Generates the synthetic method described by the
|
||||
// MAKE_PROPERTY() macro.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void InterfaceMakerPythonNative::
|
||||
write_getset(ostream &out, Object *obj, Property *property) {
|
||||
|
||||
string ClassName = make_safe_name(obj->_itype.get_scoped_name());
|
||||
std::string cClassName = obj->_itype.get_true_name();
|
||||
|
||||
const InterrogateElement &ielem = property->_ielement;
|
||||
|
||||
if (property->_getter != NULL) {
|
||||
FunctionRemap *remap = property->_getter->_remaps.front();
|
||||
|
||||
out << "PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n";
|
||||
if (remap->_const_method) {
|
||||
out << " const " << cClassName << " *local_this = NULL;\n";
|
||||
out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n";
|
||||
} else {
|
||||
out << " " << cClassName << " *local_this = NULL;\n";
|
||||
out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \""
|
||||
<< classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n";
|
||||
}
|
||||
out << " return NULL;\n";
|
||||
out << " }\n\n";
|
||||
|
||||
if (property->_has_function != NULL) {
|
||||
out << " if (!local_this->" << property->_has_function->_ifunc.get_name() << "()) {\n"
|
||||
<< " Py_INCREF(Py_None);\n"
|
||||
<< " return Py_None;\n"
|
||||
<< " }\n";
|
||||
}
|
||||
|
||||
std::set<FunctionRemap*> remaps;
|
||||
remaps.insert(remap);
|
||||
|
||||
string expected_params;
|
||||
write_function_forset(out, remaps, 0, 0,
|
||||
expected_params, 2, false, true, AT_no_args,
|
||||
RF_pyobject | RF_err_null, false, false);
|
||||
out << "}\n\n";
|
||||
}
|
||||
|
||||
if (property->_setter != NULL) {
|
||||
out << "int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *) {\n";
|
||||
out << " " << cClassName << " *local_this = NULL;\n";
|
||||
out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \""
|
||||
<< classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n";
|
||||
out << " return -1;\n";
|
||||
out << " }\n\n";
|
||||
|
||||
if (property->_clear_function != NULL) {
|
||||
out << " if (arg == Py_None) {\n"
|
||||
<< " local_this->" << property->_clear_function->_ifunc.get_name() << "();\n"
|
||||
<< " return 0;\n"
|
||||
<< " }\n";
|
||||
}
|
||||
|
||||
std::set<FunctionRemap*> remaps;
|
||||
remaps.insert(property->_setter->_remaps.begin(),
|
||||
property->_setter->_remaps.end());
|
||||
|
||||
string expected_params;
|
||||
write_function_forset(out, remaps, 1, 1,
|
||||
expected_params, 2, true, true, AT_single_arg,
|
||||
RF_int, false, false);
|
||||
|
||||
out << " if (!_PyErr_OCCURRED()) {\n";
|
||||
out << " Dtool_Raise_BadArgumentsError(\n";
|
||||
output_quoted(out, 6, expected_params);
|
||||
out << ");\n";
|
||||
out << " }\n";
|
||||
out << " return -1;\n";
|
||||
out << "}\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: InterfaceMakerPythonNative::record_object
|
||||
// Access: Protected
|
||||
|
|
@ -6551,6 +6617,22 @@ record_object(TypeIndex type_index) {
|
|||
}
|
||||
}
|
||||
|
||||
if (ielement.has_has_function()) {
|
||||
FunctionIndex func_index = ielement.get_has_function();
|
||||
Function *has_function = record_function(itype, func_index);
|
||||
if (is_function_legal(has_function)) {
|
||||
property->_has_function = has_function;
|
||||
}
|
||||
}
|
||||
|
||||
if (ielement.has_clear_function()) {
|
||||
FunctionIndex func_index = ielement.get_clear_function();
|
||||
Function *clear_function = record_function(itype, func_index);
|
||||
if (is_function_legal(clear_function)) {
|
||||
property->_clear_function = clear_function;
|
||||
}
|
||||
}
|
||||
|
||||
if (property->_getter != NULL) {
|
||||
object->_properties.push_back(property);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ private:
|
|||
|
||||
void write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
|
||||
const std::string &cClassName, MakeSeq *make_seq);
|
||||
void write_getset(ostream &out, Object *obj, Property *property);
|
||||
|
||||
void write_class_prototypes(ostream &out) ;
|
||||
void write_class_declarations(ostream &out, ostream *out_h, Object *obj);
|
||||
|
|
|
|||
|
|
@ -1927,7 +1927,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
|
|||
CPPInstance *getter = NULL;
|
||||
CPPType *return_type = NULL;
|
||||
|
||||
CPPFunctionGroup *fgroup = make_property->_getter;
|
||||
CPPFunctionGroup *fgroup = make_property->_get_function;
|
||||
if (fgroup != NULL) {
|
||||
CPPFunctionGroup::Instances::const_iterator fi;
|
||||
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
|
||||
|
|
@ -1953,6 +1953,29 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
|
|||
}
|
||||
}
|
||||
|
||||
// Find the "hasser".
|
||||
CPPInstance *hasser = NULL;
|
||||
|
||||
fgroup = make_property->_has_function;
|
||||
if (fgroup != NULL) {
|
||||
CPPFunctionGroup::Instances::const_iterator fi;
|
||||
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
|
||||
CPPInstance *function = (*fi);
|
||||
CPPFunctionType *ftype =
|
||||
function->_type->as_function_type();
|
||||
if (ftype != NULL && TypeManager::is_bool(ftype->_return_type)) {
|
||||
hasser = function;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasser == NULL || return_type == NULL) {
|
||||
cerr << "No instance of has-function '"
|
||||
<< fgroup->_name << "' is suitable!\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
|
||||
// It isn't here, so we'll have to define it.
|
||||
ElementIndex index = idb->get_next_index();
|
||||
|
|
@ -1975,6 +1998,18 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
|
|||
iproperty._flags |= InterrogateElement::F_has_getter;
|
||||
iproperty._getter = get_function(getter, "", struct_type,
|
||||
struct_type->get_scope(), 0);
|
||||
if (iproperty._getter == 0) {
|
||||
cerr << "failed " << *getter << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (hasser != NULL) {
|
||||
iproperty._flags |= InterrogateElement::F_has_has_function;
|
||||
iproperty._has_function = get_function(hasser, "", struct_type,
|
||||
struct_type->get_scope(), 0);
|
||||
if (iproperty._has_function == 0) {
|
||||
cerr << "failed " << *hasser << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// See if there happens to be a comment before the MAKE_PROPERTY macro.
|
||||
|
|
@ -1983,7 +2018,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
|
|||
}
|
||||
|
||||
// Now look for setters.
|
||||
fgroup = make_property->_setter;
|
||||
fgroup = make_property->_set_function;
|
||||
if (fgroup != NULL) {
|
||||
CPPFunctionGroup::Instances::const_iterator fi;
|
||||
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
|
||||
|
|
@ -1991,6 +2026,25 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
|
|||
iproperty._flags |= InterrogateElement::F_has_setter;
|
||||
iproperty._setter = get_function(function, "", struct_type,
|
||||
struct_type->get_scope(), 0);
|
||||
if (iproperty._setter == 0) {
|
||||
cerr << "failed " << *function << "\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fgroup = make_property->_clear_function;
|
||||
if (fgroup != NULL) {
|
||||
CPPFunctionGroup::Instances::const_iterator fi;
|
||||
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
|
||||
CPPInstance *function = (*fi);
|
||||
iproperty._flags |= InterrogateElement::F_has_clear_function;
|
||||
iproperty._clear_function = get_function(function, "", struct_type,
|
||||
struct_type->get_scope(), 0);
|
||||
if (iproperty._clear_function == 0) {
|
||||
cerr << "failed " << *function << "\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ InterrogateDatabase *InterrogateDatabase::_global_ptr = NULL;
|
|||
int InterrogateDatabase::_file_major_version = 0;
|
||||
int InterrogateDatabase::_file_minor_version = 0;
|
||||
int InterrogateDatabase::_current_major_version = 3;
|
||||
int InterrogateDatabase::_current_minor_version = 0;
|
||||
int InterrogateDatabase::_current_minor_version = 1;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: InterrogateDatabase::Constructor
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ InterrogateElement(InterrogateModuleDef *def) :
|
|||
_type = 0;
|
||||
_getter = 0;
|
||||
_setter = 0;
|
||||
_has_function = 0;
|
||||
_clear_function = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -52,6 +54,8 @@ operator = (const InterrogateElement ©) {
|
|||
_type = copy._type;
|
||||
_getter = copy._getter;
|
||||
_setter = copy._setter;
|
||||
_has_function = copy._has_function;
|
||||
_clear_function = copy._clear_function;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -156,6 +160,46 @@ get_setter() const {
|
|||
return _setter;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Element: InterrogateElement::has_has_function
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool InterrogateElement::
|
||||
has_has_function() const {
|
||||
return (_flags & F_has_has_function) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Element: InterrogateElement::get_has_function
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE FunctionIndex InterrogateElement::
|
||||
get_has_function() const {
|
||||
return _has_function;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Element: InterrogateElement::has_clear_function
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool InterrogateElement::
|
||||
has_clear_function() const {
|
||||
return (_flags & F_has_clear_function) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Element: InterrogateElement::get_clear_function
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE FunctionIndex InterrogateElement::
|
||||
get_clear_function() const {
|
||||
return _clear_function;
|
||||
}
|
||||
|
||||
|
||||
INLINE ostream &
|
||||
operator << (ostream &out, const InterrogateElement &element) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ output(ostream &out) const {
|
|||
out << _flags << " "
|
||||
<< _type << " "
|
||||
<< _getter << " "
|
||||
<< _setter << " ";
|
||||
<< _setter << " "
|
||||
<< _has_function << " "
|
||||
<< _clear_function << " ";
|
||||
idf_output_string(out, _scoped_name);
|
||||
idf_output_string(out, _comment, '\n');
|
||||
}
|
||||
|
|
@ -44,6 +46,9 @@ void InterrogateElement::
|
|||
input(istream &in) {
|
||||
InterrogateComponent::input(in);
|
||||
in >> _flags >> _type >> _getter >> _setter;
|
||||
if (InterrogateDatabase::get_file_minor_version() >= 1) {
|
||||
in >> _has_function >> _clear_function;
|
||||
}
|
||||
idf_input_string(in, _scoped_name);
|
||||
idf_input_string(in, _comment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ public:
|
|||
INLINE FunctionIndex get_getter() const;
|
||||
INLINE bool has_setter() const;
|
||||
INLINE FunctionIndex get_setter() const;
|
||||
INLINE bool has_has_function() const;
|
||||
INLINE FunctionIndex get_has_function() const;
|
||||
INLINE bool has_clear_function() const;
|
||||
INLINE FunctionIndex get_clear_function() const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
void input(istream &in);
|
||||
|
|
@ -55,7 +59,9 @@ private:
|
|||
enum Flags {
|
||||
F_global = 0x0001,
|
||||
F_has_getter = 0x0002,
|
||||
F_has_setter = 0x0004
|
||||
F_has_setter = 0x0004,
|
||||
F_has_has_function= 0x0008,
|
||||
F_has_clear_function= 0x0010,
|
||||
};
|
||||
|
||||
int _flags;
|
||||
|
|
@ -64,6 +70,8 @@ private:
|
|||
TypeIndex _type;
|
||||
FunctionIndex _getter;
|
||||
FunctionIndex _setter;
|
||||
FunctionIndex _has_function;
|
||||
FunctionIndex _clear_function;
|
||||
|
||||
friend class InterrogateBuilder;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ set_gamma(PN_stdfloat gamma) {
|
|||
// Description: Get the current gamma setting.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PN_stdfloat GraphicsStateGuardian::
|
||||
get_gamma(PN_stdfloat gamma) {
|
||||
get_gamma() const {
|
||||
return _gamma;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ PUBLISHED:
|
|||
MAKE_PROPERTY(prepared_objects, get_prepared_objects);
|
||||
|
||||
virtual bool set_gamma(PN_stdfloat gamma);
|
||||
PN_stdfloat get_gamma(PN_stdfloat gamma);
|
||||
PN_stdfloat get_gamma() const;
|
||||
virtual void restore_gamma();
|
||||
MAKE_PROPERTY(gamma, get_gamma, set_gamma);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ PUBLISHED:
|
|||
INLINE int get_y_origin() const;
|
||||
INLINE bool has_origin() const;
|
||||
INLINE void clear_origin();
|
||||
MAKE_PROPERTY2(origin, has_origin, get_origin, set_origin, clear_origin);
|
||||
|
||||
INLINE void set_size(const LVector2i &size);
|
||||
INLINE void set_size(int x_size, int y_size);
|
||||
|
|
@ -76,41 +77,55 @@ PUBLISHED:
|
|||
INLINE int get_y_size() const;
|
||||
INLINE bool has_size() const;
|
||||
INLINE void clear_size();
|
||||
MAKE_PROPERTY2(size, has_size, get_size, set_size, clear_size);
|
||||
|
||||
INLINE bool has_mouse_mode() const;
|
||||
INLINE void set_mouse_mode(MouseMode mode);
|
||||
INLINE MouseMode get_mouse_mode() const;
|
||||
INLINE void clear_mouse_mode();
|
||||
MAKE_PROPERTY2(mouse_mode, has_mouse_mode, get_mouse_mode,
|
||||
set_mouse_mode, clear_mouse_mode);
|
||||
|
||||
INLINE void set_title(const string &title);
|
||||
INLINE const string &get_title() const;
|
||||
INLINE bool has_title() const;
|
||||
INLINE void clear_title();
|
||||
MAKE_PROPERTY2(title, has_title, get_title, set_title, clear_title);
|
||||
|
||||
INLINE void set_undecorated(bool undecorated);
|
||||
INLINE bool get_undecorated() const;
|
||||
INLINE bool has_undecorated() const;
|
||||
INLINE void clear_undecorated();
|
||||
MAKE_PROPERTY2(undecorated, has_undecorated, get_undecorated,
|
||||
set_undecorated, clear_undecorated);
|
||||
|
||||
INLINE void set_fixed_size(bool fixed_size);
|
||||
INLINE bool get_fixed_size() const;
|
||||
INLINE bool has_fixed_size() const;
|
||||
INLINE void clear_fixed_size();
|
||||
MAKE_PROPERTY2(fixed_size, has_fixed_size, get_fixed_size,
|
||||
set_fixed_size, clear_fixed_size);
|
||||
|
||||
INLINE void set_fullscreen(bool fullscreen);
|
||||
INLINE bool get_fullscreen() const;
|
||||
INLINE bool has_fullscreen() const;
|
||||
INLINE void clear_fullscreen();
|
||||
MAKE_PROPERTY2(fullscreen, has_fullscreen, get_fullscreen,
|
||||
set_fullscreen, clear_fullscreen);
|
||||
|
||||
INLINE void set_foreground(bool foreground);
|
||||
INLINE bool get_foreground() const;
|
||||
INLINE bool has_foreground() const;
|
||||
INLINE void clear_foreground();
|
||||
MAKE_PROPERTY2(foreground, has_foreground, get_foreground,
|
||||
set_foreground, clear_foreground);
|
||||
|
||||
INLINE void set_minimized(bool minimized);
|
||||
INLINE bool get_minimized() const;
|
||||
INLINE bool has_minimized() const;
|
||||
INLINE void clear_minimized();
|
||||
MAKE_PROPERTY2(minimized, has_minimized, get_minimized,
|
||||
set_minimized, clear_minimized);
|
||||
|
||||
INLINE void set_raw_mice(bool raw_mice);
|
||||
INLINE bool get_raw_mice() const;
|
||||
|
|
@ -121,32 +136,42 @@ PUBLISHED:
|
|||
INLINE bool get_open() const;
|
||||
INLINE bool has_open() const;
|
||||
INLINE void clear_open();
|
||||
MAKE_PROPERTY2(open, has_open, get_open, set_open, clear_open);
|
||||
|
||||
INLINE void set_cursor_hidden(bool cursor_hidden);
|
||||
INLINE bool get_cursor_hidden() const;
|
||||
INLINE bool has_cursor_hidden() const;
|
||||
INLINE void clear_cursor_hidden();
|
||||
MAKE_PROPERTY2(cursor_hidden, has_cursor_hidden, get_cursor_hidden,
|
||||
set_cursor_hidden, clear_cursor_hidden);
|
||||
|
||||
INLINE void set_icon_filename(const Filename &icon_filename);
|
||||
INLINE const Filename &get_icon_filename() const;
|
||||
INLINE bool has_icon_filename() const;
|
||||
INLINE void clear_icon_filename();
|
||||
MAKE_PROPERTY2(icon_filename, has_icon_filename, get_icon_filename,
|
||||
set_icon_filename, clear_icon_filename);
|
||||
|
||||
INLINE void set_cursor_filename(const Filename &cursor_filename);
|
||||
INLINE const Filename &get_cursor_filename() const;
|
||||
INLINE bool has_cursor_filename() const;
|
||||
INLINE void clear_cursor_filename();
|
||||
MAKE_PROPERTY2(cursor_filename, has_cursor_filename, get_cursor_filename,
|
||||
set_cursor_filename, clear_cursor_filename);
|
||||
|
||||
INLINE void set_z_order(ZOrder z_order);
|
||||
INLINE ZOrder get_z_order() const;
|
||||
INLINE bool has_z_order() const;
|
||||
INLINE void clear_z_order();
|
||||
MAKE_PROPERTY2(z_order, has_z_order, get_z_order, set_z_order, clear_z_order);
|
||||
|
||||
void set_parent_window(size_t parent);
|
||||
INLINE void set_parent_window(WindowHandle *parent_window = NULL);
|
||||
INLINE WindowHandle *get_parent_window() const;
|
||||
INLINE bool has_parent_window() const;
|
||||
INLINE void clear_parent_window();
|
||||
MAKE_PROPERTY2(parent_window, has_parent_window, get_parent_window,
|
||||
set_parent_window, clear_parent_window);
|
||||
|
||||
void add_properties(const WindowProperties &other);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,17 +57,22 @@ PUBLISHED:
|
|||
const Filename &target_file);
|
||||
|
||||
INLINE PN_stdfloat get_progress() const;
|
||||
MAKE_PROPERTY(progress, get_progress);
|
||||
|
||||
INLINE void set_allow_multifile(bool allow_multifile);
|
||||
INLINE bool get_allow_multifile();
|
||||
MAKE_PROPERTY(allow_multifile, get_allow_multifile, set_allow_multifile);
|
||||
|
||||
INLINE void set_footprint_length(int length);
|
||||
INLINE int get_footprint_length();
|
||||
INLINE void reset_footprint_length();
|
||||
MAKE_PROPERTY(footprint_length, get_footprint_length, set_footprint_length);
|
||||
|
||||
INLINE bool has_source_hash() const;
|
||||
INLINE const HashVal &get_source_hash() const;
|
||||
INLINE const HashVal &get_result_hash() const;
|
||||
MAKE_PROPERTY2(source_hash, has_source_hash, get_source_hash);
|
||||
MAKE_PROPERTY(result_hash, get_result_hash);
|
||||
|
||||
private:
|
||||
int internal_read_header(const Filename &patch_file);
|
||||
|
|
|
|||
Loading…
Reference in New Issue