From 4f2ae4b8ed2db7f9a7bbd6152aacbf8989b3de9e Mon Sep 17 00:00:00 2001
From: Claude Heiland-Allen <claude@mathr.co.uk>
Date: Mon, 24 Sep 2018 22:36:39 +0100
Subject: [PATCH 31/39] bundled: pd-0.45-5

---
 bundled/g_canvas.h | 20 ++++++++------
 bundled/m_pd.h     | 69 ++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/bundled/g_canvas.h b/bundled/g_canvas.h
index fff4ef90..38714446 100644
--- a/bundled/g_canvas.h
+++ b/bundled/g_canvas.h
@@ -119,6 +119,7 @@ typedef struct _editor
 #define MA_REGION  3    /* selection region */
 #define MA_PASSOUT 4    /* send on to e_grab */
 #define MA_DRAGTEXT 5   /* drag in text editor to alter selection */
+#define MA_RESIZE  6    /* drag to resize */
 
 /* editor structure for "garrays".  We don't bother to delete and regenerate
 this structure when the "garray" becomes invisible or visible, although we
@@ -186,6 +187,7 @@ struct _glist
     unsigned int gl_goprect:1;      /* draw rectangle for graph-on-parent */
     unsigned int gl_isgraph:1;      /* show as graph on parent */
     unsigned int gl_hidetext:1;     /* hide object-name + args when doing graph on parent */
+    unsigned int gl_private:1;      /* private flag used in x_scalar.c */
 };
 
 #define gl_gobj gl_obj.te_g
@@ -195,7 +197,7 @@ struct _glist
 
 #define DT_FLOAT 0
 #define DT_SYMBOL 1
-#define DT_LIST 2
+#define DT_TEXT 2
 #define DT_ARRAY 3
 
 typedef struct _dataslot
@@ -331,9 +333,9 @@ struct _parentwidgetbehavior
 #define CURSOR_EDITMODE_NOTHING 4
 #define CURSOR_EDITMODE_CONNECT 5
 #define CURSOR_EDITMODE_DISCONNECT 6
+#define CURSOR_EDITMODE_RESIZE 7
 EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
 
-extern t_canvas *canvas_editing;    /* last canvas to start text edting */ 
 extern t_canvas *canvas_whichfind;  /* last canvas we did a find in */ 
 extern t_canvas *canvas_list;       /* list of all root canvases */
 extern t_class *vinlet_class, *voutlet_class;
@@ -509,6 +511,8 @@ EXTERN int canvas_isconnected (t_canvas *x,
     t_text *ob1, int n1, t_text *ob2, int n2);
 EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
 
+EXTERN t_glist *pd_checkglist(t_pd *x);
+
 
 /* ---- functions on canvasses as objects  --------------------- */
 
@@ -533,6 +537,8 @@ EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
 EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
 EXTERN void array_resize(t_array *x, int n);
 EXTERN void array_free(t_array *x);
+EXTERN void array_redraw(t_array *a, t_glist *glist);
+EXTERN void array_resize_and_redraw(t_array *array, t_glist *glist, int n);
 
 /* --------------------- gpointers and stubs ---------------- */
 EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
@@ -549,14 +555,12 @@ EXTERN t_scalar *scalar_new(t_glist *owner,
 EXTERN void word_free(t_word *wp, t_template *tmpl);
 EXTERN void scalar_getbasexy(t_scalar *x, t_float *basex, t_float *basey);
 EXTERN void scalar_redraw(t_scalar *x, t_glist *glist);
+EXTERN void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
+    int amarrayelement);
+EXTERN int canvas_readscalar(t_glist *x, int natoms, t_atom *vec,
+    int *p_nextmsg, int selectit);
 
 /* ------helper routines for "garrays" and "plots" -------------- */
