Dreamweaver 扩展开发: Calling a C++ function from JavaScript

After you understand how C-level extensibility works in Dreamweaver and its dependency on certain data types and functions, it’s useful to know how to build a library and call a function.

The following example requires the following five files, located in the Dreamweaver-application-folder/ Tutorial_assets/Extending folder as archives for both the Macintosh and Windows platforms:

  • The mm_jsapi.h header file includes definitions for the data types and functions that are described in C-level extensibility and the JavaScript interpreter.
  • The mm_jsapi_environment.h file defines the MM_Environment.h structure.
  • The MMInfo.h file provides access to the Design Notes API.
  • The Sample.c example file defines the computeSum() function.
  • The Sample.mak make file lets you build the Sample.c source file into a DLL with Microsoft Visual C++; Sample.mcp is the equivalent file for building a Mach-O Bundle with Metrowerks CodeWarrior and Sample.xcode is the equivalent file for Apple Xcode. If you use another tool, you can create the makefile.

Build the DLL in Windows using VS.Net 2003

  1. Use File > Open, and select Sample.mak with Files Of Type set to All Files (*.*). (VS.Net 2003 does not open MAK files directly). You are then prompted to verify that you want to convert the project to the new format.
  2. Select Build > Rebuild Solution.

When the build operation finishes, the Sample.dll file appears in the folder that contains Sample.mak (or one of its subfolders).

Build the DLL in Windows using Microsoft Visual C++

  1. In Microsoft Visual C++, select File > Open Workspace, and select Sample.mak.
  2. Select Build > Rebuild All.

When the build operation finishes, the Sample.dll file appears in the folder that contains Sample.mak (or one of its subfolders).

Build the shared library on the Macintosh using Metrowerks CodeWarrior 9 or later

  1. Open Sample.mcp.
  2. Build the project (Project > Make) to generate a Mach-O Bundle.

When the build operation finishes, the Sample.bundle file appears in the folder that contains Sample.mcp.

Note:The Mach-O Bundle that is generated can only be used in Dreamweaver 8 and later. Earlier versions of Dreamweaver do not recognize it.

Build the shared library on the Macintosh using Apple Xcode 1.5 or later

  1. Open Sample.xcode.
  2. Build the project (Build > Build) to generate a Mach-O Bundle.

When the build operation finishes, the Sample.bundle file appears in the build folder that is next to the Sample.xcode file.

Note:The Mach-O Bundle that is generated can only be used in Dreamweaver 8 and later. Earlier versions of Dreamweaver do not recognize it.

Call the computeSum() function from the Insert Horizontal Rule object

  1. Create a folder called JSExtensions in the Configuration folder within the Dreamweaver application folder.
  2. Copy Sample.dll (Windows) or Sample.bundle (Macintosh) to the JSExtensions folder.
  3. In a text editor, open the HR.htm file in the Configuration/Objects/Common folder.
  4. Add the line alert(Sample.computeSum(2,2)); to the objectTag() function, as shown in the following example:

    function objectTag() {
        // Return the html tag that should be inserted
        alert(Sample.computeSum(2,2));
        return "<HR>";
    }
  5. Save the file and restart Dreamweaver.

To execute the computeSum() function, select Insert > HTML > Horizontal Rule.

A dialog box that contains the number 4 (the result of computing the sum of 2 plus 2) appears.



标题:Calling a C function from JavaScript

原址:http://helpx.adobe.com/dreamweaver/extend/calling-c-function-javascript.html

时间: 2024-12-11 23:55:36

Dreamweaver 扩展开发: Calling a C++ function from JavaScript的相关文章

Dreamweaver 扩展开发:C-level extensibility and the JavaScript interpreter

The C code in your library must interact with the Dreamweaver JavaScript interpreter at the following different times: At startup, to register the library’s functions When the function is called, to parse the arguments that JavaScript is passing to C

Dreamweaver 扩展开发:文档路径等信息的处理

