mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
some minor problems
This commit is contained in:
parent
8966fe7dbf
commit
4ee298e942
@ -199,6 +199,17 @@ P3DObject::
|
||||
assert(_ref_count == 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DObject::is_python_object
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this is actually an instance of a
|
||||
// P3DPythonObject, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool P3DObject::
|
||||
is_python_object() {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DObject::get_int
|
||||
// Access: Public, Virtual
|
||||
|
@ -33,6 +33,8 @@ protected:
|
||||
public:
|
||||
virtual ~P3DObject();
|
||||
|
||||
virtual bool is_python_object();
|
||||
|
||||
virtual P3D_object_type get_type()=0;
|
||||
virtual bool get_bool()=0;
|
||||
virtual int get_int();
|
||||
|
@ -43,6 +43,17 @@ P3DPythonObject::
|
||||
unref_delete(_session);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonObject::is_python_object
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this is actually an instance of a
|
||||
// P3DPythonObject, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool P3DPythonObject::
|
||||
is_python_object() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonObject::get_type
|
||||
// Access: Public, Virtual
|
||||
@ -271,6 +282,18 @@ output(ostream &out) {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonObject::get_session
|
||||
// Access: Public
|
||||
// Description: Returns the session that this object is identified
|
||||
// with.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
P3DSession *P3DPythonObject::
|
||||
get_session() {
|
||||
return _session;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DPythonObject::get_object_id
|
||||
// Access: Public
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
P3DPythonObject(P3DSession *session, int object_id);
|
||||
virtual ~P3DPythonObject();
|
||||
|
||||
virtual bool is_python_object();
|
||||
|
||||
public:
|
||||
virtual P3D_object_type get_type();
|
||||
virtual bool get_bool();
|
||||
@ -49,6 +51,8 @@ public:
|
||||
P3D_object *params[], int num_params);
|
||||
|
||||
virtual void output(ostream &out);
|
||||
|
||||
P3DSession *get_session();
|
||||
int get_object_id();
|
||||
|
||||
private:
|
||||
|
@ -458,7 +458,9 @@ p3dobj_to_xml(P3D_object *obj) {
|
||||
break;
|
||||
|
||||
case P3D_OT_object:
|
||||
if (obj->_class == &P3DObject::_object_class) {
|
||||
if (obj->_class == &P3DObject::_object_class &&
|
||||
((P3DObject *)obj)->is_python_object() &&
|
||||
((P3DPythonObject *)obj)->get_session() == this) {
|
||||
// If it's one of our kind of objects, it must be a
|
||||
// P3DPythonObject. In this case, just send the object_id down,
|
||||
// since the actual implementation of this object exists (as a
|
||||
|
@ -473,31 +473,39 @@ class BrowserObject:
|
||||
return True
|
||||
|
||||
def __call__(self, *args):
|
||||
parentObj, attribName = self.__boundMethod
|
||||
if parentObj:
|
||||
# Call it as a method.
|
||||
needsResponse = True
|
||||
if parentObj is self.__runner.dom and attribName == 'alert':
|
||||
# As a special hack, we don't wait for the return
|
||||
# value from the alert() call, since this is a
|
||||
# blocking call, and waiting for this could cause
|
||||
# problems.
|
||||
needsResponse = False
|
||||
|
||||
if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], types.StringTypes):
|
||||
# As another special hack, we make dom.eval() a
|
||||
# special case, and map it directly into an eval()
|
||||
# call. If the string begins with 'void ', we further
|
||||
# assume we're not waiting for a response.
|
||||
if args[0].startswith('void '):
|
||||
try:
|
||||
parentObj, attribName = self.__boundMethod
|
||||
if parentObj:
|
||||
# Call it as a method.
|
||||
needsResponse = True
|
||||
if parentObj is self.__runner.dom and attribName == 'alert':
|
||||
# As a special hack, we don't wait for the return
|
||||
# value from the alert() call, since this is a
|
||||
# blocking call, and waiting for this could cause
|
||||
# problems.
|
||||
needsResponse = False
|
||||
result = self.__runner.scriptRequest('eval', parentObj, value = args[0], needsResponse = needsResponse)
|
||||
|
||||
if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], types.StringTypes):
|
||||
# As another special hack, we make dom.eval() a
|
||||
# special case, and map it directly into an eval()
|
||||
# call. If the string begins with 'void ', we further
|
||||
# assume we're not waiting for a response.
|
||||
if args[0].startswith('void '):
|
||||
needsResponse = False
|
||||
result = self.__runner.scriptRequest('eval', parentObj, value = args[0], needsResponse = needsResponse)
|
||||
else:
|
||||
# This is a normal method call.
|
||||
try:
|
||||
result = self.__runner.scriptRequest('call', parentObj, propertyName = attribName, value = args, needsResponse = needsResponse)
|
||||
except EnvironmentError:
|
||||
# Problem on the call. Maybe no such method?
|
||||
raise AttributeError
|
||||
else:
|
||||
# This is a normal method call.
|
||||
result = self.__runner.scriptRequest('call', parentObj, propertyName = attribName, value = args, needsResponse = needsResponse)
|
||||
else:
|
||||
# Call it as a plain function.
|
||||
result = self.__runner.scriptRequest('call', self, value = args)
|
||||
# Call it as a plain function.
|
||||
result = self.__runner.scriptRequest('call', self, value = args)
|
||||
except EnvironmentError:
|
||||
# Some odd problem on the call.
|
||||
raise TypeError
|
||||
|
||||
return result
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user