Exemple #1
0
        /// <summary>
        /// Prepares <see cref="SciterClassDef"/> for marshalling
        /// </summary>
        public SciterNativeClassDef ToNative()
        {
            var sciterNative = new SciterNativeClassDef();

            sciterNative.name = Marshal.StringToCoTaskMemAnsi(name);
            sciterNative.dtor = Marshal.GetFunctionPointerForDelegate(dtor);

            sciterNative.methods = Marshal.AllocCoTaskMem(SciterNativeMethodDef.SizeOf * methods.Length + 1);
            for (var i = 0; i < methods.Length; ++i)
            {
                Marshal.StructureToPtr(methods[i], new IntPtr(sciterNative.methods.ToInt64() + i * SciterNativeMethodDef.SizeOf), false);
            }

            // Write NULL methodDef
            Marshal.StructureToPtr(new SciterNativeMethodDef(), new IntPtr(sciterNative.methods.ToInt64() + methods.Length * SciterNativeMethodDef.SizeOf), false);

            sciterNative.properties = Marshal.AllocCoTaskMem(SciterNativePropertyDef.SizeOf * properties.Length + 1);
            for (var i = 0; i < properties.Length; ++i)
            {
                Marshal.StructureToPtr(properties[i], new IntPtr(sciterNative.properties.ToInt64() + i * SciterNativePropertyDef.SizeOf), false);
            }

            // Write NULL propertyDef
            Marshal.StructureToPtr(new SciterNativePropertyDef(), new IntPtr(sciterNative.properties.ToInt64() + properties.Length * SciterNativePropertyDef.SizeOf), false);

            return(sciterNative);
        }
Exemple #2
0
        /// <summary>
        /// Releases resources from <see cref="SciterNativeClassDef"/>
        /// </summary>
        public static void FreeNative(SciterNativeClassDef nativeClass)
        {
            Marshal.FreeCoTaskMem(nativeClass.name);

            var loc = nativeClass.methods;

            while (Marshal.ReadIntPtr(loc) != IntPtr.Zero)
            {
                Marshal.StructureToPtr(new SciterNativeMethodDef(), loc, true);
                loc = new IntPtr(loc.ToInt64() + SciterNativeMethodDef.SizeOf);
            }

            loc = nativeClass.properties;
            while (Marshal.ReadIntPtr(loc) != IntPtr.Zero)
            {
                Marshal.StructureToPtr(new SciterNativePropertyDef(), loc, true);
                loc = new IntPtr(loc.ToInt64() + SciterNativePropertyDef.SizeOf);
            }

            Marshal.FreeCoTaskMem(nativeClass.methods);
            Marshal.FreeCoTaskMem(nativeClass.properties);
        }
Exemple #3
0
 /// <summary>
 /// SciterNativeDefineClass - register "native" class to for the script.
 /// </summary>
 public static bool SciterNativeDefineClass(IntPtr hvm, SciterNativeClassDef pClassDef)
 {
     return(false);
 }
Exemple #4
0
 public static extern bool SciterNativeDefineClass(IntPtr hvm, SciterNativeClassDef pClassDef);