Dreamweaver extended development: Calling a C + + function from JavaScript

Source: Internet
Author: User
Tags dreamweaver codewarrior

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

The following example requires the following five files, located in the Dreamweaver-application-folder/tutorial_assets/ex Tending 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 is described in C-level Extensibili Ty 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 your 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 are the Equival ent 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 were then prompted to verify so 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 SUBFO Lders).

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 SUBFO Lders).

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 is generated can, 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's next to the Sample.xcode fil E.

Note: The Mach-o Bundle is generated can, 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 () {     //    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.

Title: Calling a C function from JavaScript

Original site: http://helpx.adobe.com/dreamweaver/extend/calling-c-function-javascript.html

Dreamweaver extended development: Calling a C + + function from JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.