Revision: 75285
          http://sourceforge.net/p/brlcad/code/75285
Author:   starseeker
Date:     2020-04-07 14:44:40 +0000 (Tue, 07 Apr 2020)
Log Message:
-----------
move Fb_Init to libtclcad

Modified Paths:
--------------
    brlcad/trunk/include/fb.h
    brlcad/trunk/include/tclcad.h
    brlcad/trunk/src/libfb/CMakeLists.txt
    brlcad/trunk/src/libtclcad/libfuncs.c
    brlcad/trunk/src/mged/attach.c

Removed Paths:
-------------
    brlcad/trunk/src/libfb/tcl.c

Modified: brlcad/trunk/include/fb.h
===================================================================
--- brlcad/trunk/include/fb.h   2020-04-07 14:16:39 UTC (rev 75284)
+++ brlcad/trunk/include/fb.h   2020-04-07 14:44:40 UTC (rev 75285)
@@ -199,11 +199,6 @@
 #define FB_DEBUG_RW 4  /* Contents of reads and writes */
 #define FB_DEBUG_BRW 8 /* Buffered IO rpixel and wpixel */
 
-/* tcl.c */
-/* The presence of Tcl_Interp as an arg prevents giving arg list */
-FB_EXPORT extern void fb_tcl_setup(void);
-FB_EXPORT extern int Fb_Init(Tcl_Interp *interp);
-
 /**
  * report version information about LIBFB
  */

Modified: brlcad/trunk/include/tclcad.h
===================================================================
--- brlcad/trunk/include/tclcad.h       2020-04-07 14:16:39 UTC (rev 75284)
+++ brlcad/trunk/include/tclcad.h       2020-04-07 14:44:40 UTC (rev 75285)
@@ -483,6 +483,10 @@
 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);
 
+
+FB_EXPORT extern int Fb_Init(Tcl_Interp *interp);
+
+
 __END_DECLS
 
 #endif /* TCLCAD_H */

Modified: brlcad/trunk/src/libfb/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libfb/CMakeLists.txt       2020-04-07 14:16:39 UTC (rev 
75284)
+++ brlcad/trunk/src/libfb/CMakeLists.txt       2020-04-07 14:44:40 UTC (rev 
75285)
@@ -96,7 +96,6 @@
   if_null.c
   if_remote.c
   if_stack.c
-  tcl.c
   vers.c
   )
 

Deleted: brlcad/trunk/src/libfb/tcl.c
===================================================================
--- brlcad/trunk/src/libfb/tcl.c        2020-04-07 14:16:39 UTC (rev 75284)
+++ brlcad/trunk/src/libfb/tcl.c        2020-04-07 14:44:40 UTC (rev 75285)
@@ -1,140 +0,0 @@
-/*                           T C L . C
- * BRL-CAD
- *
- * Copyright (c) 1997-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @addtogroup libfb */
-/** @{ */
-/** @file ./libfb/tcl.c
- *
- * LIBFB's Tcl interface.
- *
- */
-/** @} */
-
-#include "common.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-#include "tcl.h"
-#include "bu/cmd.h"
-#include "bu/log.h"
-#include "bu/vls.h"
-#include "fb_private.h"
-#include "fb.h"
-
-/* private headers */
-#include "brlcad_version.h"
-
-/* from libfb/fb_obj.c */
-extern int Fbo_Init(Tcl_Interp *interp);
-
-/**
- * Hook function wrapper to the fb_common_file_size Tcl command
- */
-int
-fb_cmd_common_file_size(ClientData clientData, int argc, const char **argv)
-{
-    Tcl_Interp *interp = (Tcl_Interp *)clientData;
-    size_t width, height;
-    int pixel_size = 3;
-
-    if (argc != 2 && argc != 3) {
-       bu_log("wrong #args: should be \" fileName [#bytes/pixel]\"");
-       return TCL_ERROR;
-    }
-
-    if (argc >= 3) {
-       pixel_size = atoi(argv[2]);
-    }
-
-    if (fb_common_file_size(&width, &height, argv[1], pixel_size) > 0) {
-       struct bu_vls vls = BU_VLS_INIT_ZERO;
-       bu_vls_printf(&vls, "%lu %lu", (unsigned long)width, (unsigned 
long)height);
-       Tcl_SetObjResult(interp,
-                        Tcl_NewStringObj(bu_vls_addr(&vls), 
bu_vls_strlen(&vls)));
-       bu_vls_free(&vls);
-       return TCL_OK;
-    }
-
-    /* Signal error */
-    Tcl_SetResult(interp, "0 0", TCL_STATIC);
-    return TCL_OK;
-}
-
-
-static int
-wrapper_func(ClientData data, Tcl_Interp *interp, int argc, const char *argv[])
-{
-    struct bu_cmdtab *ctp = (struct bu_cmdtab *)data;
-
-    return ctp->ct_func(interp, argc, argv);
-}
-
-
-static void
-register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds)
-{
-    struct bu_cmdtab *ctp = NULL;
-
-    for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) {
-       (void)Tcl_CreateCommand(interp, ctp->ct_name, wrapper_func, 
(ClientData)ctp, (Tcl_CmdDeleteProc *)NULL);
-    }
-}
-
-
-/*
- * Allows LIBFB to be dynamically loaded to a vanilla tclsh/wish with
- * "load /usr/brlcad/lib/libfb.so"
- *
- * The name of this function is specified by TCL.
- */
-int
-Fb_Init(Tcl_Interp *interp)
-{
-    static struct bu_cmdtab cmdtab[] = {
-       {"fb_common_file_size",  fb_cmd_common_file_size},
-       {(const char *)NULL, BU_CMD_NULL}
-    };
-
-    /* register commands */
-    register_cmds(interp, cmdtab);
-
-    /* initialize framebuffer object code */
-    Fbo_Init(interp);
-
-    Tcl_PkgProvide(interp,  "Fb", brlcad_version());
-
-    return TCL_OK;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

Modified: brlcad/trunk/src/libtclcad/libfuncs.c
===================================================================
--- brlcad/trunk/src/libtclcad/libfuncs.c       2020-04-07 14:16:39 UTC (rev 
75284)
+++ brlcad/trunk/src/libtclcad/libfuncs.c       2020-04-07 14:44:40 UTC (rev 
75285)
@@ -459,7 +459,7 @@
 
 
 static void
-register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds)
+bu_register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds)
 {
     struct bu_cmdtab *ctp = NULL;
 
@@ -486,7 +486,7 @@
        {(const char *)NULL, BU_CMD_NULL}
     };
 
