Check-in [3d3b2386ea]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge with trunk
Timelines: family | ancestors | descendants | both | wtf-8-experiment
Files: files | file ages | folders
SHA1: 3d3b2386ea1bf93b53c8031746268989aacdb683
User & Date: chw 2019-06-17 16:24:28
Context
2019-06-18
05:54
merge with trunk check-in: 959e085353 user: chw tags: wtf-8-experiment
2019-06-17
16:24
merge with trunk check-in: 3d3b2386ea user: chw tags: wtf-8-experiment
16:23
improve twv demo check-in: 88aafcd418 user: chw tags: trunk
2019-06-16
08:20
merge with trunk check-in: 59100d7e0c user: chw tags: wtf-8-experiment
Changes

Changes to undroid/build-vanilla-linux32.sh.

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
....
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

1566
1567
1568
1569




1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
....
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
....
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
SUBDIRS="${SUBDIRS} dbus-tcl dbus-intf tclx libdmtx ZBar zint"
SUBDIRS="${SUBDIRS} tcl-augeas tktray snack tkvnc tksvg VecTcl tclral"
SUBDIRS="${SUBDIRS} tclepeg tcluvc xotcl nsf libsocketcan tclcan vu"
SUBDIRS="${SUBDIRS} rl_json tkdnd mpexpr"
SUBDIRS="${SUBDIRS} tclcsv tkzinc libffi ffidl tcl-lmdb DiffUtilTcl"
SUBDIRS="${SUBDIRS} tclparser tclcompiler snap7 libmodbus fswatch"
SUBDIRS="${SUBDIRS} tserialport topcua parse_args tkvlc tclJBlend"
SUBDIRS="${SUBDIRS} tcl-fuse"

if pkg-config --exists webkit2gtk-4.0 ; then
  SUBDIRS="${SUBDIRS} twv"
fi

ACTION="$1"
if test -z "$ACTION" ; then
  ACTION=build
fi

clean_build_stamps() {
................................................................................
    Makefile
  make || exit 1
  make install-binaries install-libraries DESTDIR=${HERE} || exit 1
  touch build-stamp
  echo >&3 "done"
) || fail

if test -d twv ; then
  echo -n "build twv ... "
  (
    exec 3>&1
    exec >> build.log 2>&1
    cd twv
    test -e build-stamp && echo >&3 "already done" && exit 0

    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1




    install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
    touch build-stamp
    echo >&3 "done"
  ) || fail
fi

echo -n "strip binaries ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  set -x
  $STRIP ${PFX_HERE}/bin/tclsh* ${PFX_HERE}/bin/wish* ${PFX_HERE}/lib/*.so \
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/fuse* assets
  if test -d ${PFX_HERE}/lib/twv* ; then
    cp -rp ${PFX_HERE}/lib/twv* assets
    cp -rp ${AWDIR}/undroid/tsb* assets
  fi
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  if test "$ACTION" != "ebuild" ; then
    cp -rp ${AWDIR}/undroid/mkappimg assets
  fi
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
................................................................................
    echo > zinc-widget \
      'source [file dirname [info script]]/'$(echo Tkzinc*/demos/zinc-widget)
    echo > stardom \
      'source [file dirname [info script]]/'$(echo stardom*/stardom.tcl)
    echo > fuse \
      'set argv0 [file dirname [info script]]/'$(echo fuse*/fusevfs.tcl)
    echo >> fuse 'source $argv0'
    if test -d ${PFX_HERE}/lib/twv* ; then
      echo > TSB \
        'source [file dirname [info script]]/'$(echo tsb*/tsb.tcl)
    fi
  )
  # add tkchat
  if test -d ${AWDIR}/assets/tkchat* ; then
    cp -rp ${AWDIR}/assets/tkchat* assets
    (
      cd assets
      echo > tkchat \







|
<
<
<
<







 







<
|
|
|
|
|
|
>




>
>
>
>
|
|
|
|
<







 







<
|
|
<







 







<
|
|
<







90
91
92
93
94
95
96
97




98
99
100
101
102
103
104
....
1548
1549
1550
1551
1552
1553
1554

1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573

1574
1575
1576
1577
1578
1579
1580
....
1715
1716
1717
1718
1719
1720
1721

1722
1723

1724
1725
1726
1727
1728
1729
1730
....
1766
1767
1768
1769
1770
1771
1772

1773
1774

1775
1776
1777
1778
1779
1780
1781
SUBDIRS="${SUBDIRS} dbus-tcl dbus-intf tclx libdmtx ZBar zint"
SUBDIRS="${SUBDIRS} tcl-augeas tktray snack tkvnc tksvg VecTcl tclral"
SUBDIRS="${SUBDIRS} tclepeg tcluvc xotcl nsf libsocketcan tclcan vu"
SUBDIRS="${SUBDIRS} rl_json tkdnd mpexpr"
SUBDIRS="${SUBDIRS} tclcsv tkzinc libffi ffidl tcl-lmdb DiffUtilTcl"
SUBDIRS="${SUBDIRS} tclparser tclcompiler snap7 libmodbus fswatch"
SUBDIRS="${SUBDIRS} tserialport topcua parse_args tkvlc tclJBlend"
SUBDIRS="${SUBDIRS} tcl-fuse twv"





ACTION="$1"
if test -z "$ACTION" ; then
  ACTION=build
fi

clean_build_stamps() {
................................................................................
    Makefile
  make || exit 1
  make install-binaries install-libraries DESTDIR=${HERE} || exit 1
  touch build-stamp
  echo >&3 "done"
) || fail


echo -n "build twv ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd twv
  test -e build-stamp && echo >&3 "already done" && exit 0
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/i386/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail


echo -n "strip binaries ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  set -x
  $STRIP ${PFX_HERE}/bin/tclsh* ${PFX_HERE}/bin/wish* ${PFX_HERE}/lib/*.so \
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/fuse* assets

  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets

  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  if test "$ACTION" != "ebuild" ; then
    cp -rp ${AWDIR}/undroid/mkappimg assets
  fi
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
................................................................................
    echo > zinc-widget \
      'source [file dirname [info script]]/'$(echo Tkzinc*/demos/zinc-widget)
    echo > stardom \
      'source [file dirname [info script]]/'$(echo stardom*/stardom.tcl)
    echo > fuse \
      'set argv0 [file dirname [info script]]/'$(echo fuse*/fusevfs.tcl)
    echo >> fuse 'source $argv0'

    echo > TSB \
      'source [file dirname [info script]]/'$(echo tsb*/tsb.tcl)

  )
  # add tkchat
  if test -d ${AWDIR}/assets/tkchat* ; then
    cp -rp ${AWDIR}/assets/tkchat* assets
    (
      cd assets
      echo > tkchat \

Changes to undroid/build-vanilla-linux64.sh.

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
....
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

1566
1567
1568
1569




1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
....
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
....
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
SUBDIRS="${SUBDIRS} dbus-tcl dbus-intf tclx libdmtx ZBar zint"
SUBDIRS="${SUBDIRS} tcl-augeas tktray snack tkvnc tksvg VecTcl tclral"
SUBDIRS="${SUBDIRS} tclepeg tcluvc xotcl nsf libsocketcan tclcan vu"
SUBDIRS="${SUBDIRS} rl_json tkdnd mpexpr"
SUBDIRS="${SUBDIRS} tclcsv tkzinc libffi ffidl tcl-lmdb DiffUtilTcl"
SUBDIRS="${SUBDIRS} tclparser tclcompiler snap7 libmodbus fswatch"
SUBDIRS="${SUBDIRS} tserialport topcua parse_args tkvlc tclJBlend"
SUBDIRS="${SUBDIRS} tcl-fuse"

if pkg-config --exists webkit2gtk-4.0 ; then
  SUBDIRS="${SUBDIRS} twv"
fi

ACTION="$1"
if test -z "$ACTION" ; then
  ACTION=build
fi

clean_build_stamps() {
................................................................................
    Makefile
  make || exit 1
  make install-binaries install-libraries DESTDIR=${HERE} || exit 1
  touch build-stamp
  echo >&3 "done"
) || fail

if test -d twv ; then
  echo -n "build twv ... "
  (
    exec 3>&1
    exec >> build.log 2>&1
    cd twv
    test -e build-stamp && echo >&3 "already done" && exit 0

    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1




    install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
    touch build-stamp
    echo >&3 "done"
  ) || fail
fi

echo -n "strip binaries ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  set -x
  $STRIP ${PFX_HERE}/bin/tclsh* ${PFX_HERE}/bin/wish* ${PFX_HERE}/lib/*.so \
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/fuse* assets
  if test -d ${PFX_HERE}/lib/twv* ; then
    cp -rp ${PFX_HERE}/lib/twv* assets
    cp -rp ${AWDIR}/undroid/tsb* assets
  fi
  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  if test "$ACTION" != "ebuild" ; then
    cp -rp ${AWDIR}/undroid/mkappimg assets
  fi
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
................................................................................
    echo > zinc-widget \
      'source [file dirname [info script]]/'$(echo Tkzinc*/demos/zinc-widget)
    echo > stardom \
      'source [file dirname [info script]]/'$(echo stardom*/stardom.tcl)
    echo > fuse \
      'set argv0 [file dirname [info script]]/'$(echo fuse*/fusevfs.tcl)
    echo >> fuse 'source $argv0'
    if test -d ${PFX_HERE}/lib/twv* ; then
      echo > TSB \
        'source [file dirname [info script]]/'$(echo tsb*/tsb.tcl)
    fi
  )
  # add tkchat
  if test -d ${AWDIR}/assets/tkchat* ; then
    cp -rp ${AWDIR}/assets/tkchat* assets
    (
      cd assets
      echo > tkchat \







|
<
<
<
<







 







<
|
|
|
|
|
|
>




>
>
>
>
|
|
|
|
<







 







<
|
|
<







 







<
|
|
<







90
91
92
93
94
95
96
97




98
99
100
101
102
103
104
....
1548
1549
1550
1551
1552
1553
1554

1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573

1574
1575
1576
1577
1578
1579
1580
....
1715
1716
1717
1718
1719
1720
1721

1722
1723

1724
1725
1726
1727
1728
1729
1730
....
1766
1767
1768
1769
1770
1771
1772

1773
1774

1775
1776
1777
1778
1779
1780
1781
SUBDIRS="${SUBDIRS} dbus-tcl dbus-intf tclx libdmtx ZBar zint"
SUBDIRS="${SUBDIRS} tcl-augeas tktray snack tkvnc tksvg VecTcl tclral"
SUBDIRS="${SUBDIRS} tclepeg tcluvc xotcl nsf libsocketcan tclcan vu"
SUBDIRS="${SUBDIRS} rl_json tkdnd mpexpr"
SUBDIRS="${SUBDIRS} tclcsv tkzinc libffi ffidl tcl-lmdb DiffUtilTcl"
SUBDIRS="${SUBDIRS} tclparser tclcompiler snap7 libmodbus fswatch"
SUBDIRS="${SUBDIRS} tserialport topcua parse_args tkvlc tclJBlend"
SUBDIRS="${SUBDIRS} tcl-fuse twv"





ACTION="$1"
if test -z "$ACTION" ; then
  ACTION=build
fi

clean_build_stamps() {
................................................................................
    Makefile
  make || exit 1
  make install-binaries install-libraries DESTDIR=${HERE} || exit 1
  touch build-stamp
  echo >&3 "done"
) || fail


echo -n "build twv ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  cd twv
  test -e build-stamp && echo >&3 "already done" && exit 0
  if pkg-config --exists webkit2gtk-4.0 ; then
    make TCL_CFLAGS="-I${PFX_HERE}/include -DUSE_TCL_STUBS=1" \
      TCL_LDFLAGS="-L${PFX_HERE}/lib -ltclstub8.6" || exit 1
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 libtwv.so ${PFX_HERE}/lib/twv0.1
  else
    install -d ${PFX_HERE}/lib/twv0.1
    install -m 755 prebuilt/x86_64/libtwv.so ${PFX_HERE}/lib/twv0.1
  fi
  install -m 644 pkgIndex.tcl ${PFX_HERE}/lib/twv0.1
  touch build-stamp
  echo >&3 "done"
) || fail


echo -n "strip binaries ... "
(
  exec 3>&1
  exec >> build.log 2>&1
  set -x
  $STRIP ${PFX_HERE}/bin/tclsh* ${PFX_HERE}/bin/wish* ${PFX_HERE}/lib/*.so \
................................................................................
  cp -rp ${PFX_HERE}/lib/tserialport* assets
  cp -rp ${PFX_HERE}/lib/topcua* assets
  cp -rp ${PFX_HERE}/lib/parse_args* assets
  cp -rp ${PFX_HERE}/lib/tkvlc* assets
  cp -rp ${PFX_HERE}/lib/tclJBlend* assets
  cp -rp ${AWDIR}/assets/tdbcjdbc* assets
  cp -rp ${PFX_HERE}/lib/fuse* assets

  cp -rp ${PFX_HERE}/lib/twv* assets
  cp -rp ${AWDIR}/undroid/tsb* assets

  # add stripped down TDK
  cp -rp ${AWDIR}/undroid/TDK assets
  if test "$ACTION" != "ebuild" ; then
    cp -rp ${AWDIR}/undroid/mkappimg assets
  fi
  # add shortcuts providing builtin:widget, builtin:tksqlite, etc.
  (
................................................................................
    echo > zinc-widget \
      'source [file dirname [info script]]/'$(echo Tkzinc*/demos/zinc-widget)
    echo > stardom \
      'source [file dirname [info script]]/'$(echo stardom*/stardom.tcl)
    echo > fuse \
      'set argv0 [file dirname [info script]]/'$(echo fuse*/fusevfs.tcl)
    echo >> fuse 'source $argv0'

    echo > TSB \
      'source [file dirname [info script]]/'$(echo tsb*/tsb.tcl)

  )
  # add tkchat
  if test -d ${AWDIR}/assets/tkchat* ; then
    cp -rp ${AWDIR}/assets/tkchat* assets
    (
      cd assets
      echo > tkchat \

Changes to undroid/tsb/tsb.tcl.

799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
    set D_style {
	<style>
	body {
	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, monospace;
	    font-size: 100%;
	}
	label {
	    font-family: Consolas, monospace;
	    margin: 1px;
	    padding: 1px;
	}
	pre {
	    /* overflow-x: auto; */
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, monospace;
	    font-size: 100%;
	}
	.infield * {
	    vertical-align: middle;
	}
	.tin {
	    width: 85%;







|



|












|







799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
    set D_style {
	<style>
	body {
	    font-family: sans-serif, Arial, Tahoma, Helvetica;
	    font-size: 90%;
	}
	textarea {
	    font-family: Consolas, Monaco, monospace;
	    font-size: 100%;
	}
	label {
	    font-family: Consolas, Monaco, monospace;
	    margin: 1px;
	    padding: 1px;
	}
	pre {
	    /* overflow-x: auto; */
	    white-space: pre-wrap;
	    white-space: -moz-pre-wrap;
	    white-space: -pre-wrap;
	    white-space: -o-pre-wrap;
	    word-wrap: break-word;
	}
	pre, code {
	    font-family: Consolas, Monaco, monospace;
	    font-size: 100%;
	}
	.infield * {
	    vertical-align: middle;
	}
	.tin {
	    width: 85%;

Changes to undroid/twv/Makefile.

15
16
17
18
19
20
21




22
23
24
25
26
27
28
29
30
31
32
	WEBVIEW_CFLAGS := -DWEBVIEW_WINAPI=1
	WEBVIEW_LDFLAGS := -lole32 -lcomctl32 -loleaut32 -luuid -mwindows
else ifeq ($(shell uname -s),Darwin)
	TARGET := libtwv.dylib
	WEBVIEW_CFLAGS := -DWEBVIEW_COCOA=1
	WEBVIEW_LDFLAGS := -framework WebKit
else




	TARGET := libtwv.so
	WEBVIEW_CFLAGS := -DWEBVIEW_GTK=1 \
	    $(shell pkg-config --cflags gtk+-3.0 webkit2gtk-4.0)
	WEBVIEW_LDFLAGS := $(shell pkg-config --libs webkit2gtk-4.0)
endif

all:	$(TARGET)

$(TARGET): twv.c
	$(CC) -fPIC -shared $(CFLAGS) $(TCL_CFLAGS) $(WEBVIEW_CFLAGS) twv.c \
	    $(LDFLAGS) $(TCL_LDFLAGS) $(WEBVIEW_LDFLAGS) -o $@







>
>
>
>

|

|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
	WEBVIEW_CFLAGS := -DWEBVIEW_WINAPI=1
	WEBVIEW_LDFLAGS := -lole32 -lcomctl32 -loleaut32 -luuid -mwindows
else ifeq ($(shell uname -s),Darwin)
	TARGET := libtwv.dylib
	WEBVIEW_CFLAGS := -DWEBVIEW_COCOA=1
	WEBVIEW_LDFLAGS := -framework WebKit
else

# to omit runtime linking, remove WEBVIEW_GTK_DL and use
# WEBVIEW_LDFLAGS := $(shell pkg-config --libs webkit2gtk-4.0)

	TARGET := libtwv.so
	WEBVIEW_CFLAGS := -DWEBVIEW_GTK=1 -DWEBVIEW_GTK_DL=1 \
	    $(shell pkg-config --cflags gtk+-3.0 webkit2gtk-4.0)
	WEBVIEW_LDFLAGS := -lgtk-3 -lgdk-3 -lglib-2.0
endif

all:	$(TARGET)

$(TARGET): twv.c
	$(CC) -fPIC -shared $(CFLAGS) $(TCL_CFLAGS) $(WEBVIEW_CFLAGS) twv.c \
	    $(LDFLAGS) $(TCL_LDFLAGS) $(WEBVIEW_LDFLAGS) -o $@

Added undroid/twv/prebuilt/i386/libtwv.so.

cannot compute difference between binary files

Added undroid/twv/prebuilt/x86_64/libtwv.so.

cannot compute difference between binary files

Changes to undroid/twv/twv.c.

1
2
3
4



5
6
7
8
9
10
11
...
566
567
568
569
570
571
572






573
574
575
576
577
578
579
#include <tcl.h>

#define WEBVIEW_IMPLEMENTATION
#define WEBVIEW_STATIC



#include "webview.h"

/*
 * set w [::twv::new options ...]
 *
 * options:
 *   -width int
................................................................................
    if (Tcl_InitStubs(interp, "8.4", 0) == NULL) {
        return TCL_ERROR;
    }
#else
    if (Tcl_PkgRequire(interp, "Tcl", "8.4", 0) == NULL) {
        return TCL_ERROR;
    }






#endif
    if (Tcl_PkgProvide(interp, "twv", "0.1") != TCL_OK) {
        return TCL_ERROR;
    }
    tctrl = ckalloc(sizeof (tctrl));
    tctrl->counter = 0;
    Tcl_CreateNamespace(interp, "::twv", NULL, NULL);




>
>
>







 







>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#include <tcl.h>

#define WEBVIEW_IMPLEMENTATION
#define WEBVIEW_STATIC
#ifdef WEBVIEW_GTK_DL
#include "webview_dl.h"
#endif
#include "webview.h"

/*
 * set w [::twv::new options ...]
 *
 * options:
 *   -width int
................................................................................
    if (Tcl_InitStubs(interp, "8.4", 0) == NULL) {
        return TCL_ERROR;
    }
#else
    if (Tcl_PkgRequire(interp, "Tcl", "8.4", 0) == NULL) {
        return TCL_ERROR;
    }
#endif
#ifdef WEBVIEW_GTK_DL
    if (webview_dl_init() < 0) {
	Tcl_SetResult(interp, "runtime linking webview failed", TCL_STATIC);
	return TCL_ERROR;
    }
#endif
    if (Tcl_PkgProvide(interp, "twv", "0.1") != TCL_OK) {
        return TCL_ERROR;
    }
    tctrl = ckalloc(sizeof (tctrl));
    tctrl->counter = 0;
    Tcl_CreateNamespace(interp, "::twv", NULL, NULL);

Added undroid/twv/webview_dl.h.





































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#ifndef WEBVIEW_DL_H
#define WEBVIEW_DL_H

#ifdef WEBVIEW_GTK
#include <dlfcn.h>
#include <pthread.h>
#include <JavaScriptCore/JavaScript.h>
#include <webkit2/webkit2.h>

typedef size_t (*fn_JSStringGetMaximumUTF8CStringSize)(JSStringRef);
typedef size_t (*fn_JSStringGetUTF8CString)(JSStringRef string, char *, size_t);
typedef void (*fn_JSStringRelease)(JSStringRef);
typedef JSStringRef (*fn_JSValueToStringCopy)(JSContextRef, JSValueRef, JSValueRef *);
typedef JSGlobalContextRef (*fn_webkit_javascript_result_get_global_context)(WebKitJavascriptResult *);
typedef JSValueRef (*fn_webkit_javascript_result_get_value)(WebKitJavascriptResult *);
typedef void (*fn_webkit_settings_set_enable_developer_extras)(WebKitSettings *, gboolean);
typedef void (*fn_webkit_settings_set_enable_write_console_messages_to_stdout)(WebKitSettings *, gboolean);
typedef WebKitUserContentManager *(*fn_webkit_user_content_manager_new)(void);
typedef gboolean (*fn_webkit_user_content_manager_register_script_message_handler)(WebKitUserContentManager *, const gchar *);
typedef WebKitSettings *(*fn_webkit_web_view_get_settings)(WebKitWebView *);
typedef GType (*fn_webkit_web_view_get_type)(void);
typedef void (*fn_webkit_web_view_load_uri)(WebKitWebView *, const gchar *);
typedef GtkWidget *(*fn_webkit_web_view_new_with_user_content_manager)(WebKitUserContentManager *);
typedef void (*fn_webkit_web_view_run_javascript)(WebKitWebView *, const gchar *, GCancellable *, GAsyncReadyCallback, gpointer);
typedef void (*fn_webkit_web_view_set_background_color)(WebKitWebView *, const GdkRGBA *);

struct wk_dl {
  fn_JSStringGetMaximumUTF8CStringSize JSStringGetMaximumUTF8CStringSize;
  fn_JSStringGetUTF8CString JSStringGetUTF8CString;
  fn_JSStringRelease JSStringRelease;
  fn_JSValueToStringCopy JSValueToStringCopy;
  fn_webkit_javascript_result_get_global_context webkit_javascript_result_get_global_context;
  fn_webkit_javascript_result_get_value webkit_javascript_result_get_value;
  fn_webkit_settings_set_enable_developer_extras webkit_settings_set_enable_developer_extras;
  fn_webkit_settings_set_enable_write_console_messages_to_stdout webkit_settings_set_enable_write_console_messages_to_stdout;
  fn_webkit_user_content_manager_new webkit_user_content_manager_new;
  fn_webkit_user_content_manager_register_script_message_handler webkit_user_content_manager_register_script_message_handler;
  fn_webkit_web_view_get_settings webkit_web_view_get_settings;
  fn_webkit_web_view_get_type webkit_web_view_get_type;
  fn_webkit_web_view_load_uri webkit_web_view_load_uri;
  fn_webkit_web_view_new_with_user_content_manager webkit_web_view_new_with_user_content_manager;
  fn_webkit_web_view_run_javascript webkit_web_view_run_javascript;
  fn_webkit_web_view_set_background_color webkit_web_view_set_background_color;
};

#ifdef WEBVIEW_STATIC
#define WEBVIEW_API static
static struct wk_dl wk_dl = { 0 };
#else
#define WEBVIEW_API extern
extern struct wk_dl wk_dl = { 0 };
#endif

WEBVIEW_API int webview_dl_init(void) {
  static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
  static int initialized = 0;
  int i, result;
  static const char *libnames[2] = {
    "libwebkit2gtk-4.0.so.37",
    "libjavascriptcoregtk-4.0.so.18",
  };
  static void *libs[2] = { NULL, NULL };

  if (!initialized) {
    pthread_mutex_lock(&init_mutex);
    if (initialized) {
      goto done;
    }
    for (i = 0; i < 2; i++) {
      libs[i] = dlopen(libnames[i], RTLD_NOW);
      if (libs[i] == NULL) {
	initialized = -1;
	while (i > 0) {
	  --i;
	  dlclose(libs[i]);
	  libs[i] = NULL;
	}
	goto done;
      }
    }

#define DOSYM(name)				      \
    wk_dl.name = (fn_ ## name) dlsym(libs[0], #name); \
    if (wk_dl.name == NULL) goto dlerr;

    DOSYM(webkit_javascript_result_get_global_context);
    DOSYM(webkit_javascript_result_get_value);
    DOSYM(webkit_settings_set_enable_developer_extras);
    DOSYM(webkit_settings_set_enable_write_console_messages_to_stdout);
    DOSYM(webkit_user_content_manager_new);
    DOSYM(webkit_user_content_manager_register_script_message_handler);
    DOSYM(webkit_web_view_get_settings);
    DOSYM(webkit_web_view_get_type);
    DOSYM(webkit_web_view_load_uri);
    DOSYM(webkit_web_view_new_with_user_content_manager);
    DOSYM(webkit_web_view_run_javascript);
    DOSYM(webkit_web_view_set_background_color);

#undef DOSYM

#define DOSYM(name)				      \
    wk_dl.name = (fn_ ## name) dlsym(libs[1], #name); \
    if (wk_dl.name == NULL) goto dlerr;

    DOSYM(JSStringGetMaximumUTF8CStringSize);
    DOSYM(JSStringGetUTF8CString);
    DOSYM(JSStringRelease);
    DOSYM(JSValueToStringCopy);

#undef DOSYM

    initialized = 1;
    goto done;

dlerr:
    initialized = -1;
    for (i = 0; i < 2; i++) {
      dlclose(libs[i]);
      libs[i] = NULL;
    }

done:
    pthread_mutex_unlock(&init_mutex);
  }

  return (initialized > 0) ? 0 : -1;
}

#define JSStringGetMaximumUTF8CStringSize \
  wk_dl.JSStringGetMaximumUTF8CStringSize

#define JSStringGetUTF8CString \
  wk_dl.JSStringGetUTF8CString

#define JSStringRelease \
  wk_dl.JSStringRelease

#define JSValueToStringCopy \
  wk_dl.JSValueToStringCopy

#define webkit_javascript_result_get_global_context \
  wk_dl.webkit_javascript_result_get_global_context

#define webkit_javascript_result_get_value \
  wk_dl.webkit_javascript_result_get_value

#define webkit_settings_set_enable_developer_extras \
  wk_dl.webkit_settings_set_enable_developer_extras

#define webkit_settings_set_enable_write_console_messages_to_stdout \
  wk_dl.webkit_settings_set_enable_write_console_messages_to_stdout

#define webkit_user_content_manager_new \
  wk_dl.webkit_user_content_manager_new

#define webkit_user_content_manager_register_script_message_handler \
  wk_dl.webkit_user_content_manager_register_script_message_handler

#define webkit_web_view_get_settings \
  wk_dl.webkit_web_view_get_settings

#define webkit_web_view_get_type \
  wk_dl.webkit_web_view_get_type

#define webkit_web_view_load_uri \
  wk_dl.webkit_web_view_load_uri

#define webkit_web_view_new_with_user_content_manager \
  wk_dl.webkit_web_view_new_with_user_content_manager

#define webkit_web_view_run_javascript \
  wk_dl.webkit_web_view_run_javascript

#define webkit_web_view_set_background_color \
  wk_dl.webkit_web_view_set_background_color

#endif /* WEBVIEW_GTK */
#endif /* WEBVIEW_DL_H */