[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-java
Subject:    Re: [Kde-java] ANN: kalyptus bindings generator for C/Objective-C/Java
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2001-11-17 11:20:30
[Download RAW message or body]

On Friday 16 November 2001 8:58 pm, Richard Moore wrote:
> Hmm, how hard is it to extend this app? I'm wondering if it might be
> possible to write a binding for kjs to go with kjsembed. Any idea if this
> is feasible?
It shouldn't be too difficult. Some of the KJS datatypes such as UString are 
not converted at the moment - they need suitable data conversion methods to 
be written in KDESupport.* for the target langauge. eg 
KDESupport::toUString() and KDESupport::fromUString(). And suitable UString 
code generation needs to be added to kalyptusCxxToJava.pm.

Here are the steps needed to add the kjsembed types.

1) Run the headers through kalyptus

tipitina duke 568% ls
CVS                dialogfactory.h      jsconsolewidget.h  
messagelogwidget.cpp Makefile.am        jsbinding.h          jshookloader.cpp 
  messagelogwidget.h
README             jsconsolepart.cpp    jshookloader.h     testkjsembed.cpp
design.h           jsconsolepart.h      jsobjectproxy.cpp
dialogfactory.cpp  jsconsolewidget.cpp  jsobjectproxy.h
tipitina duke 569% mkdir tmp
tipitina duke 570% cd tmp
tipitina duke 571% kalyptus -fjava ../*.h

It will output an error message for each data type it hasn't encountered, for 
example:

'JSHookLoader*' => 'kde_JSHookLoader*',
'KJS::Interpreter*' => 'kde_KJS::Interpreter*',

These correspond to the perl needed to add these types to the type conversion 
table '$ctypemap' in kalyptusDataDict.pm. 

2) Repeat the previous command but run it though 'sort | uniq': 

kalyptus -fjava ../*.h | grep '=>' | sort | uniq
warning: MethodImp inherits unknown class 'KJS::ObjectImp'
warning: JSConsolePart inherits unknown class 'KParts::ReadOnlyPart'
warning: MessageLogWidget inherits unknown class 'QMultiLineEdit'
warning: JSConsoleWidget inherits unknown class 'QFrame'
warning: MethodImp inherits unknown class 'KJS::ObjectImp'
warning: JSObjectProxy inherits unknown class 'KJS::ObjectImp'
warning: MethodImp inherits unknown class 'KJS::ObjectImp'
'DialogFactory*' => 'kde_DialogFactory*',
'JSConsolePart*' => 'kde_JSConsolePart*',
'JSConsoleWidget*' => 'kde_JSConsoleWidget*',
'JSHookLoader*' => 'kde_JSHookLoader*',
'JSObjectProxy*' => 'kde_JSObjectProxy*',
'KJS::ExecState*' => 'kde_KJS::ExecState*',
'KJS::Interpreter*' => 'kde_KJS::Interpreter*',
'KJS::List&' => 'kde_KJS::List&',
'KJS::Object&' => 'kde_KJS::Object&',
'KJS::Value&' => 'kde_KJS::Value&',
'KJSEmbed*' => 'kde_KJSEmbed*',
'MessageLogWidget*' => 'kde_MessageLogWidget*',
'MethodImp*' => 'kde_MethodImp*',

Tidy up the suggested $ctypemap entries as follows, and add them to 
kalyptusDataDict.pm.

'DialogFactory*' => 'kde_DialogFactory*',
'JSConsolePart*' => 'kde_JSConsolePart*',
'JSConsoleWidget*' => 'kde_JSConsoleWidget*',
'JSHookLoader*' => 'kde_JSHookLoader*',
'JSObjectProxy*' => 'kde_JSObjectProxy*',
'KJS::ExecState*' => 'kde_ExecState*',
'KJS::Interpreter*' => 'kde_Interpreter*',
'KJS::List&' => 'kde_KJSList*',
'KJS::Object&' => 'kde_KJSObject*',
'KJS::Value&' => 'kde_KJSValue*',
'KJSEmbed*' => 'kde_KJSEmbed*',
'MessageLogWidget*' => 'kde_MessageLogWidget*',
'MethodImp*' => 'kde_MethodImp*',

Rebuild and install kalyptus with the new data types.

3) Run kalyptus again with the complete Qt and KDE headers, along with the 
new kjsembed headers. It needs to know if a class is descended from QObject 
or QWidget for correct java finalize() or objective-c -dealloc method 
generation.

kalyptus -fjava ../*.h /usr/lib/qt3/include/*.h /opt/kde3/include/*.h

4) Pick out the new KJS classes, get the java code compiled, and then run 
them through javah to generate .h files. Compile the javah .h files against 
the .cpp JNI files generated by kalyptus.

There is some more explanation in the qtjava/README file.

-- Richard
_______________________________________________
Kde-java mailing list
Kde-java@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-java

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic