lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> From: "Don Hopkins" <dhopkins@DonHopkins.com>
>
> I'd like to wrap a bunch of the Win32 telephony and other APIs that are
> unique to pocket pc phones. I'd also like an ActiveX interface that lets
> you easily integrate ActiveX / OLE Automation objects with Lua. The
> "jsdb" project does that for JavaScript, so I'm sure it could be done
> for Lua. The tricky part (that jsdb's ActiveX integration doesn't
> support) is receiving ActiveX events and sending them to Lua
> (IConnectionPointContainer et al). Python's win32com module does all
> that stuff, and it's extremely useful. I'd love that for Lua on Windows
> and Windows CE.
>
> -Don
>

Hello Don,

We are doing something along that line for a few years now, fast approaching
its release deadline. The goal of this project, called Elastos, is to
overcome the shortcomings of ActiveX/ OleAutomation/ IConnectionPoint/ etc.
and to help C/C++ programmers to move to Web Service Age.  There are
currently Widgets running on Windows, Linux and a smart-phone using XML+
Lua+ DLL (compiled C/C++ code).  Of course, we also support JavaScript/ Ruby
and so on.  All of our native DLLs are automation/ reflection-enabled, i.e.,
binary code packaged with meta-data, so Lua could script DLLs directly.
Implemented classes/ interfaces/ methods/ arguments of a DLL automatically
become XML tags, recursively.  Dlls run on a distributed/ grid  operating
platform layer which has all bells and whistles wrapped in self-describing
classes and interfaces, i.e., process, thread, mutex, file, RPC, window
controls, 2D/3D-graphics, everything.  Elastos also let programmers declare
URL (assigned a URL to every DLL), module, class, interface, callback,
aspect, domain, context, aggregate, synchronized, etc. in an ODL like
language called CAR (Component Assembly Runtime).  Everything fits in the
footprint of an embedded system (PDA or Smart-phone or Windows/ Linux).

In conclusion, we think of Elastos as "JAVA on steroids" -- lean, mean, and
fast, for system programmers.  Don't take me wrong, we support JAVA on our
smart-phone, on top of Elastos, because so many cell phone games rely on
J2ME.  Seriously, however, how many desktops run on CPUs other than x86?
Similarly, how many smart-phones run on non-ARM based CPUs?  Virtually none,
for both questions.  Sure, byte-code has its advantages.  But in the world
of embedded and system programming, we can't simply leave C/C++ behind.
Wouldn't it be wonderful if byte-code and native-code collaborate, all live
in harmony?

We are thinking about dual licensing Elastos, like QT, but no final words
from our lawyers yet.  Feel free to drop me questions.

Best regards,

Rong Chen  (Ex-team member of ActiveX/ IConnectionPoint/ OleAutomation :-)

Koretide Corp.
-----------------------------------------------
Addr: 2nd Floor, Bld.#17, 498 Guo Shoujing Road
      Pudong District, Shanghai 201203
      P.R.China
Tel:  + 86 21 5131-4260
Fax:  + 86 21 5131-4261
Skype: chen.rong
Email: chenrong@elastos.com




Ps: Last, but not least, some code snippets...

Lua example ------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<x:xmlglue xmlns:x="http://www.elastos.com/xml-glue"; xmlns:w="elactrl.dll">
    <w:form x:id="MainForm" nControlStyle="FormStyle_DoubleBuffer,
FormStyle_PixelAlphaChannel,
               ControlStyle_NoBackground" esCaption="sub" nLeft="20"
nTop="120" nWidth="100" nHeight="120">
        <w:pictureBox  x:id="picBox" nLeft="0" nTop="0" nWidth="100"
nHeight="120" nControlStyle="ControlStyle_NoBackground"/>
    </w:form>
    <script language="lua">

        function OnMouseDown(st, x, y, b)
            MainForm:SetWindowLevel(1)
        end

        function OnKeyDown(src, id, d)
            if id == 141 or id == 144 or id == 137 then
                MainForm:KillTimer(1)
                MainForm:Close()
            end
        end

        j = 0;
        images = {}
        elagdi = Elastos.Using("elagdi.dll")
        for j = 1, 17 do
            filename = "dancer" .. j .. ".png"
            image = elagdi.CImage()
            image:InitFromFile(resource(filename))
            images[j] = image
        end

        function OnTimer()
            local i = 1
            return function(src, id)
                i = i % 17 + 1
                picBox:SetImage(images[i])
                src:Update()
            end
        end

        picBox:SetImage(images[1]);
        MainForm:SetStackingClass(2)
        MainForm:SetTimer(1, 80)

        MainForm.Timer = OnTimer()
        picBox.MouseDown = OnMouseDown
        MainForm.KeyDown = OnKeyDown
        MainForm.InActive = OnLostFocus;
        MainForm.Active = OnGotFocus;
        MainForm:Show()

    </script>
</x:xglue>

JavaScript ------------------------------------------

function onButtonClick(src) {
    print(src.text + " clicked!");
}

elactrl = Elastos.Using("elactrl.dll");
form = elactrl.Form.New(
           "JavaScriptDemo", 0, 0, 240, 320, 0);
button = elactrl.Button.New(
              "Hello", 90, 60, 60, 25, 0, form);
button.Click = onButtonClick;
form.Show();


C/C++ ------------------------------------------

#include <stdio.h>       // support mostly standard .h files
#import <foobar.dll>     // DLLs are used in design-time and run-time

Boolean exitFlag = FALSE;

ECode OnClick(IFoo sender) {
    exitFlag = TRUE;
    return NOERROR;
}

int main()
{
    IBar* pBar;
    ECode ec = CFooBar::New("Hello", &pBar); // allow constructors.  btw,
CProcess::New(..), CThread::New(..) works as well.
    // ECode ec = CButton::NewInContext(pOuterSpace, "Hello", &pBar); //
trying to contact aliens on a machine far, far away...
    if (FAILED(ec)) { … }
    pBar->Bar();

    IFoo* pFoo;
    ec = IFoo::Query(pBar, &pFoo);  // does the object support IFoo?
    if (FAILED(ec)) { … }
    pFoo->Foo();

    CFooBar::AddClickCallback(pFoo, &OnClick);  // bind a callback handler
    while (exitFlag == FALSE) sleep(1);  // waiting for the callback handler
to be called...

    pBar->Release();  // still use the good ol' reference counting,
unfortunately.
    pFoo->Release();
    return 0;
}