-EXTERN int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
-    t_symbol *elemtemplatesym,
-    t_float linewidth, t_float xloc, t_float xinc, t_float yloc, t_float scalarvis,
-    t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
-    int xpix, int ypix, int shift, int alt, int dbl, int doit);
-
 EXTERN void array_getcoordinate(t_glist *glist,
     char *elem, int xonset, int yonset, int wonset, int indx,
     t_float basex, t_float basey, t_float xinc,
diff --git a/bundled/m_pd.h b/bundled/m_pd.h
index d73b6bbf..52805a89 100644
--- a/bundled/m_pd.h
+++ b/bundled/m_pd.h
@@ -9,8 +9,8 @@ extern "C" {
 #endif
 
 #define PD_MAJOR_VERSION 0
-#define PD_MINOR_VERSION 44
-#define PD_BUGFIX_VERSION 3
+#define PD_MINOR_VERSION 45
+#define PD_BUGFIX_VERSION 5
 #define PD_TEST_VERSION ""
 extern int pd_compatibilitylevel;   /* e.g., 43 for pd 0.43 compatibility */
 
@@ -68,8 +68,6 @@ typedef unsigned __int8   uint8_t;
 typedef unsigned __int16  uint16_t;
 typedef unsigned __int32  uint32_t;
 typedef unsigned __int64  uint64_t;
-#elif defined(IRIX)
-typedef long int32_t;  /* a data type that has 32 bits */
 #else
 # include <stdint.h>
 #endif
@@ -84,9 +82,24 @@ typedef long int32_t;  /* a data type that has 32 bits */
 #if !defined(PD_LONGINTTYPE)
 #define PD_LONGINTTYPE long
 #endif
-#if !defined(PD_FLOATTYPE)
-#define PD_FLOATTYPE float
+
+#if !defined(PD_FLOATSIZE)
+  /* normally, our floats (t_float, t_sample,...) are 32bit */
+# define PD_FLOATSIZE 32
+#endif
+
+#if PD_FLOATSIZE == 32
+# define PD_FLOATTYPE float
+/* an unsigned int of the same size as FLOATTYPE: */
+# define PD_FLOATUINTTYPE unsigned int
+
+#elif PD_FLOATSIZE == 64
+# define PD_FLOATTYPE double
+# define PD_FLOATUINTTYPE unsigned long
+#else
+# error invalid FLOATSIZE: must be 32 or 64
 #endif
+
 typedef PD_LONGINTTYPE t_int;       /* pointer-size integer */
 typedef PD_FLOATTYPE t_float;       /* a float type at most the same size */
 typedef PD_FLOATTYPE t_floatarg;    /* float type for function calls */
@@ -138,7 +151,7 @@ typedef union word
     t_symbol *w_symbol;
     t_gpointer *w_gpointer;
     t_array *w_array;
-    struct _glist *w_list;
+    struct _binbuf *w_binbuf;
     int w_index;
 } t_word;
 
@@ -317,6 +330,7 @@ EXTERN void binbuf_restore(t_binbuf *x, int argc, t_atom *argv);
 EXTERN void binbuf_print(t_binbuf *x);
 EXTERN int binbuf_getnatom(t_binbuf *x);
 EXTERN t_atom *binbuf_getvec(t_binbuf *x);
+EXTERN int binbuf_resize(t_binbuf *x, int newsize);
 EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
 EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
     int crflag);
@@ -336,9 +350,12 @@ EXTERN t_clock *clock_new(void *owner, t_method fn);
 EXTERN void clock_set(t_clock *x, double systime);
 EXTERN void clock_delay(t_clock *x, double delaytime);
 EXTERN void clock_unset(t_clock *x);
+EXTERN void clock_setunit(t_clock *x, double timeunit, int sampflag);
 EXTERN double clock_getlogicaltime(void);
 EXTERN double clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
 EXTERN double clock_gettimesince(double prevsystime);
+EXTERN double clock_gettimesincewithunits(double prevsystime,
+    double units, int sampflag);
 EXTERN double clock_getsystimeafter(double delaytime);
 EXTERN void clock_free(t_clock *x);
 
@@ -444,6 +461,7 @@ EXTERN void class_setparentwidget(t_class *c, t_parentwidgetbehavior *w);
 EXTERN t_parentwidgetbehavior *class_parentwidget(t_class *c);
 EXTERN char *class_getname(t_class *c);
 EXTERN char *class_gethelpname(t_class *c);
+EXTERN char *class_gethelpdir(t_class *c);
 EXTERN void class_setdrawcommand(t_class *c);
 EXTERN int class_isdrawcommand(t_class *c);
 EXTERN void class_domainsignalin(t_class *c, int onset);
@@ -455,6 +473,8 @@ EXTERN void class_set_extern_dir(t_symbol *s);
 typedef void (*t_savefn)(t_gobj *x, t_binbuf *b);
 EXTERN void class_setsavefn(t_class *c, t_savefn f);
 EXTERN t_savefn class_getsavefn(t_class *c);
+EXTERN void obj_saveformat(t_object *x, t_binbuf *bb); /* add format to bb */
+
         /* prototype for functions to open properties dialogs */
 typedef void (*t_propertiesfn)(t_gobj *x, struct _glist *glist);
 EXTERN void class_setpropertiesfn(t_class *c, t_propertiesfn f);
@@ -516,6 +536,10 @@ EXTERN int sys_trylock(void);
 /* --------------- signals ----------------------------------- */
 
 typedef PD_FLOATTYPE t_sample;
+typedef union _sampleint_union {
+  t_sample f;
+  PD_FLOATUINTTYPE i;
+} t_sampleint_union;
 #define MAXLOGSIG 32
 #define MAXSIGSIZE (1 << MAXLOGSIG)
 
@@ -623,6 +647,8 @@ EXTERN void garray_resize(t_garray *x, t_floatarg f);  /* avoid; use this: */
 EXTERN void garray_resize_long(t_garray *x, long n);   /* better version */
 EXTERN void garray_usedindsp(t_garray *x);
 EXTERN void garray_setsaveit(t_garray *x, int saveit);
+EXTERN t_glist *garray_getglist(t_garray *x);
+EXTERN t_array *garray_getarray(t_garray *x);
 EXTERN t_class *scalar_class;
 
 EXTERN t_float *value_get(t_symbol *s);
@@ -666,18 +692,37 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
 
 #define PD_USE_TE_XPIX
 
+#ifndef _MSC_VER /* Microoft compiler can't handle "inline" function/macros */
 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
 /* a test for NANs and denormals.  Should only be necessary on i386. */
+# if PD_FLOATSIZE == 32
+static inline int PD_BADFLOAT(t_sample f) {
+  t_sampleint_union u;
+  u.f=f;
+  return ((u.i & 0x7f800000)==0) || ((u.i&0x7f800000)==0x7f800000);
+}
+/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
+static inline int PD_BIGORSMALL(t_sample f) {
+  t_sampleint_union u;
+  u.f=f;
+  return ((u.i & 0x60000000)==0) || ((u.i & 0x60000000)==0x60000000);
+}
+# else
+#  warning 64bit mode: BIGORSMALL not implemented yet
+#  define PD_BADFLOAT(f) 0
+#  define PD_BIGORSMALL(f) 0
+# endif
+#else
+# define PD_BADFLOAT(f) 0
+# define PD_BIGORSMALL(f) 0
+#endif
+#else   /* _MSC_VER */
 #define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \
     (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000))
 /* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
 #define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
     (((*(unsigned int*)&(f))&0x60000000)==0x60000000))
-#else
-#define PD_BADFLOAT(f) 0
-#define PD_BIGORSMALL(f) 0
-#endif
-
+#endif /* _MSC_VER */
     /* get version number at run time */
 EXTERN void sys_getversion(int *major, int *minor, int *bugfix);
 
-- 
2.19.1

