Ejemplo n.º 1
0
        internal MetaVariableExpr()
        {
            _pool = new NativeGU.NativeMemoryPool();
            IntPtr exprMetaPtr = NativeGU.gu_alloc_variant((byte)PgfExprTag.PGF_EXPR_META,
                                                           (UIntPtr)Marshal.SizeOf <NativePgfExprMeta>(), UIntPtr.Zero, ref _ptr, _pool.Ptr);

            Native.EditStruct <NativePgfExprMeta> (exprMetaPtr, (ref NativePgfExprMeta m) => m.Id = 0);
        }
Ejemplo n.º 2
0
        internal IntPtr MkStringVariant(byte tag, string s, ref IntPtr out_)
        {
            var    size    = Encoding.UTF8.GetByteCount(s);
            IntPtr slitPtr = NativeGU.gu_alloc_variant(tag,
                                                       (UIntPtr)(size + 1), UIntPtr.Zero, ref out_, _pool.Ptr);

            Native.NativeString.CopyToPreallocated(s, slitPtr);
            return(slitPtr);
        }
Ejemplo n.º 3
0
        public LiteralStringExpr(string s) : base()
        {
            _pool = new NativeGU.NativeMemoryPool();

            var    exprTag = (byte)(int)PgfExprTag.PGF_EXPR_LIT;
            IntPtr litPtr  = NativeGU.gu_alloc_variant(exprTag,
                                                       (UIntPtr)Marshal.SizeOf <NativePgfExprLit>(), UIntPtr.Zero, ref _ptr, _pool.Ptr);

            Native.EditStruct <NativePgfExprLit>(litPtr, (ref NativePgfExprLit lit) => {
                MkStringVariant((byte)PgfLiteralTag.PGF_LITERAL_STR, s, ref lit.lit);
            });
        }
Ejemplo n.º 4
0
        internal void Initialize <TNative>(PgfLiteralTag litTag, Native.StructAction <TNative> setValue, UIntPtr?size = null)
        {
            _pool = new NativeGU.NativeMemoryPool();

            var    exprTag = (byte)(int)PgfExprTag.PGF_EXPR_LIT;
            IntPtr litPtr  = NativeGU.gu_alloc_variant(exprTag,
                                                       (UIntPtr)Marshal.SizeOf <NativePgfExprLit>(), UIntPtr.Zero, ref _ptr, _pool.Ptr);

            Native.EditStruct <NativePgfExprLit> (litPtr, (ref NativePgfExprLit lit) => {
                IntPtr ilitPtr = NativeGU.gu_alloc_variant((byte)litTag,
                                                           (UIntPtr)Marshal.SizeOf <TNative> (), UIntPtr.Zero, ref lit.lit, _pool.Ptr);

                Native.EditStruct <TNative>(ilitPtr, setValue);
            });
        }
Ejemplo n.º 5
0
        public ApplicationExpr(string fname, IEnumerable <Expr> args)
        {
            _pool = new NativeGU.NativeMemoryPool();
            MkStringVariant((byte)PgfExprTag.PGF_EXPR_FUN, fname, ref _ptr);
            foreach (var arg in args)
            {
                var fun     = _ptr;
                var exprApp = NativeGU.gu_alloc_variant((byte)PgfExprTag.PGF_EXPR_APP,
                                                        (UIntPtr)Marshal.SizeOf <PgfExprApp>(), UIntPtr.Zero, ref _ptr, _pool.Ptr);

                Native.EditStruct <PgfExprApp> (exprApp, (ref PgfExprApp app) => {
                    app.Function = fun;
                    app.Argument = arg.Ptr;
                });
            }
        }