-    register_cmds(interp, cmds);
+    bu_register_cmds(interp, cmds);
 
     Tcl_SetVar(interp, "BU_DEBUG_FORMAT", BU_DEBUG_FORMAT, TCL_GLOBAL_ONLY);
     Tcl_LinkVar(interp, "bu_debug", (char *)&bu_debug, TCL_LINK_INT);
@@ -2602,9 +2602,93 @@
     return ret;
 }
 
+/* LIBFB's Tcl interface.
+ */
 
+/* from libfb/fb_obj.c */
+extern int Fbo_Init(Tcl_Interp *interp);
 
+/**
+ * Hook function wrapper to the fb_common_file_size Tcl command
+ */
+int
+fb_cmd_common_file_size(ClientData clientData, int argc, const char **argv)
+{
+    Tcl_Interp *interp = (Tcl_Interp *)clientData;
+    size_t width, height;
+    int pixel_size = 3;
+
+    if (argc != 2 && argc != 3) {
+       bu_log("wrong #args: should be \" fileName [#bytes/pixel]\"");
+       return TCL_ERROR;
+    }
+
+    if (argc >= 3) {
+       pixel_size = atoi(argv[2]);
+    }
+
+    if (fb_common_file_size(&width, &height, argv[1], pixel_size) > 0) {
+       struct bu_vls vls = BU_VLS_INIT_ZERO;
+       bu_vls_printf(&vls, "%lu %lu", (unsigned long)width, (unsigned 
long)height);
+       Tcl_SetObjResult(interp,
+                        Tcl_NewStringObj(bu_vls_addr(&vls), 
bu_vls_strlen(&vls)));
+       bu_vls_free(&vls);
+       return TCL_OK;
+    }
+
+    /* Signal error */
+    Tcl_SetResult(interp, "0 0", TCL_STATIC);
+    return TCL_OK;
+}
+
+
+static int
+wrapper_func(ClientData data, Tcl_Interp *interp, int argc, const char *argv[])
+{
+    struct bu_cmdtab *ctp = (struct bu_cmdtab *)data;
+
+    return ctp->ct_func(interp, argc, argv);
+}
+
+
+static void
+fb_register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds)
+{
+    struct bu_cmdtab *ctp = NULL;
+
+    for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) {
+       (void)Tcl_CreateCommand(interp, ctp->ct_name, wrapper_func, 
(ClientData)ctp, (Tcl_CmdDeleteProc *)NULL);
+    }
+}
+
+
 /*
+ * Allows LIBFB to be dynamically loaded to a vanilla tclsh/wish with
+ * "load /usr/brlcad/lib/libfb.so"
+ *
+ * The name of this function is specified by TCL.
+ */
+int
+Fb_Init(Tcl_Interp *interp)
+{
+    static struct bu_cmdtab cmdtab[] = {
+       {"fb_common_file_size",  fb_cmd_common_file_size},
+       {(const char *)NULL, BU_CMD_NULL}
+    };
+
+    /* register commands */
+    fb_register_cmds(interp, cmdtab);
+
+    /* initialize framebuffer object code */
+    Fbo_Init(interp);
+
+    Tcl_PkgProvide(interp,  "Fb", brlcad_version());
+
+    return TCL_OK;
+}
+
+
+/*
  * Local Variables:
  * mode: C
  * tab-width: 8

Modified: brlcad/trunk/src/mged/attach.c
===================================================================
--- brlcad/trunk/src/mged/attach.c      2020-04-07 14:16:39 UTC (rev 75284)
+++ brlcad/trunk/src/mged/attach.c      2020-04-07 14:44:40 UTC (rev 75285)
@@ -44,6 +44,7 @@
 #include "vmath.h"
 #include "bu/env.h"
 #include "ged.h"
+#include "tclcad.h"
 
 #include "./mged.h"
 #include "./titles.h"

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

Reply via email to