Fwd: Porting application from Tcl/Tk to Hecl on Android

104 views
Skip to first unread message

David Welton

unread,
May 16, 2011, 4:24:00 AM5/16/11
to he...@googlegroups.com
---------- Forwarded message ----------
From: zdia <reply+m-6813976-8647ec9a4209...@reply.github.com>
Date: Sat, May 14, 2011 at 4:06 PM
Subject: Porting application from Tcl/Tk to Hecl on Android
To: dav...@dedasys.com


I tried to post to <he...@googlegroups.com> but I got a Delivery Status
Notification (Failure) from google.groups

   Hello z....@gmx.de,

   We're writing to let you know that the group you tried to contact
(hecl) may not exist, or you may not have permission to post messages
to the group. A few more details on why you weren't able to post:

So I try to contact you this way:


I would like to port my Tcl/Tk application to Android but I am new to
Android and to Java.

The application, a password manager
(https://github.com/zdia/gorilla/wiki) has a Tk GUI, a database
management (using Itcl) and an encryption part for Bruce Schneier's
Twofish algorithm.

As there won't be a Tk binding for Android in the near future I thought
of coding a command line version of my app and using Pat Thoyts tclkit
on Android with some curses inspired user interface.

Googling around I found the Hecl project which seems to me a reasonable
alternative:

Before diving deeper in the world of Hecl the following
pre-considerations are essential for me:

* the encryption part

There is a Java port of Twofish. Is it possible to include this
extension with "Creating new Hecl commands"?

Do Hecl math commands allow bit shifts?

* UI part

I have seen there is a "textview", a "edittext", a "button" command and
so on. Is there to be found a complete list of the UI commands?

* db part

Hecl "things" allow object oriented coding?

Unfortunately I couldn't test the script.hcl because I've got the
following error on installing hecl.apk

> > dia[bin]$ adb install Hecl.apk
> > 620 KB/s (97529 bytes in 0.153s)
> >     pkg: /data/local/tmp/Hecl.apk
> > Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
So probably I will have to install some further files?

--
Reply to this email directly or view it on GitHub:
http://github.com/inbox/6813976#reply

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

David Welton

unread,
May 16, 2011, 10:10:15 AM5/16/11
to he...@googlegroups.com, z....@gmx.de
> I tried to post to <he...@googlegroups.com> but I got a Delivery Status
> Notification (Failure) from google.groups

>    We're writing to let you know that the group you tried to contact


> (hecl) may not exist, or you may not have permission to post messages
> to the group. A few more details on why you weren't able to post:

Strange - I didn't see any approval messages, although I was out of
town for a few days - maybe that's what did it.

> So I try to contact you this way:
>
>
> I would like to port my Tcl/Tk application to Android but I am new to
> Android and to Java.

I'd love to encourage that, but do know that the Android port is very betaish.

> The application, a password manager
> (https://github.com/zdia/gorilla/wiki) has a Tk GUI, a database
> management (using Itcl) and an encryption part for Bruce Schneier's
> Twofish algorithm.
>
> As there won't be a Tk binding for Android in the near future I thought
> of coding a command line version of my app and using Pat Thoyts tclkit
> on Android with some curses inspired user interface.
>
> Googling around I found the Hecl project which seems to me a reasonable
> alternative:
>
> Before diving deeper in the world of Hecl the following
> pre-considerations are essential for me:
>
> * the encryption part
>
> There is a Java port of Twofish. Is it possible to include this
> extension with "Creating new Hecl commands"?

Yes, it should be, but it'll require some hacking on your part.

> Do Hecl math commands allow bit shifts?

Not at the moment, and bit shifts sound like something you might want
to be doing in Java anyway. You want to use Hecl to do the high level
'do this, then do that' rather than fiddling with bits or heavy number
crunching.

> * UI part
>
> I have seen there is a "textview", a "edittext", a "button" command and
> so on. Is there to be found a complete list of the UI commands?

With Android, I decided to 'cheat' and use some introspection, because
there are a lot of GUI components, and I did not have the time to map
them all on to Hecl commands directly. So you'd want to learn about
how Android does GUI stuff and then look at the example code to see
how Hecl maps to it.

> * db part
>
> Hecl "things" allow object oriented coding?

Yes.

> Unfortunately I couldn't test the script.hcl because I've got the
> following error on installing hecl.apk
>
>> > dia[bin]$ adb install Hecl.apk
>> > 620 KB/s (97529 bytes in 0.153s)
>> >     pkg: /data/local/tmp/Hecl.apk
>> > Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
> So probably I will have to install some further files?

Unfortunately, I can't really help at this point in time - I simply
don't have enough time in the day any more - so you'd have to hack on
it yourself to find out why it's not working.

Zbigniew Diaczyszyn

unread,
May 16, 2011, 3:01:39 PM5/16/11
to he...@googlegroups.com
Am 16.05.2011 16:10, schrieb David Welton:

>> There is a Java port of Twofish. Is it possible to include this
>> extension with "Creating new Hecl commands"?
>
> Yes, it should be, but it'll require some hacking on your part.

Well, I am ready to learn something new.

> You want to use Hecl to do the high level
> 'do this, then do that' rather than fiddling with bits or heavy number

> crunching.?

Hm, the lowest level for Hecl is Java Code?

>> I have seen there is a "textview", a "edittext", a "button" command and
>> so on. Is there to be found a complete list of the UI commands?
>
> With Android, I decided to 'cheat' and use some introspection, because
> there are a lot of GUI components, and I did not have the time to map
> them all on to Hecl commands directly. So you'd want to learn about
> how Android does GUI stuff and then look at the example code to see
> how Hecl maps to it.

Ok

>> Unfortunately I couldn't test the script.hcl because I've got the
>> following error on installing hecl.apk
>>
>>>> dia[bin]$ adb install Hecl.apk
>>>> 620 KB/s (97529 bytes in 0.153s)
>>>> pkg: /data/local/tmp/Hecl.apk
>>>> Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
>> So probably I will have to install some further files?
>
> Unfortunately, I can't really help at this point in time - I simply
> don't have enough time in the day any more - so you'd have to hack on
> it yourself to find out why it's not working.

Well, I wanted to go the lazy way ...

After having installed Hecl with "ant android-install" Hecl is running
in my emulator. See the screenshot with Android 3.0 on android-11
application (tablet):

http://zdia.de/images/screenshots/hecl/HeclEditor.png

Just still one question before I will make some trials with Hecl:

Is there an interactive access to Hecl commands?

I would test and develop my application by modifying the script.tcl
inside the app bundle but isn't there a way to send interactively some
code to the Hecl interpreter (perhaps even connecting the interpreter
running inside a running application like tkcon does with Wish apps)?

"adb shell" for example allows interaction like this and I thought
"Hecl-debug.apk" would be something similar but it is just a copy of
Hecl.apk

I googled much around but you were the only one who gave the hint that a
.apk file is a .zip file.

The .apk bundle is very similar to the MacOSX bundle which is also a
zipped directory containing resources and executables.

Zbigniew Diaczyszyn

unread,
May 20, 2011, 4:16:49 PM5/20/11
to he...@googlegroups.com
> Is there an interactive access to Hecl commands?

I found the answer: Yes.

Start the Hecl-Server with the main menu and follow this guide:

"Running Hecl server on port ${port}. You can telnet to this port to
interact with Hecl after running this command: adb forward tcp:7405
tcp:7405\nSince the interpreter that you are accessing is a
sub-interpreter, to run commands in the main interpreter, which has
access to the Android GUI thread, you have to pass them with the
maineval command, like this: maineval { ... code ... }"]

Connection succeeded with:

$ telnet localhost 7405

The actual commands set is:

> sort [intro commands]
!= % * + - / 1+ 1- < <= = > >= abs acos activity adapterview after alert
and androidactivity androidlog append arrayadapter asin atan
base64::decode base64::encode basiclist basicspinner bgerror break
bufferedreader button callback catch cbrt ceil classof clock code
contentQuery continue copy cos cosh cursor d double edittext eq eval
exit exp expand expm1 false filter findview float floor for foreach
global gui hasclass hash hclear hcontains heclhandler hget hkeys hremove
hset http.data http.formatQuery http.geturl http.ncode http.status hypot
i if incr inputstream inputstreamreader int intent interp intro java
join l lappend lindex linearlayout linearlayoutparams linsert list
listview llen log log10 log1p long lrange lset maineval menu menuitem
message ne newActivity not null or outputstream outputstreamwriter pow
proc progressbar put puts random rename reslookup resourcebytes return
round runtime.freememory runtime.totalmemory s scrollview search
serversock set signum sin sinh socket sort spinner split sqrt strbytelen
strcmp strfind strindex strlast strlen strlower strrange strrep
strreplace strtrim strtriml strtrimr strupper system.gc
system.getproperty system.hasproperty tan tanh textview thisinterp throw
time tnotify toDegrees toRadians true twait unset upeval view while

Awesome!

Zbigniew Diaczyszyn

unread,
May 25, 2011, 1:55:14 PM5/25/11
to he...@googlegroups.com
I just want to announce that I created a Wiki page on Github for my
porting project based on Hecl

https://github.com/zdia/gorilla/wiki/Gorilla-for-Android

Reply all
Reply to author
Forward
0 new messages