Beispiel #1
0
        private static unsafe void Invoke196(object x)
        {
            // script: error JSC1000: type not supported: CLRLibraryDllExportDefinition.uvec3 ; consider adding [ScriptAttribute]

            // dynamic callsite

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before Export196...");
            var y = (__Export196)windows_h.GetProcAddress(x, "Export196");
            //var yargs = new CLRLibraryDllExportDefinition.uvec3 { x = 11, y = 22, z = 33 };
            var yargs = new CLRLibraryDllExportDefinition.uvec3();

            yargs.z = 66;

            //uvec31 = NULL;
            //&uvec31->z = ((signed long)(66));


            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("yargs.z = ");
            ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yargs.z));

            var yargsref = &yargs;

            // long long TestSwitchToCLR_Program_Export196(CLRLibraryDllExportDefinition_uvec3*);
            var yret = Program.Export196(yargsref);

            //var yret = y(yargsref);

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("after Export196...");
            ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yret));
        }
Beispiel #2
0
        public unsafe static void Invoke()
        {
            var yargs = new CLRLibraryDllExportDefinition.uvec3();

            yargs.z = 66;

            var z = yargs.z;

            var yargsptr = &yargs;

            //  num3 = ((long long)uvec3_2.z);
            var pz = yargsptr->z;

            yargsptr->z = pz;
        }
Beispiel #3
0
        public unsafe static void Invoke()
        {
            var yargs = new CLRLibraryDllExportDefinition.uvec3();

            yargs.z = 66;

            var z = yargs.z;

            var yargsptr = &yargs;

            //  num3 = ((long long)uvec3_2.z);
            var pz = yargsptr->z;

            yargsptr->z = pz;
        }
        // __declspec(dllimport) long long Export196(CLRLibraryDllExportDefinition_uvec3*);
        // __declspec(dllexport) long long __stdcall Export196(CLRLibraryDllExportDefinition_uvec3*);

        //---------------------------
        //TestSwitchToCLR.exe - System Error
        //---------------------------
        //The program can't start because TestConsoleWriteLine.dll is missing from your computer. Try reinstalling the program to fix this problem. 
        //---------------------------
        //OK   
        //---------------------------


        unsafe static void Main(string[] args)
        {
            // Binary was not built with debug information.

            // http://choorucode.com/2012/09/13/visual-studio-2010-conversion-to-coff-failure/

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("hello. will switch to CLR...");

            // http://www.willus.com/mingw/colinp/win32/tools/dlltool.html
            // http://stackoverflow.com/questions/17935113/declspecdllimport-how-to-load-library

            // http://www.codeproject.com/Articles/146652/Creating-Import-Library-from-a-DLL-with-Header-Fil
            // http://hi.baidu.com/hainei_/item/dfcffb5cf442743932e0a912
            // http://andyrushton.co.uk/csharp-dynamic-loading-of-a-c-dll-at-run-time/

            // DllImport could define shadow library we could hard link to?
            var x = windows_h.LoadLibrary("CLRLibrary.dll");

            if (x == null)
            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("err 1");

                return;
            }

            {
                var y = windows_h.GetProcAddress(x, "Export2");
                if (y == null)
                {
                    ScriptCoreLibNative.SystemHeaders.stdio_h.puts("err 2");

                    return;
                }

                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before invoke...");

                var f = (__Action)y;

                f();
            }

            //         Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CLRLibraryCSharp, Version=1.0.0.0,
            //at CLRLibrary.Class1.Export2()

            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before Export4...");

                var y = (__LongToLong)windows_h.GetProcAddress(x, "Export4");
                var yv = y(5);

                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("after Export4...");

                // http://www.cplusplus.com/reference/cstdio/printf/
                // http://stackoverflow.com/questions/38561/what-is-the-argument-for-printf-that-formats-a-long
                ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yv));
            }

            Invoke196(x);

            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before ");
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts(nameof(ExportPointer));
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("...");
                var y = (ExportPointer)windows_h.GetProcAddress(x, nameof(ExportPointer));
                var yargsxyz = new CLRLibraryDllExportDefinition.uvec3();
                yargsxyz.y = 11;

                var yargs = new CLRLibraryDllExportDefinition.uvec3ptr();
                yargs.position = &yargsxyz;

                var yv = y(&yargs);
            }

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("done!");
        }
        private static unsafe void Invoke196(object x)
        {
            // script: error JSC1000: type not supported: CLRLibraryDllExportDefinition.uvec3 ; consider adding [ScriptAttribute]

            // dynamic callsite

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before Export196...");
            var y = (__Export196)windows_h.GetProcAddress(x, "Export196");
            //var yargs = new CLRLibraryDllExportDefinition.uvec3 { x = 11, y = 22, z = 33 };
            var yargs = new CLRLibraryDllExportDefinition.uvec3();

            yargs.z = 66;

            //uvec31 = NULL;
            //&uvec31->z = ((signed long)(66));


            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("yargs.z = ");
            ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yargs.z));

            var yargsref = &yargs;

            // long long TestSwitchToCLR_Program_Export196(CLRLibraryDllExportDefinition_uvec3*);
            var yret = Program.Export196(yargsref);
            //var yret = y(yargsref);

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("after Export196...");
            ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yret));

        }
