Author: toshok
Date: 2007-07-21 04:25:59 -0400 (Sat, 21 Jul 2007)
New Revision: 82408
Modified:
trunk/moon/plugin/ChangeLog
trunk/moon/plugin/plugin-class.cpp
trunk/moon/plugin/plugin-class.h
Log:
2007-07-21 Chris Toshok <[EMAIL PROTECTED]>
* plugin-class.cpp (variant_to_value): fix this such that it
doesn't crash due to c++'s not using a copy ctor when you do "foo
= Value()". the first of the changes are fallout from this.
Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-07-21 06:21:25 UTC (rev 82407)
+++ trunk/moon/plugin/ChangeLog 2007-07-21 08:25:59 UTC (rev 82408)
@@ -1,3 +1,9 @@
+2007-07-21 Chris Toshok <[EMAIL PROTECTED]>
+
+ * plugin-class.cpp (variant_to_value): fix this such that it
+ doesn't crash due to c++'s not using a copy ctor when you do "foo
+ = Value()". the first of the changes are fallout from this.
+
2007-07-20 Miguel de Icaza <[EMAIL PROTECTED]>
* Fix a memory leak.
Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp 2007-07-21 06:21:25 UTC (rev 82407)
+++ trunk/moon/plugin/plugin-class.cpp 2007-07-21 08:25:59 UTC (rev 82408)
@@ -226,30 +226,32 @@
}
static void
-variant_to_value (const NPVariant *v, Value *result)
+variant_to_value (const NPVariant *v, Value **result)
{
switch (v->type) {
- case NPVariantType_Void:
- DEBUG_WARN_NOTIMPLEMENTED ("void variant type");
- break;
- case NPVariantType_Null:
- DEBUG_WARN_NOTIMPLEMENTED ("null variant type");
- *result = Value (Type::DEPENDENCY_OBJECT);
- break;
case NPVariantType_Bool:
- *result = Value (NPVARIANT_TO_BOOLEAN (*v));
+ *result = new Value (NPVARIANT_TO_BOOLEAN (*v));
break;
case NPVariantType_Int32:
- *result = Value ((gint32)NPVARIANT_TO_INT32(*v));
+ *result = new Value ((gint32)NPVARIANT_TO_INT32(*v));
break;
case NPVariantType_Double:
- *result = Value (NPVARIANT_TO_DOUBLE(*v));
+ *result = new Value (NPVARIANT_TO_DOUBLE(*v));
break;
case NPVariantType_String:
- *result = Value (NPVARIANT_TO_STRING(*v).utf8characters);
+ *result = new Value (NPVARIANT_TO_STRING(*v).utf8characters);
break;
+ case NPVariantType_Void:
+ DEBUG_WARN_NOTIMPLEMENTED ("void variant type");
+ *result = NULL;
+ break;
+ case NPVariantType_Null:
+ DEBUG_WARN_NOTIMPLEMENTED ("null variant type");
+ *result = new Value (Type::DEPENDENCY_OBJECT);
+ break;
case NPVariantType_Object:
DEBUG_WARN_NOTIMPLEMENTED ("object variant type");
+ *result = NULL;
break;
}
}
@@ -1518,16 +1520,15 @@
return true;
}
else if (name_matches (name, "seek")) {
- // not yet implemented
- DEBUG_WARN_NOTIMPLEMENTED ("storyboard.seek");
-#if notyet
- if (argCount != 1)
+ // XXX JS doesn't have 64bit ints?
+ if (argCount != 1 || !NPVARIANT_IS_INT32 (args[0]))
return true;
- sb->Seek (...);
+ TimeSpan ts = (TimeSpan)NPVARIANT_TO_INT32(args[0]);
+ sb->Seek (ts);
VOID_TO_NPVARIANT (*result);
-#endif
+
return true;
}
else if (name_matches (name, "stop")) {
@@ -1785,7 +1786,14 @@
DEBUGMSG ("***************** getting scriptable object property %s",
strname);
NPN_MemFree (strname);
- DEBUG_WARN_NOTIMPLEMENTED ("scriptableobject.get_property");
+ Value v;
+
+ sobj->getprop (sobj->managed_scriptable, prop->property_handle, &v);
+
+ value_to_variant (npobj, &v, result);
+
+ v.FreeValue ();
+
return true;
}
@@ -1801,7 +1809,14 @@
DEBUGMSG ("***************** setting scriptable object property
%s", strname);
NPN_MemFree (strname);
- DEBUG_WARN_NOTIMPLEMENTED ("scriptableobject.set_property");
+ Value *v;
+
+ variant_to_value (value, &v);
+
+ sobj->setprop (sobj->managed_scriptable, prop->property_handle,
v);
+
+ delete v;
+
return true;
}
// if that fails, look for the event of that name
@@ -1840,10 +1855,10 @@
Value rv;
- Value* vargs = NULL;
+ Value** vargs = NULL;
if (argCount > 0) {
- vargs = new Value[argCount];
+ vargs = new Value*[argCount];
for (int i = 0; i < argCount; i ++) {
variant_to_value (&args[i], &vargs[i]);
}
@@ -1851,7 +1866,13 @@
sobj->invoke (sobj->managed_scriptable, method->method_handle, vargs,
argCount, &rv);
- delete [] vargs;
+ if (argCount > 0) {
+ for (int i = 0; i < argCount; i ++) {
+ delete vargs[i];
+ }
+ delete [] vargs;
+ }
+
if (method->method_return_type != 1 /* XXX this 1 is "void" */) {
value_to_variant (sobj, &rv, result);
}
Modified: trunk/moon/plugin/plugin-class.h
===================================================================
--- trunk/moon/plugin/plugin-class.h 2007-07-21 06:21:25 UTC (rev 82407)
+++ trunk/moon/plugin/plugin-class.h 2007-07-21 08:25:59 UTC (rev 82408)
@@ -214,8 +214,8 @@
/*** MoonlightScriptableObject
***************************************************/
-typedef void (*InvokeDelegate) (gpointer obj_handle, gpointer method_handle,
Value* args, int arg_count, Value* return_value);
-typedef void (*SetPropertyDelegate) (gpointer obj_handle, gpointer
property_handle, Value value);
+typedef void (*InvokeDelegate) (gpointer obj_handle, gpointer method_handle,
Value** args, int arg_count, Value* return_value);
+typedef void (*SetPropertyDelegate) (gpointer obj_handle, gpointer
property_handle, Value *value);
typedef void (*GetPropertyDelegate) (gpointer obj_handle, gpointer
property_handle, Value *value);
typedef void (*EventHandlerDelegate) (gpointer obj_handle, gpointer
event_handle);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches