阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

GoAhead翻译—Embedded JavaScript

97次阅读
没有评论

共计 3440 个字符,预计需要花费 9 分钟才能阅读完成。

Embedded JavaScript

GoAhead provides an embedded version of JavaScript with WebServer called Ejscript™. As the full JavaScript 1.2 specification is now quite a large language, its size prohibits its use in most embedded devices. GoAhead’s embedded JavaScript is designed to solve this dilemma. Ejscript™ is a strict subset of JavaScript and implements the essential elements of the language. Ejscript also interfaces with Active Server Pages (ASP) to allow the easy creation of dynamic Web pages.

GoAhead 提供一个嵌入式版本的 JavaScript,即 Ejscript。因为完整版的 JavaScript 1.2 现在是一个内容比较庞大的语言,它的大小阻止了它在嵌入式设备上的使用。GoAhead 嵌入式 JavaScript 就是为了解决这个尴尬的局面。Ejscript 是一个严格的 JavaScript 子集,它具备 JavaScript 必备的一些元素。Ejscript 同样和 ASP接口进行交互以创建建议的动态Web 网页。

A standalone product, Embedthis EJScript™ more fully supports the latest JavaScript 3 specification and is an alternative to the built-in WebServer support.

When JavaScript is used inside an ASP Web page, it consists of a script within ASP delimiters. The basic format is:

Embedthis EJScript 作为一个独立的产品更加充分的支持最新的 JavaScript 3,同时可以替代内置 WebServer 支持。

当 JavaScript 在 ASP Web 网页中使用的时候,脚本语言包含 ASP的分隔符内。基本的格式如下:

<% function(arguments, …); %>

JavaScript functions are created by the ejSetGlobalFunction. When the function is evaluated, the corresponding C procedure that implements the JavaScript function is called.

ejSetGlobalFunction 可以创建 JavaScript 功能。当功能被评估的时候,相应的处理处理 JavaScript 函数 C 程序就会被调用。

Ejscript implements the following JavaScript elements:Ejscript 包含以下一些 JavaScript 元素

· Case sensitivity大小写敏感

· White space空白字符

· Semicolons分号

· Comments逗号

· Identifiers标识符

· Data types including numbers, booleans, and strings with backslash characters数据类型

· Full expressions 充分表达式

· If/else, for, return

· Global function calls 全局函数调用

The following language elements are not implemented:

· Arrays 数组

· Objects 对象

· Labeled statements 标记语句

· Control flow statements including: break, case, continue, default, do/while, export, for/in, function, import, switch, var, while, and with 控制流

· Regular expressions 常规表达

JavaScript scripts can span multiple lines by using “\” as the last character on the preceding line. When used in ASP pages, function arguments can contain any query variable defined in either the URL query string or the standard variable set. URL query strings are automatically decoded, and JavaScript variables are defined to the decoded query value. For example, to parse the name and address encoded as a query string in a URL, use the following code:

http://localhost/mypage?name=smith&age=35

JavaScript 通过讲最后一个字符置为 ”\” 来续行。当 JavaScript 用于 ASP页面中的时候,功能参数可以包含任何定义在 URL 查询字符串 或者标准变量集里的变量。URL查询字符串是自动解码的,JavaScript 变量用于定义解码查询值。比如,解析 URL中的一个查询字符串中的名字和地址,使用如下的代码:

int myAspProcedure(webs_t wp, int argc, char_t **argv) {

char_t *name = websGetVar(wp, “name”, “undefined”);

char_t *age = websGetVar(wp, “age”, “undefined”);

websWrite(wp, “Name %s, Age”, args);

}

JavaScript procedures are registered by using the websAspDefine API. This publishes a C procedure as a JavaScript global function. For example:

extern int outputMyTable(int ejid, webs_t wp, int argc, char_t **argv);

websAspDefine(“outputTable”, outputMyTable);

The websAspDefine call publishes the JavaScript command “outputTable” and links it to the outputMyTable C procedure. When an ASP page is requested by the user’s browser, any ASP JavaScript which uses the outputTable command will cause the outputMyTable to be called with the relevant arguments.

JavaScript 过程是通过 websAspDefine API 来注册的。它将一个 C 程序作为一个全局的 JavaScript 来发布。websAspDefine 调用发布的 JavaScript 命令 outputTable,链接到 outputMyTable C 程序中。当用户请求一个ASP 页面的时候,任何使用 outputTable 命令的 ASP JavaScript 将会调用 outputMyTable 和相关的参数。

GoAhead 的详细介绍:请点这里
GoAhead 的下载地址:请点这里

相关阅读:

GoAhead 上实现文件上传到嵌入式 Web 服务器上 http://www.linuxidc.com/Linux/2011-10/45429.htm

GoAhead 2.5 嵌入式 Web 服务器移植到 ARM9 2440 + Linux 中 http://www.linuxidc.com/Linux/2011-09/43267.htm

GoAhead 移植到 uClinux 平台上 http://www.linuxidc.com/Linux/2011-01/31076.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计3440字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中