Author: gert
Date: 2008-01-03 16:31:04 -0500 (Thu, 03 Jan 2008)
New Revision: 92205
Added:
trunk/gert/standalone/bug351520/
trunk/gert/standalone/bug351520/default.build
trunk/gert/standalone/bug351520/hello.cpp
trunk/gert/standalone/bug351520/test.cs
Modified:
trunk/gert/standalone/known-issues
Log:
Added test for bug #351520.
Added: trunk/gert/standalone/bug351520/default.build
===================================================================
--- trunk/gert/standalone/bug351520/default.build 2008-01-03 20:33:32 UTC
(rev 92204)
+++ trunk/gert/standalone/bug351520/default.build 2008-01-03 21:31:04 UTC
(rev 92205)
@@ -0,0 +1,35 @@
+<project name="bug351520" default="rebuild">
+ <include buildfile="../../build/common.build" />
+
+ <property name="frameworks" value="mono-2.0,net-2.0" />
+
+ <target name="clean">
+ <delete>
+ <fileset>
+ <include name="libhello.so" />
+ <include name="out" />
+ <include name="test.exe" />
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="compile" depends="init">
+ <exec program="g++">
+ <arg value="--shared" />
+ <arg value="-fpic" />
+ <arg value="-o" />
+ <arg file="libhello.so" />
+ <arg file="hello.cpp" />
+ </exec>
+ <csc target="exe" define="${csc.defines}" output="test.exe"
warninglevel="4">
+ <sources>
+ <include name="test.cs" />
+ </sources>
+ </csc>
+ </target>
+
+ <target name="run-test" depends="compile">
+ <exec program="test.exe" managed="true" output="out" />
+ <fail if="${file::exists('out')}">#1</fail>
+ </target>
+</project>
Property changes on: trunk/gert/standalone/bug351520/default.build
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/gert/standalone/bug351520/hello.cpp
===================================================================
--- trunk/gert/standalone/bug351520/hello.cpp 2008-01-03 20:33:32 UTC (rev
92204)
+++ trunk/gert/standalone/bug351520/hello.cpp 2008-01-03 21:31:04 UTC (rev
92205)
@@ -0,0 +1,43 @@
+/***
+ *
+ * Simple mono embedding example.
+ *
+ *
+ ***/
+
+#include <iostream>
+
+#define CALLING_CONVENTION __attribute__((cdecl))
+
+extern "C"
+{
+
+ typedef CALLING_CONVENTION void (*CallbackFunction)(void);
+
+ void CALLING_CONVENTION print_hello_world()
+ {
+ std::wcout << "Hello, World!" << std::endl;
+ }
+
+ void CALLING_CONVENTION DoNothing()
+ {
+ std::wcout << "Not doing anything!" << std::endl;
+ }
+
+
+ CallbackFunction CALLING_CONVENTION GetCallbackI()
+ {
+ std::wcout << "In GetCallbackI!" << std::endl;
+ return print_hello_world;
+ }
+
+
+ void CALLING_CONVENTION GetCallbackII(CallbackFunction * callback)
+ {
+ std::wcout << "In GetCallbackII!" << std::endl;
+ *callback = print_hello_world;
+ }
+}
+
+
+
Property changes on: trunk/gert/standalone/bug351520/hello.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/gert/standalone/bug351520/test.cs
===================================================================
--- trunk/gert/standalone/bug351520/test.cs 2008-01-03 20:33:32 UTC (rev
92204)
+++ trunk/gert/standalone/bug351520/test.cs 2008-01-03 21:31:04 UTC (rev
92205)
@@ -0,0 +1,29 @@
+using System;
+using System.Runtime.InteropServices;
+
+class Program
+{
+ static void Main ()
+ {
+ DoNothing ();
+ Callback callback = null;
+ callback = GetCallbackI ();
+ callback ();
+ GetCallbackII (out callback);
+ callback ();
+ }
+
+ [UnmanagedFunctionPointer (convention)]
+ internal delegate void Callback ();
+
+ [DllImport ("libhello.dll", CallingConvention = convention)]
+ internal static extern void DoNothing ();
+
+ [DllImport ("libhello.dll", CallingConvention = convention)]
+ internal static extern Callback GetCallbackI ();
+
+ [DllImport ("libhello.dll", CallingConvention = convention)]
+ internal static extern void GetCallbackII (out Callback callback);
+
+ const CallingConvention convention = CallingConvention.Cdecl;
+}
Property changes on: trunk/gert/standalone/bug351520/test.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/gert/standalone/known-issues
===================================================================
--- trunk/gert/standalone/known-issues 2008-01-03 20:33:32 UTC (rev 92204)
+++ trunk/gert/standalone/known-issues 2008-01-03 21:31:04 UTC (rev 92205)
@@ -138,3 +138,4 @@
bug345449/**
bug346762/**
bug347193/**
+bug351520/**
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches