Ejemplo n.º 1
0
        /// <summary>
        /// Read expression from string.
        /// </summary>
        /// <param name="exprStr"></param>
        /// <returns></returns>
        public static Expr ReadExpr(string exprStr)
        {
            var tmp_pool    = new NativeGU.NativeMemoryPool();
            var exn         = new NativeGU.NativeExceptionContext(tmp_pool);
            var result_pool = new NativeGU.NativeMemoryPool();

            using (var strNative = new Native.NativeString(exprStr))
            {
                var in_  = NativeGU.gu_data_in(strNative.Ptr, strNative.Size, tmp_pool.Ptr);
                var expr = Native.pgf_read_expr(in_, result_pool.Ptr, tmp_pool.Ptr, exn.Ptr);
                if (exn.IsRaised || expr == IntPtr.Zero)
                {
                    throw new PGFError();
                }
                else
                {
                    return(Expr.FromPtr(expr, result_pool));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read type from string.
        /// </summary>
        /// <param name="typeStr"></param>
        /// <returns></returns>
        public static Type ReadType(string typeStr)
        {
            var tmp_pool    = new NativeGU.NativeMemoryPool();
            var exn         = new NativeGU.NativeExceptionContext(tmp_pool);
            var result_pool = new NativeGU.NativeMemoryPool();

            using (var strNative = new Native.NativeString(typeStr))
            {
                var in_ = NativeGU.gu_data_in(strNative.Ptr, strNative.Size, tmp_pool.Ptr);
                var typ = Native.pgf_read_type(in_, result_pool.Ptr, tmp_pool.Ptr, exn.Ptr);
                if (exn.IsRaised || typ == IntPtr.Zero)
                {
                    throw new PGFError();
                }
                else
                {
                    return(Type.FromPtr(typ, result_pool));
                }
            }
        }