You've already forked linux-packaging-mono
Imported Upstream version 6.8.0.73
Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
parent
bceda29824
commit
73ee7591e8
@@ -1,8 +1,12 @@
|
||||
#ifndef _TESTCASE_
|
||||
#include <mono/jit/jit.h>
|
||||
#endif
|
||||
|
||||
#include <mono/metadata/object.h>
|
||||
#include <mono/metadata/environment.h>
|
||||
#include <mono/metadata/assembly.h>
|
||||
#include <mono/metadata/debug-helpers.h>
|
||||
#include <mono/metadata/mono-config.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -15,9 +19,9 @@
|
||||
* We show how to create objects and invoke methods and set fields in them.
|
||||
* Compile with:
|
||||
* gcc -Wall -o test-invoke test-invoke.c `pkg-config --cflags --libs mono-2` -lm
|
||||
* mcs invoke.cs
|
||||
* mcs -out:test-embed-invoke-cs.exe invoke.cs
|
||||
* Run with:
|
||||
* ./test-invoke invoke.exe
|
||||
* ./test-invoke
|
||||
*/
|
||||
|
||||
static void
|
||||
@@ -316,18 +320,40 @@ static void main_function (MonoDomain *domain, const char *file, int argc, char
|
||||
create_object (domain, mono_assembly_get_image (assembly));
|
||||
}
|
||||
|
||||
#ifdef _TESTCASE_
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int
|
||||
test_mono_embed_invoke_main (void);
|
||||
|
||||
int
|
||||
main (int argc, char* argv[]) {
|
||||
test_mono_embed_invoke_main (void)
|
||||
{
|
||||
#else
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
#endif
|
||||
|
||||
MonoDomain *domain;
|
||||
int argc = 2;
|
||||
char *argv[] = {
|
||||
(char*)"test-embed-invoke.exe",
|
||||
(char*)"test-embed-invoke-cs.exe",
|
||||
NULL
|
||||
};
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,11 @@ class MonoEmbed {
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
extern static string gimme();
|
||||
|
||||
static void Main() {
|
||||
Console.WriteLine (gimme ());
|
||||
static int Main ()
|
||||
{
|
||||
System.Console.WriteLine(gimme ());
|
||||
if (gimme ().Equals("All your monos are belong to us!"))
|
||||
return 0;
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
#ifndef _TESTCASE_
|
||||
#include <mono/jit/jit.h>
|
||||
#endif
|
||||
|
||||
#include <mono/metadata/environment.h>
|
||||
#include <mono/utils/mono-publib.h>
|
||||
#include <mono/metadata/mono-config.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Very simple mono embedding example.
|
||||
* Compile with:
|
||||
* gcc -o teste teste.c `pkg-config --cflags --libs mono-2` -lm
|
||||
* mcs test.cs
|
||||
* mcs -out:test-embed.exe test.cs
|
||||
* Run with:
|
||||
* ./teste test.exe
|
||||
* ./teste
|
||||
*/
|
||||
|
||||
static MonoString*
|
||||
@@ -40,19 +44,33 @@ static void* custom_malloc(size_t bytes)
|
||||
return malloc(bytes);
|
||||
}
|
||||
|
||||
#ifdef _TESTCASE_
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int
|
||||
test_mono_embed_main (void);
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
test_mono_embed_main (void) {
|
||||
#else
|
||||
int
|
||||
main (void) {
|
||||
#endif
|
||||
|
||||
MonoDomain *domain;
|
||||
int argc = 2;
|
||||
char *argv[] = {
|
||||
(char*)"test-mono-embed.exe",
|
||||
(char*)"test-embed.exe",
|
||||
NULL
|
||||
};
|
||||
const char *file;
|
||||
int retval;
|
||||
|
||||
if (argc < 2){
|
||||
fprintf (stderr, "Please provide an assembly to load\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = argv [1];
|
||||
|
||||
MonoAllocatorVTable mem_vtable = {custom_malloc};
|
||||
MonoAllocatorVTable mem_vtable = {MONO_ALLOCATOR_VTABLE_VERSION, custom_malloc};
|
||||
mono_set_allocator_vtable (&mem_vtable);
|
||||
|
||||
/*
|
||||
@@ -70,7 +88,7 @@ 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 ("MonoEmbed::gimme", (const void *)gimme);
|
||||
|
||||
main_function (domain, file, argc - 1, argv + 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user