Beispiel #6
0
        // __declspec(dllimport) long long Export196(CLRLibraryDllExportDefinition_uvec3*);
        // __declspec(dllexport) long long __stdcall Export196(CLRLibraryDllExportDefinition_uvec3*);

        //---------------------------
        //TestSwitchToCLR.exe - System Error
        //---------------------------
        //The program can't start because TestConsoleWriteLine.dll is missing from your computer. Try reinstalling the program to fix this problem.
        //---------------------------
        //OK
        //---------------------------


        unsafe static void Main(string[] args)
        {
            // Binary was not built with debug information.

            // http://choorucode.com/2012/09/13/visual-studio-2010-conversion-to-coff-failure/

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("hello. will switch to CLR...");

            // http://www.willus.com/mingw/colinp/win32/tools/dlltool.html
            // http://stackoverflow.com/questions/17935113/declspecdllimport-how-to-load-library

            // http://www.codeproject.com/Articles/146652/Creating-Import-Library-from-a-DLL-with-Header-Fil
            // http://hi.baidu.com/hainei_/item/dfcffb5cf442743932e0a912
            // http://andyrushton.co.uk/csharp-dynamic-loading-of-a-c-dll-at-run-time/

            // DllImport could define shadow library we could hard link to?
            var x = windows_h.LoadLibrary("CLRLibrary.dll");

            if (x == null)
            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("err 1");

                return;
            }

            {
                var y = windows_h.GetProcAddress(x, "Export2");
                if (y == null)
                {
                    ScriptCoreLibNative.SystemHeaders.stdio_h.puts("err 2");

                    return;
                }

                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before invoke...");

                var f = (__Action)y;

                f();
            }

            //         Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CLRLibraryCSharp, Version=1.0.0.0,
            //at CLRLibrary.Class1.Export2()

            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before Export4...");

                var y  = (__LongToLong)windows_h.GetProcAddress(x, "Export4");
                var yv = y(5);

                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("after Export4...");

                // http://www.cplusplus.com/reference/cstdio/printf/
                // http://stackoverflow.com/questions/38561/what-is-the-argument-for-printf-that-formats-a-long
                ScriptCoreLibNative.SystemHeaders.stdio_h.printf("%lld", __arglist(yv));
            }

            Invoke196(x);

            {
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("before ");
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts(nameof(ExportPointer));
                ScriptCoreLibNative.SystemHeaders.stdio_h.puts("...");
                var y        = (ExportPointer)windows_h.GetProcAddress(x, nameof(ExportPointer));
                var yargsxyz = new CLRLibraryDllExportDefinition.uvec3();
                yargsxyz.y = 11;

                var yargs = new CLRLibraryDllExportDefinition.uvec3ptr();
                yargs.position = &yargsxyz;

                var yv = y(&yargs);
            }

            ScriptCoreLibNative.SystemHeaders.stdio_h.puts("done!");
        }