]> O.S.I.I.S - jp/crow.git/commitdiff
use internal calls for libcrow
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 6 Jun 2017 10:47:32 +0000 (12:47 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 6 Jun 2017 10:47:32 +0000 (12:47 +0200)
12 files changed:
.gitignore
MDEmbedTest/MDEmbedTest.cproj
MDEmbedTest/Makefile
MDEmbedTest/libcrow.so [new file with mode: 0755]
MDEmbedTest/main.c
MDEmbedTest/main.o [deleted file]
MDEmbedTest/mdembed [deleted file]
MDEmbedTest/test.exe [deleted file]
MDEmbedTest/test2.cs
MDEmbedTest/test2.exe [deleted file]
src/Crow.Native/LibCrow.cs
testDrm/TestCrow.cs

index 477bac00d42662293e5d08f2eee80dc176b4657d..6e57eec4327a775ac2e22fc4cce1f02af508ad9c 100644 (file)
@@ -3,6 +3,7 @@ Win_x86
 Crow.userprefs
 Debug
 packages
+*.o
 *.nupkg
 /GOLib.suo
 /tmp
index 3c209afc22de623c7988cfff478eeaa2eb9b35fe..43502bcd03d1b2c239f6652e525f7141e3e68fa1 100644 (file)
@@ -24,7 +24,7 @@
     <CustomCommands>
       <CustomCommands>
         <Command type="Build" command="make" />
-        <Command type="Execute" command="make run" externalConsole="True" pauseExternalConsole="True" />
+        <Command type="Execute" command="make run" workingdir="" externalConsole="True" pauseExternalConsole="True" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
index 631fa2725fa2fa29357dbb31aa4ad3317274f57b..53da377d283fc491c1f95962c0710f09de25b32f 100644 (file)
@@ -2,12 +2,13 @@ export PKG_CONFIG_PATH = /opt/mono/lib/pkgconfig
 
 CC = gcc
 CFLAGS = -Wall -Wextra -O2 -g -DDEBUG
-LDFLAGS = 
+LDFLAGS = -L/devel/crow/build/Debug 
 
 TARGET  = mdembed
 SOURCES = main.c
 OBJECTS = $(SOURCES:.c=.o)
 
+CFLAGS += -lcrow
 CFLAGS += `pkg-config --cflags --libs mono-2` 
 CFLAGS += `pkg-config --cflags --libs cairo` 
 CFLAGS += `pkg-config --cflags --libs gl`
@@ -28,4 +29,4 @@ clean:
 
 .PHONY: run
 run:
-       -./${TARGET} test.exe
\ No newline at end of file
+       -./${TARGET} ../build/Debug/testDrm.exe
diff --git a/MDEmbedTest/libcrow.so b/MDEmbedTest/libcrow.so
new file mode 100755 (executable)
index 0000000..ff874cc
Binary files /dev/null and b/MDEmbedTest/libcrow.so differ
index 45a01cd38e30445971147114573208ee840de3ed..a6f06783ea04511203b234b42fc3d5c7a09d72f0 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <GL/gl.h>
 #include <GL/glext.h>
+#include "../../libcrow/libcrow.h"
 
 /*
  * Very simple mono embedding example.
@@ -26,16 +27,16 @@ static void main_function (MonoDomain *domain, const char *file, int argc, char*
        assembly = mono_domain_assembly_open (domain, file);
        if (!assembly)
                exit (2);
-       a2 = mono_domain_assembly_open (domain, "test2.exe");
-       if (!a2)
-               exit (2);
+       //a2 = mono_domain_assembly_open (domain, "../build/Debug/testDrm.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);
+       //mono_jit_exec (domain, a2, argc, argv);
 }
 
 int 
@@ -65,7 +66,22 @@ main(int argc, char* argv[]) {
         * We add our special internal call, so that C# code
         * can call us back.
         */
-       mono_add_internal_call ("MonoEmbed::gimme", gimme);
+       mono_add_internal_call ("Crow.Native.LibCrow::gimme", gimme);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_create", crow_context_create);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_destroy", crow_context_destroy);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_set_root", crow_context_set_root);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_clipping", crow_context_process_clipping);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_layouting", crow_context_process_layouting);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_context_process_drawing", crow_context_process_drawing);
+
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_create", crow_object_create);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_destroy", crow_object_destroy);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_set_type", crow_object_set_type);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_do_layout", crow_object_do_layout);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_register_layouting", crow_object_register_layouting);
+
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_child_add", crow_object_child_add);
+       mono_add_internal_call ("Crow.Native.LibCrow::crow_object_child_remove", crow_object_child_remove);
 
        main_function (domain, file, argc - 1, argv + 1);
        