//browseFile(fieldToStoreURL){ //getFullPath(filePathURL){ //getSimpleFileName() { //fixUpPath(docURL,siteURL,savedPath) //fileIsCurrentlyOpen(absoluteFileURL); //Invokes dialog to allow user to select filename. Puts value in text input. // The optio

使用ClojureScript进行chrome扩展开发

*/--> pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src {background-color: #292b

Dreamweaver扩展及JavaScript性能调优

Dreamweaver曾经辉煌过,部分开发人员还在使用,毕竟十年前的技术了,不做深入研究.我打算对Dreamweaver扩展和JavaScript开发做一些整理. 主要内容: 1. 开发Extension的注意事项 2. 如何在Extension里面启动并调用JVM 3. 开发自己的工具 4. JavaScript性能调优 扩展开发注意事项 扩展(Extension),是应用程序给用户预留的二次开发接口.Dreamweaver提供了对菜单,插入栏(Insert),浮动框等GUI部件的扩展支持,使

Chrome浏览器扩展开发系列之十四:本地消息机制Native messagin

Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 2016-11-24 09:36 114人阅读 评论(0) 收藏 举报  分类: PPAPI(27)  通过将浏览器所在客户端的本地应用注册为Chrome浏览器扩展的"本地消息主机(native messaging host)",Chrome浏览器扩展还可以与客户端本地应用之间收发消息. 客户端的本地应用注册为Chrome浏览器扩展的"本地消息主机"之后,Chrome浏览器会在独立的

Chrome扩展开发之三——Chrome扩展中的数据本地存储和下载

目录: 0.Chrome扩展开发(Gmail附件管理助手)系列之〇——概述 1.Chrome扩展开发之一——Chrome扩展的文件结构 2.Chrome扩展开发之二——Chrome扩展中脚本的运行机制和通信方式 3.Chrome扩展开发之三——Chrome扩展中的数据本地存储和下载 4.Chrome扩展开发之四——Gmail API的简单介绍 5.Chrome扩展开发之五——OAuth2的理解 6.Chrome扩展开发之六——GmailAssist核心功能的实现(包括Gmail API的使用中的

【原创】PHP扩展开发入门

PHP扩展开发入门 作者:wf (360电商技术组) 在我们编写自己的第一个php扩展之前,先了解一下php的总体架构和执行机制. php的架构如图1所看到的. 当中一个重要的就是SAPI(server端应用编程端口),它使得PHP能够和其它应用进行数据交互,把外部错综复杂的外部环境进行抽象化,为内部的php提供一套固定和统一的接口.使得php自身不受外部影响,保持一定的独立性.常见的SAPI有CGI.FastCGI.Shell的CLI,apache的mod_php5,IIS的ISAPI. 另外

Chrome浏览器扩展开发系列之十四

Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59      阅读:1361      评论:0      收藏:0      [点我收藏+] 通过将浏览器所在客户端的本地应用注册为Chrome浏览器扩展的"本地消息主机(native messaging host)",Chrome浏览器扩展还可以与客户端本地应用之间收发消息. 客户端的本地应用注册为Chrome浏览器扩展的"本地消息主机"

常见浏览器扩展开发笔记(chrome firefox 360 baidu qq sougou liebao uc opera)

浏览器扩展开发貌似时下很冷门啊,但是不少企业还是有类似的应用,360的抢票插件啊,笔者最近在做的网页翻译扩展之类的.笔者在开发的过程中,遇到了不少坑,说是坑,说白了就是各个厂商支持的API不统一导致的. 经过总结,发现有三大阵营: Chrome系 Chrome 各种友好,你想要的API它基本都有,谁叫人是谷歌呢 360 国产浏览器中比较NB的,有极速和兼容2中模式,如果你开发完了chrome的扩展,直接copy过去,基本不用大改 Baidu qq浏览器,不予评价,论copy能力,马寨主手下的兄弟