How to use “Google Apps Services” such as “Finance” in embedded JavaScript within V8 C++ engine?

112 views
Skip to first unread message

Nat M

unread,
Jan 17, 2014, 10:28:47 PM1/17/14
to v8-u...@googlegroups.com

Background

With the use “Google script” editor from Chrome browser, I can execute the following Google script and get the result shown below function myFunction`` script.

function myFunction()
{
    // Gets the price of Google's stock.
    var info = FinanceApp.getStockInfo('GOOG');
    Logger.log('The stock %s is trading at %s', info.name, info.price);
}

Output

[14-01-17 21:19:19:440 EST] The stock Google Inc is trading at 1150.530029296875

I am finding that, in addition to the standard Google apps services, one can select large array of “Advanced Google Services” (Ex: Prediction, AdSense) from Google script editor “Resource” menu item. This facility let one to develop small Java script code having very rich functionality.

What I would like to do

I liked to use the “Google Apps Services” from C++ codebase (not from browser). I believed, one way to get access to the above services is through V8 C++ based Java script engine.

Hence I downloaded V8 C++ engine, built it and was able to compile and run the ‘Hello World” test code provided in https://developers.google.com/v8/get_started.

Then I modified line

Handle<String> source = String::NewFromUtf8(isolate, "'Hello' + ', World!'");

in the “Hello World” program as follows:

Handle<String> source = String::NewFromUtf8(isolate, "var info = FinanceApp.getStockInfo('GOOG');");

But I am getting “:11: Uncaught ReferenceError: FinanceApp is not defined (null)”.

I am new to JavaScript. But I can say that the V8 JavaScript engine is unable to find the “Finance” JavaScript library in my environment. Looks like, this library is built into Chrome browser by default and works well in Google Script editor.

My Question

I would like to know whether Google support embedding “Google Apps Service” library from embedded JavaScript.

Even if not part of standard V8 download, do I have a way of getting the Google Apps Service libraries into V8 C++ environment in my desktop environment?

Flying Jester

unread,
Jan 17, 2014, 11:55:11 PM1/17/14
to v8-u...@googlegroups.com
The first step would be to interface with the service in C++. Then you would have to expose it to JS.

There is no specific allowance for what you are asking built in to V8, or any JS. What you want to use is, from what you've said, part of Chrome, and not part of V8.
Reply all
Reply to author
Forward
0 new messages