Revision: 75466
http://sourceforge.net/p/brlcad/code/75466
Author: starseeker
Date: 2020-04-20 13:46:17 +0000 (Mon, 20 Apr 2020)
Log Message:
-----------
Whoops, revert deleted the tclcad io setup
Modified Paths:
--------------
brlcad/trunk/include/tclcad.h
brlcad/trunk/src/libtclcad/tclcad_obj.c
brlcad/trunk/src/mged/setup.c
Modified: brlcad/trunk/include/tclcad.h
===================================================================
--- brlcad/trunk/include/tclcad.h 2020-04-18 14:39:02 UTC (rev 75465)
+++ brlcad/trunk/include/tclcad.h 2020-04-20 13:46:17 UTC (rev 75466)
@@ -471,7 +471,18 @@
*/
TCLCAD_EXPORT extern int tclcad_init(Tcl_Interp *interp, int init_gui, struct
bu_vls *tlog);
+/**
+ * Create Tcl specific I/O handlers
+ */
+TCLCAD_EXPORT void
+tclcad_create_io_handler(void **chan, struct bu_process *p, int fd, int mode,
void *data, ged_io_handler_callback_t callback);
+/**
+ * Delete Tcl specific I/O handlers
+ */
+TCLCAD_EXPORT void
+tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p, int
fd, void *data, ged_io_handler_callback_t callback);
+
__END_DECLS
#endif /* TCLCAD_H */
Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c 2020-04-18 14:39:02 UTC (rev
75465)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c 2020-04-20 13:46:17 UTC (rev
75466)
@@ -51,6 +51,7 @@
#include "rt/geom.h"
#include "wdb.h"
#include "raytrace.h"
+#include "ged.h"
#include "tclcad.h"
#include "rt/solid.h"
@@ -57,7 +58,6 @@
#include "dm.h"
#include "dm/bview.h"
-#include "ged.h"
#include "icv/io.h"
#include "icv/ops.h"
#include "icv/crop.h"
@@ -1521,7 +1521,6 @@
return TCL_OK;
}
-
/**
* @brief create the Tcl command for to_open
*
@@ -1693,6 +1692,52 @@
}
+/* Wrappers for setting up/tearing down IO handler */
+#ifndef _WIN32
+void
+tclcad_create_io_handler(void **UNUSED(chan), struct bu_process *p, int fd,
int mode, void *data, ged_io_handler_callback_t callback)
+{
+ int *fdp;
+ if (!p) return;
+ fdp = (int *)bu_process_fd(p, fd);
+ Tcl_CreateFileHandler(*fdp, mode, callback, (ClientData)data);
+}
+
+void
+tclcad_delete_io_handler(void *UNUSED(interp), void *UNUSED(chan), struct
bu_process *p, int fd, void *UNUSED(data), ged_io_handler_callback_t
UNUSED(callback))
+{
+ int *fdp;
+ if (!p) return;
+ fdp = (int *)bu_process_fd(p, fd);
+ Tcl_DeleteFileHandler(*fdp);
+ close(*fdp);
+}
+
+#else
+void
+tclcad_create_io_handler(void **chan, struct bu_process *p, int fd, int mode,
void *data, ged_io_handler_callback_t callback)
+{
+ HANDLE *fdp;
+ if (!chan || !p) return;
+ fdp = (HANDLE *)bu_process_fd(p, fd);
+ (*chan) = (void *)Tcl_MakeFileChannel(*fdp, mode);
+ Tcl_CreateChannelHandler((Tcl_Channel)(*chan), mode, callback,
(ClientData)data);
+}
+
+void
+tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p, int
fd, void *data, ged_io_handler_callback_t callback)
+{
+ HANDLE *fdp;
+ Tcl_Interp *tcl_interp;
+ if (!chan || !p) return;
+ tcl_interp = (Tcl_Interp *)interp;
+ fdp = (HANDLE *)bu_process_fd(p, fd);
+ Tcl_DeleteChannelHandler((Tcl_Channel)chan, callback, (ClientData)data);
+ Tcl_Close(tcl_interp, (Tcl_Channel)chan);
+}
+#endif
+
+
/**
* @brief
* A TCL interface to wdb_fopen() and wdb_dbopen().
@@ -1768,6 +1813,11 @@
}
gedp->ged_interp = (void *)interp;
+ /* Set the Tcl specific I/O handlers for asynchronous subprocess I/O */
+ gedp->ged_create_io_handler = &tclcad_create_io_handler;
+ gedp->ged_delete_io_handler = &tclcad_delete_io_handler;
+ gedp->io_mode = TCL_READABLE;
+
/* initialize tclcad_obj */
BU_ALLOC(top, struct tclcad_obj);
top->to_interp = interp;
Modified: brlcad/trunk/src/mged/setup.c
===================================================================
--- brlcad/trunk/src/mged/setup.c 2020-04-18 14:39:02 UTC (rev 75465)
+++ brlcad/trunk/src/mged/setup.c 2020-04-20 13:46:17 UTC (rev 75466)
@@ -474,6 +474,9 @@
mged_global_variable_setup(*interpreter);
mged_variable_setup(*interpreter);
GEDP->ged_interp = (void *)*interpreter;
+ GEDP->ged_create_io_handler = &tclcad_create_io_handler;
+ GEDP->ged_delete_io_handler = &tclcad_delete_io_handler;
+ GEDP->io_mode = TCL_READABLE;
GEDP->ged_interp_eval = &mged_db_search_callback;
/* Tcl needs to write nulls onto subscripted variable names */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits