EndProject
Project("{2857B73E-F847-4B02-9238-064979017E93}") = "libcrow", "..\libcrow\libcrow.cproj", "{6CD55032-B8D6-4238-AA91-F9145E1217D4}"
EndProject
+Project("{2857B73E-F847-4B02-9238-064979017E93}") = "MDEmbedTest", "MDEmbedTest\MDEmbedTest.cproj", "{A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}.Release|Any CPU.Build.0 = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.Build.0 = Release|Any CPU
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{A41EEF9F-6F0C-402E-9AD0-C23B7A32B05D}</ProjectGuid>
+ <Compiler>
+ <Compiler ctype="GccCompiler" />
+ </Compiler>
+ <Language>C</Language>
+ <Target>Bin</Target>
+ <ReleaseVersion>0.5</ReleaseVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\Debug</OutputPath>
+ <Externalconsole>true</Externalconsole>
+ <OutputName>MDEmbedTest</OutputName>
+ <CompileTarget>Bin</CompileTarget>
+ <DefineSymbols>DEBUG MONODEVELOP</DefineSymbols>
+ <SourceDirectory>.</SourceDirectory>
+ <CustomCommands>
+ <CustomCommands>
+ <Command type="Build" command="make" />
+ <Command type="Execute" command="make run" externalConsole="True" pauseExternalConsole="True" />
+ </CustomCommands>
+ </CustomCommands>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <OutputPath>bin\Release</OutputPath>
+ <Externalconsole>true</Externalconsole>
+ <OutputName>MDEmbedTest</OutputName>
+ <CompileTarget>Bin</CompileTarget>
+ <OptimizationLevel>3</OptimizationLevel>
+ <DefineSymbols>MONODEVELOP</DefineSymbols>
+ <SourceDirectory>.</SourceDirectory>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="main.c" />
+ <Compile Include="test.cs" />
+ </ItemGroup>
+ <ProjectExtensions>
+ <MonoDevelop>
+ <Properties>
+ <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="Makefile">
+ <BuildFilesVar />
+ <DeployFilesVar />
+ <ResourcesVar />
+ <OthersVar />
+ <GacRefVar />
+ <AsmRefVar />
+ <ProjectRefVar />
+ </MonoDevelop.Autotools.MakefileInfo>
+ </Properties>
+ </MonoDevelop>
+ </ProjectExtensions>
+ <ItemGroup>
+ <None Include="Makefile" />
+ <None Include="test2.cs" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+export PKG_CONFIG_PATH = /opt/mono/lib/pkgconfig
+
+CC = gcc
+CFLAGS = -Wall -Wextra -O2 -g -DDEBUG
+LDFLAGS =
+
+TARGET = mdembed
+SOURCES = main.c
+OBJECTS = $(SOURCES:.c=.o)
+
+CFLAGS += `pkg-config --cflags --libs mono-2`
+CFLAGS += `pkg-config --cflags --libs cairo`
+CFLAGS += `pkg-config --cflags --libs gl`
+
+.PHONY: all
+all: ${TARGET} test.exe test2.exe
+
+$(TARGET): $(OBJECTS)
+ $(CC) $(CFLAGS) ${LDFLAGS} -o $(TARGET) $(OBJECTS)
+test.exe : test.cs
+ mcs -unsafe test.cs
+test2.exe : test2.cs
+ mcs -unsafe test2.cs
+
+.PHONY: clean
+clean:
+ -rm -f ${TARGET} ${OBJECTS} test.exe test2.exe
+
+.PHONY: run
+run:
+ -./${TARGET} test.exe
\ No newline at end of file
--- /dev/null
+#include <mono/jit/jit.h>
+#include <mono/metadata/environment.h>
+#include <stdlib.h>
+#include <GL/gl.h>
+#include <GL/glext.h>
+
+/*
+ * Very simple mono embedding example.
+ * Compile with:
+ * gcc -o teste teste.c `pkg-config --cflags --libs mono-2` -lm
+ * mcs test.cs
+ * Run with:
+ * ./teste test.exe
+ */
+
+static MonoString*
+gimme () {
+ return mono_string_new (mono_domain_get (), "All your monos are belong to us!");
+}
+
+static void main_function (MonoDomain *domain, const char *file, int argc, char** argv)
+{
+ MonoAssembly *assembly;
+ MonoAssembly *a2;
+
+ assembly = mono_domain_assembly_open (domain, file);
+ if (!assembly)
+ exit (2);
+ a2 = mono_domain_assembly_open (domain, "test2.exe");
+ if (!a2)
+ exit (2);
+ /*
+ * mono_jit_exec() will run the Main() method in the assembly.
+ * The return value needs to be looked up from
+ * System.Environment.ExitCode.
+ */
+ mono_jit_exec (domain, assembly, argc, argv);
+ mono_jit_exec (domain, a2, argc, argv);
+}
+
+int
+main(int argc, char* argv[]) {
+ MonoDomain *domain;
+ const char *file;
+ int retval;
+
+ if (argc < 2){
+ fprintf (stderr, "Please provide an assembly to load\n");
+ return 1;
+ }
+ file = argv [1];
+
+ /*
+ * Load the default Mono configuration file, this is needed
+ * if you are planning on using the dllmaps defined on the
+ * system configuration
+ */
+ mono_config_parse (NULL);
+ /*
+ * mono_jit_init() creates a domain: each assembly is
+ * loaded and run in a MonoDomain.
+ */
+ domain = mono_jit_init (file);
+ /*
+ * We add our special internal call, so that C# code
+ * can call us back.
+ */
+ mono_add_internal_call ("MonoEmbed::gimme", gimme);
+
+ main_function (domain, file, argc - 1, argv + 1);
+
+ retval = mono_environment_exitcode_get ();
+
+ mono_jit_cleanup (domain);
+ return retval;
+}
+
+
--- /dev/null
+using System;
+using System.Runtime.CompilerServices;
+
+class MonoEmbed {
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ unsafe extern static string gimme();
+
+ static void Main() {
+ Console.WriteLine (gimme ());
+ }
+}
--- /dev/null
+using System;
+using System.Runtime.CompilerServices;
+
+class MonoEmbed {
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ unsafe extern static string gimme();
+
+ static void Main() {
+ Console.WriteLine ("test2 => " + gimme ());
+ }
+}
public class TestCrow
{
//const string lib = "/mnt/data2/devel/crow/libcrow/bin/Debug/libcrow.so";
- const string lib = "/home/jp/devel/testsharedlib/bin/Debug/libcrow.so";
+ const string lib = "libcrow.so";
[StructLayout(LayoutKind.Sequential)]
public struct testStruct {
public int a = 10,b=20;
}
- [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void testAppDomain();
-
- [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int gimmePI (ref testStruct t);
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern int gimme (ref testStruct t);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern object UnsafeGetValue (object obj);
+ unsafe extern static string gimme();
+ [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern void registerICall ();
static void Main(){
- using (Interface iface = new Interface ()) {
+ registerICall ();
+ Console.WriteLine (gimme());
+
+ /*using (Interface iface = new Interface ()) {
Console.WriteLine ("is dirty: {0}", iface.IsDirty);
iface.ProcessResize (new Rectangle (0, 0, 1024, 768));
iface.LoadInterface ("#testDrm.ui.go.crow");
iface.Update ();
iface.DumpTo ("/home/jp/test.png");
- }
+ }*/
}
}
}