/// <summary> /// Get the bracketed (structured) linearization of an expression. /// </summary> /// <param name="e"></param> /// <returns></returns> public Bracket BracketedLinearize(Expr e) { var tmp_pool = new NativeGU.NativeMemoryPool(); var exn = new NativeGU.NativeExceptionContext(tmp_pool); var cts = Native.pgf_lzr_concretize(Ptr, e.Ptr, exn.Ptr, tmp_pool.Ptr); var ctree = IntPtr.Zero; NativeGU.gu_enum_next(cts, ref ctree, tmp_pool.Ptr); if (ctree == IntPtr.Zero) { return(null); } ctree = Native.pgf_lzr_wrap_linref(ctree, tmp_pool.Ptr); var builder = new Bracket.BracketBuilder(); var mem = Marshal.AllocHGlobal(Marshal.SizeOf <Native.PgfLinFuncs>()); Marshal.StructureToPtr <Native.PgfLinFuncs>(builder.LinFuncs, mem, false); Native.pgf_lzr_linearize(Ptr, ctree, 0, ref mem, tmp_pool.Ptr); var b = builder.Build(); Marshal.FreeHGlobal(mem); return(b); }
public static IEnumerable <IntPtr> IteratorToIEnumerable(IntPtr iterator, IntPtr pool) { IntPtr ptr = IntPtr.Zero; NativeGU.gu_enum_next(iterator, ref ptr, pool); while (ptr != IntPtr.Zero) { yield return(ptr); NativeGU.gu_enum_next(iterator, ref ptr, pool); } }