diff --git a/MDEmbedTest/main.o b/MDEmbedTest/main.o
deleted file mode 100644 (file)
index eb52af1..0000000
Binary files a/MDEmbedTest/main.o and /dev/null differ
diff --git a/MDEmbedTest/mdembed b/MDEmbedTest/mdembed
deleted file mode 100755 (executable)
index db17b65..0000000
Binary files a/MDEmbedTest/mdembed and /dev/null differ
diff --git a/MDEmbedTest/test.exe b/MDEmbedTest/test.exe
deleted file mode 100755 (executable)
index b49eb85..0000000
Binary files a/MDEmbedTest/test.exe and /dev/null differ
index eb23a83745a46827f13ed311257c66de306b3386..ea85efd3f78453434bfdeac3ef86194afd5cea96 100644 (file)
@@ -7,5 +7,6 @@ class MonoEmbed {
 
        static void Main() {            
                Console.WriteLine ("test2 => " + gimme ());
+
        }
 }      
diff --git a/MDEmbedTest/test2.exe b/MDEmbedTest/test2.exe
deleted file mode 100755 (executable)
index c98fc48..0000000
Binary files a/MDEmbedTest/test2.exe and /dev/null differ
index 5496f19f67a9fb715dae94fb93246ce9e1d88b8e..bd0a147327cb5f1e44aeb3e2225e0107670fecb4 100644 (file)
 // THE SOFTWARE.
 using System;
 using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
 
 namespace Crow.Native
 {
-       internal static class LibCrow
+       public static class LibCrow
        {
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               public unsafe extern static string gimme();
                #region PINVOKE
                const string lib = "libcrow";
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern IntPtr crow_context_create ();
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern void crow_context_destroy (IntPtr ctx);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern void crow_context_set_root (IntPtr ctx, crow_object_t* root);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern void crow_context_process_layouting (IntPtr ctx);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern void crow_context_process_clipping (IntPtr ctx);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern void crow_context_process_drawing (IntPtr ctx, IntPtr cairoCtx);
 
-               [DllImport(lib)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern crow_object_t* crow_object_create();
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern void crow_object_destroy(crow_object_t* go);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern void crow_object_set_type (crow_object_t* go, CrowType objType);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern byte crow_object_do_layout (crow_object_t* go, LayoutingType layout);
-               [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
                unsafe internal static extern byte crow_object_register_layouting (crow_object_t* go, LayoutingType layout);
 
 
index 552b71981616b0f1402d819669dec1e463a660c8..5e98ab56c2f471d18984018e636d838477efb338 100644 (file)
@@ -48,22 +48,21 @@ namespace testDrm
                        public int a = 10,b=20;
                }
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               unsafe extern static string gimme();
+
                [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
                internal static extern void registerICall ();
 
                static void Main(){
-                       registerICall ();
-                       Console.WriteLine (gimme());
+                       //registerICall ();
+                       Console.WriteLine (Crow.Native.LibCrow. gimme());
 
-                       /*using (Interface iface = new Interface ()) {
+                       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");
-                       }*/
+                       }
                }
        }
 }