Hello,
I would like to know if it's possible to make C/C++ calls from
javascript, compiled in a static or dynamic library and included, and
in such a case how can I do that. Does someone know it? Thank you very
much. Any help would be very appreciated.
Regards
Matteo
|
|
0
|
|
|
|
Reply
|
Teo
|
5/10/2010 12:04:38 PM |
|
Teo wrote:
> Hello,
>
> I would like to know if it's possible to make C/C++ calls from
> javascript, compiled in a static or dynamic library and included, and
> in such a case how can I do that. Does someone know it? Thank you very
> much. Any help would be very appreciated.
>
> Regards
> Matteo
From Java you can call C/C++
Java -> JNI -> C libraries
and from JavaScript you can call Java applets
JavaScript -> Java Applet
But I doubt you can complete the sequence from JavaScript to Java to JNI
to C because a Java Applet is trapped within a sandbox called the JVM
(Java Virtual Machine) and I'd be surprised if it lets you access JNI
and C libraries. If it did, then any webpage with an applet on it could
basically do anything at all on your machine.
All the above changes if your web page isn't on the web and can use hta
of course.
|
|
0
|
|
|
|
Reply
|
Joe
|
5/10/2010 12:21:19 PM
|
|
Teo schreef:
> Hello,
>
> I would like to know if it's possible to make C/C++ calls from
> javascript, compiled in a static or dynamic library and included, and
> in such a case how can I do that. Does someone know it? Thank you very
> much. Any help would be very appreciated.
>
> Regards
> Matteo
Hi,
AFAIK: No, not from within a browser (unless it is broken).
You can of course make calls to your server and do over there whatever
you like (including calling your C libs) and return the output to your
JavaScript.
Something like:
JavaScript instantiates a XMLHTTPREQUEST object (AJAX).
eg http://www.example.com/myC_call.php?info=34
and catch the output back.
From myC_call.php (or whatever serverside language suits you) you can
call your C routines.
Of course, this solution will not be suitable for fast execution since
it needs a roundtrip to the server.
Maybe using a Java applet makes more sense in your situation. (This
involves writing your C code again in Java.)
Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
|
|
0
|
|
|
|
Reply
|
Erwin
|
5/10/2010 1:12:24 PM
|
|
On 10 Mag, 15:12, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
> Teo schreef:
>
> > Hello,
>
> > I would like to know if it's possible to make C/C++ calls from
> > javascript, compiled in a static or dynamic library and included, and
> > in such a case how can I do that. Does someone know it? Thank you very
> > much. Any help would be very appreciated.
>
> > Regards
> > Matteo
>
> Hi,
>
> AFAIK: No, not from within a browser (unless it is broken).
>
> You can of course make calls to your server and do over there whatever
> you like (including calling your C libs) and return the output to your
> JavaScript.
>
> Something like:
> JavaScript instantiates a XMLHTTPREQUEST object (AJAX).
> eghttp://www.example.com/myC_call.php?info=3D34
> and catch the output back.
>
> =A0From myC_call.php (or whatever serverside language suits you) you can
> call your C routines.
>
> Of course, this solution will not be suitable for fast execution since
> it needs a roundtrip to the server.
>
> Maybe using a Java applet makes more sense in your situation. (This
> involves writing your C code again in Java.)
>
> Regards,
> Erwin Moller
>
> --
> "There are two ways of constructing a software design: One way is to
> make it so simple that there are obviously no deficiencies, and the
> other way is to make it so complicated that there are no obvious
> deficiencies. The first method is far more difficult."
> -- C.A.R. Hoare
Ok I'll explain myself better, maybe I tackled the problem from an
uncorrect point of view. I would need a way to "extend" Javascript, or
something like that, to make C calls. I understood that probably, like
you guys told me, it's not possible making directly the calls. I mean
something like extension features of python, ruby etc. Thank you a lot
agiain.
|
|
0
|
|
|
|
Reply
|
Teo
|
5/10/2010 1:31:34 PM
|
|
On 10 Mag, 15:31, Teo <matteo.m...@gmail.com> wrote:
> On 10 Mag, 15:12, Erwin Moller
>
>
>
> <Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
> > Teo schreef:
>
> > > Hello,
>
> > > I would like to know if it's possible to make C/C++ calls from
> > > javascript, compiled in a static or dynamic library and included, and
> > > in such a case how can I do that. Does someone know it? Thank you ver=
y
> > > much. Any help would be very appreciated.
>
> > > Regards
> > > Matteo
>
> > Hi,
>
> > AFAIK: No, not from within a browser (unless it is broken).
>
> > You can of course make calls to your server and do over there whatever
> > you like (including calling your C libs) and return the output to your
> > JavaScript.
>
> > Something like:
> > JavaScript instantiates a XMLHTTPREQUEST object (AJAX).
> > eghttp://www.example.com/myC_call.php?info=3D34
> > and catch the output back.
>
> > =A0From myC_call.php (or whatever serverside language suits you) you ca=
n
> > call your C routines.
>
> > Of course, this solution will not be suitable for fast execution since
> > it needs a roundtrip to the server.
>
> > Maybe using a Java applet makes more sense in your situation. (This
> > involves writing your C code again in Java.)
>
> > Regards,
> > Erwin Moller
>
> > --
> > "There are two ways of constructing a software design: One way is to
> > make it so simple that there are obviously no deficiencies, and the
> > other way is to make it so complicated that there are no obvious
> > deficiencies. The first method is far more difficult."
> > -- C.A.R. Hoare
>
> Ok I'll explain myself better, maybe I tackled the problem from an
> uncorrect point of view. I would need a way to "extend" Javascript, or
> something like that, to make C calls. I understood that probably, like
> you guys told me, it's not possible making directly the calls. I mean
> something like extension features of python, ruby etc. Thank you a lot
> agiain.
I need this to implement a binding for another technology.
|
|
0
|
|
|
|
Reply
|
Teo
|
5/10/2010 1:33:21 PM
|
|
Teo wrote:
> Ok I'll explain myself better, maybe I tackled the problem from an
> uncorrect point of view. I would need a way to "extend" Javascript, or
> something like that, to make C calls. I understood that probably, like
> you guys told me, it's not possible making directly the calls. I mean
> something like extension features of python, ruby etc. Thank you a lot
> agiain.
To run in what environment? In most web browsers, there are already
plug-in architectures that might help. Of course then your users
would have to be willing to install your plug-in. For other
environments, there are probably mechanisms that are useful too. So
where should this run?
--
Scott
|
|
0
|
|
|
|
Reply
|
Scott
|
5/10/2010 1:35:48 PM
|
|
Teo wrote:
> On 10 Mag, 15:31, Teo <matteo.m...@gmail.com> wrote:
>> On 10 Mag, 15:12, Erwin Moller
>>
>>
>>
>> <Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
>>> Teo schreef:
>>>> Hello,
>>>> I would like to know if it's possible to make C/C++ calls from
>>>> javascript, compiled in a static or dynamic library and included, and
>>>> in such a case how can I do that. Does someone know it? Thank you very
>>>> much. Any help would be very appreciated.
>>>> Regards
>>>> Matteo
>>> Hi,
>>> AFAIK: No, not from within a browser (unless it is broken).
>>> You can of course make calls to your server and do over there whatever
>>> you like (including calling your C libs) and return the output to your
>>> JavaScript.
>>> Something like:
>>> JavaScript instantiates a XMLHTTPREQUEST object (AJAX).
>>> eghttp://www.example.com/myC_call.php?info=34
>>> and catch the output back.
>>> From myC_call.php (or whatever serverside language suits you) you can
>>> call your C routines.
>>> Of course, this solution will not be suitable for fast execution since
>>> it needs a roundtrip to the server.
>>> Maybe using a Java applet makes more sense in your situation. (This
>>> involves writing your C code again in Java.)
>>> Regards,
>>> Erwin Moller
>>> --
>>> "There are two ways of constructing a software design: One way is to
>>> make it so simple that there are obviously no deficiencies, and the
>>> other way is to make it so complicated that there are no obvious
>>> deficiencies. The first method is far more difficult."
>>> -- C.A.R. Hoare
>> Ok I'll explain myself better, maybe I tackled the problem from an
>> uncorrect point of view. I would need a way to "extend" Javascript, or
>> something like that, to make C calls. I understood that probably, like
>> you guys told me, it's not possible making directly the calls. I mean
>> something like extension features of python, ruby etc. Thank you a lot
>> agiain.
>
> I need this to implement a binding for another technology.
If you're limiting usage to Internet Explorer then you can write an
ActiveX control which can call C dlls. It won't work on non-IE plugins
though as they're as sandboxed as Java is.
|
|
0
|
|
|
|
Reply
|
Joe
|
5/10/2010 1:46:51 PM
|
|
On May 10, 2:04=A0pm, Teo <matteo.m...@gmail.com> wrote:
> Hello,
>
> I would like to know if it's possible to make C/C++ calls from
> javascript, compiled in a static or dynamic library and included, and
> in such a case how can I do that. Does someone know it? Thank you very
> much. Any help would be very appreciated.
>
> Regards
> Matteo
You can do that freely on a server running server-side JS (e.g.
Node.js [*1]), but not -normally- on a browser -unless you install a
plugin [*2] for that- where the JS code can't call nothing beyond the
provided secure sandboxed API.
(*1) http://node.js
(*2) http://developer.apple.com/Mac/library/documentation/AppleApplications=
/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html
--
Jorge.
|
|
0
|
|
|
|
Reply
|
Ry
|
5/10/2010 1:57:48 PM
|
|
On May 10, 3:57=A0pm, Ry Nohryb <jo...@jorgechamorro.com> wrote:
>
> You can do that freely on a server running server-side JS (e.g.
> Node.js [*1]), but not -normally- on a browser -unless you install a
> plugin [*2] for that- where the JS code can't call nothing beyond the
> provided secure sandboxed API.
>
> (*1)http://node.js
> (*2)http://developer.apple.com/Mac/library/documentation/AppleApplication=
s/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html
Sorry, http://nodejs.org and http://nodejs.org/api.html
See also:
http://google.com/search?q=3DWebKit_PluginProgTopic+filetype:pdf+site:devel=
oper.apple.com
--
Jorge.
|
|
0
|
|
|
|
Reply
|
Ry
|
5/10/2010 2:11:37 PM
|
|
On May 10, 4:11=A0pm, Ry Nohryb <jo...@jorgechamorro.com> wrote:
> On May 10, 3:57=A0pm, Ry Nohryb <jo...@jorgechamorro.com> wrote:
>
>
>
> > You can do that freely on a server running server-side JS (e.g.
> > Node.js [*1]), but not -normally- on a browser -unless you install a
> > plugin [*2] for that- where the JS code can't call nothing beyond the
> > provided secure sandboxed API.
>
> > (*1)http://node.js
> > (*2)http://developer.apple.com/Mac/library/documentation/AppleApplicati=
on...
>
> Sorry,http://nodejs.organdhttp://nodejs.org/api.html
>
> See also:http://google.com/search?q=3DWebKit_PluginProgTopic+filetype:pdf=
+site:d...
> --
> Jorge.
For server-side JS there's :
https://wiki.mozilla.org/ServerJS/Existing_APIs
http://www.mozilla.org/js/spidermonkey/ /* Pure C! (but not too fast)
*/
http://code.google.com/p/v8/ /* Damn fast ! */
http://webkit.org/projects/javascript/ /* JavaScriptCore: Damn fast
too! ++Pure C API */
(My favourites: Node.js and http://www.jsdb.org/ )
Plus the WSH crap from Microsoft, heavily poisoned with ActiveX
bindings.
--
Jorge.
|
|
0
|
|
|
|
Reply
|
Ry
|
5/10/2010 2:31:59 PM
|
|
Ry Nohryb :
> For server-side JS there's :
> https://wiki.mozilla.org/ServerJS/Existing_APIs
> http://www.mozilla.org/js/spidermonkey/ /* Pure C! (but not too fast) */
> http://code.google.com/p/v8/ /* Damn fast ! */
> http://webkit.org/projects/javascript/ /* JavaScriptCore: Damn fast too!
> ++Pure C API */
Why "for server-side JS" ?
--
Johannes
|
|
0
|
|
|
|
Reply
|
Johannes
|
5/10/2010 3:27:03 PM
|
|
On May 10, 5:27=A0pm, Johannes Baagoe <baa...@baagoe.com> wrote:
> Ry Nohryb :
>
> > For server-side JS there's :
> >https://wiki.mozilla.org/ServerJS/Existing_APIs
> >http://www.mozilla.org/js/spidermonkey//* Pure C! (but not too fast) */
> >http://code.google.com/p/v8//* Damn fast ! */
> >http://webkit.org/projects/javascript//* JavaScriptCore: Damn fast too!
> > ++Pure C API */
>
> Why "for server-side JS" ?
Hmmm. I guess I mean: not in-browser: the API they provide is !=3D=3D that
the API that JS in a browser provides.
--
Jorge.
|
|
0
|
|
|
|
Reply
|
Ry
|
5/10/2010 3:37:36 PM
|
|
Ry Nohryb :
> Johannes Baagoe :
>> Ry Nohryb :
>>> For server-side JS there's :
>>> https://wiki.mozilla.org/ServerJS/Existing_APIs
>>> http://www.mozilla.org/js/spidermonkey//* Pure C! (but not
>>> too fast) */ http://code.google.com/p/v8//* Damn fast ! */
>>> http://webkit.org/projects/javascript//* JavaScriptCore: Damn
>>> fast too! ++Pure C API */
>> Why "for server-side JS" ?
> Hmmm. I guess I mean: not in-browser: the API they provide is !==
> that the API that JS in a browser provides.
OK, as long as we don't forget that there are other applications than
Web servers and browsers :) Perhaps the best solution to the OP's
problem is a standalone application or a custom client that needs very
few of the functionalities of a full-fledged Web browser. Perhaps http,
html and the DOM are irrelevant.
Anyway, in addition to the links you provided, it may be worth the
trouble to take a look at http://live.gnome.org/Seed/
--
Johannes
|
|
0
|
|
|
|
Reply
|
Johannes
|
5/10/2010 4:09:21 PM
|
|
Teo wrote:
> Hello,
>
> I would like to know if it's possible to make C/C++ calls from
> javascript, compiled in a static or dynamic library and included, and
> in such a case how can I do that. Does someone know it? Thank you very
> much. Any help would be very appreciated.
>
It is possible to create an application that wraps Webkit and expose an
API to the script environment.
I do not have any experience doing that. You might try WebKit
documentation.
Apple changes the location of their documents pretty frequently, so no
saying how long that link will be good for, but if the link is bad, then
search for the title:
"Using JavaScript From Objective-C"
The document is found at a long, unmemorable URI from Apple and it may
have information for what you are looking to do:
<http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/JavaScriptFromObjC.html#//apple_ref/doc/uid/30001214-BCIIEAFH>
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
|
|
0
|
|
|
|
Reply
|
Garrett
|
5/10/2010 5:05:14 PM
|
|
|
13 Replies
88 Views
(page loaded in 0.523 seconds)
Similiar Articles: getElementsByTagNameNS Function Call - comp.lang.javascript ...getElementsByTagNameNS Function Call - JavaScript / Ajax / DHTML getElementsByTagNameNS Function Call. JavaScript / Ajax / DHTML Forums on Bytes. how to display a message in console window? - comp.lang.javascript ...thinktwice wrote: > i call it in bat file, > like this : > cmd CScript /k C:\test.wsf The - cmd - command ... comp.lang.javascript 30940 articles. 9 followers. JButton and Execute Windows Batch File - comp.lang.java.help ...... rt = Runtime.getRuntime(); String[] args = {"c ... run file.bat from java - comp.lang.java.security Javascript ... Control Applets - Run at commandline or call in batch ... JavaScript - prototype - check for browser compatibility - comp ...> and want to check if the library is running properly, because javascript > prototype ... not have the `undefined' value; it does not test that the code invoked by calling ... XMLHTTP TimeOut - comp.lang.javascriptxmlhttp.open( "GET", [ "apps.php?call=navcategory&maxlimit ... comp.lang.javascript 30940 articles. 9 followers. onKeyup - cancel previous events if next char entered quickly ...I'm trying to minimize the number of unnecessary db calls as much as I can. ... onKeyup - cancel previous events if next char entered quickly?. JavaScript / Ajax ... 'Deferred' functions? - comp.lang.javascriptHi all Does javascript have the concept of a 'deferred' function? I don't know if ... >> >> >> I want to call a function from within a 'got focus' hander, and that ... Create a layer with a message on mouseover - comp.lang.javascript ...wrote on 14 mei 2005 in comp.lang.javascript: > I know this ... Onmouseover, I like to call >another layer which ... CSS solution too: <style> /* CSS hack by (: McA (c ... How to execute Jar file using Batch file. - comp.lang.java ...... Xmx200m -cp .src.cmdbwc.cmdbw_main %1 %2 %3 %4 %5 %6 %7> > > > Call & Error> =====> C ... how to execute a .bat from Javascript? - comp.text.pdf run file.bat from java ... json functions - comp.lang.xharbouror show me the way to call these functions? Thank you so much Pere ... xharbour/AT/telkom/net/id> + include/hbjson.h + source/rtl/hbjson.c ! JavaScript ... How do I access trusted sites programmatically? - comp.lang ...Hi, How can I access the trusted sites list for the currently logged in user programmatically? Is there some sort of IE API which I can call to get ... Convert getFullYear to 2-digit format - comp.lang.javascript ...... same thing with %100 The OP, in Subject and Body, calls ... comp.lang.javascript 30940 articles. 9 followers. ... converting double to long - comp.lang.c I need to ... Open Save Dialog box using Virtual Folders - comp.lang.javascript ...Hi, I have an file1.exe file stored at some physical location say C ... Open Save Dialog box using Virtual Folders - comp.lang.javascript ... How to call Save As Dialog ... JAVASCRIPT AND EXCEL, SET OUTPUT FILE NAME - comp.lang.javascript ...Hi, Is it possible to set the output file name of a excel file from javascript? ... to file and process - how? - comp.os.linux ... will set a ... doc load Then call ... LinkDemand equivalent in Java? - comp.lang.java.security ...Note: myMth2 accepts (recursive) calls from any methods that it calls. package ... speed issues traversing the DOM. - comp.lang.javascript... the JS to complete from Json ... JavaScript call from C++ - CodeProjectA class for easy implementation of JavaScript calls from C++ code.; Author: Eugene Khodakovsky; Updated: 7 Jul 2011; Section: COM / COM+; Chapter: Platforms ... Javascript calling C/C++ code located in dll loaded as a plugin ...Worth throwing in that I changed this since the last email to return a value rather than make a JS call to the browser. See older revisions for the old described methods. 7/19/2012 4:05:35 PM
|