Package c-delegate

Solution to "Link C++ - SKILL"

Author

Damien Diederen  <dd@crosstwine.com>

Overview

Cf. http://www.cadence.com/Community/forums/p/24699/1318711.aspx#1318711.

The goal of this small package is to demonstrate communication between SKILL and an external executable program (the "delegate").

Inputs are passed as command-line arguments, results are parsed out from the delegate's standard output. The delegate is written in C, and can be found in the c-delegate.c source file. It must be compiled prior to use; e.g. by running:

$ make CC=<your-c-compiler> CFLAGS=<your-c-flags>

from the package's directory.

The main entry point is MyInvokeCDelegate; here are basic usage instructions:

$ $CDSHOME/tools/dfII/bin/skill
(load "pkg/c-delegate/c-delegate.ils")
|- t
(MyInvokeCDelegate 1.1 1.2 1.3 1.4 5)
|- ((1.1 1.2)
|   (2.4 2.6)
|   (3.7 4.0)
|   (5.0 5.4)
|   (6.3 6.8))

This has been tested on a Linux box, using Veda 0.2.0 (http://crosstwine.com/veda/):

$ make
cc  -o c-delegate c-delegate.c
$ veda test-package
    Testing c-delegate
=== RUN Test_InvokeCDelegate
--- PASS: Test_InvokeCDelegate

Index

Unexported variable cDelegate
Unexported variable thisFilename
Unexported function FindSibling (filename)
Function MyInvokeCDelegate (x0 y0 dx dy steps)
Unexported function ParseFloatPair (string)
Unexported function PrepareCommand (x0 y0 dx dy steps)

Package files

c-delegate.ils

Details

Unexported variable cDelegate

(define cDelegate ...)

The base name of the executable to invoke.

Unexported variable thisFilename

(define thisFilename ...)

The full path to this SKILL++ file, as seen by (load "..."); used by FindSibling.

Unexported function FindSibling

(defun FindSibling (filename) ...)

FindSibling returns the complete path to filename, which is a sibling to this file, or nil if no such readable file could be found.

Function MyInvokeCDelegate (exported)

(defun InvokeCDelegate (x0 y0 dx dy steps) ...)

InvokeCDelegate passes its arguments to an external program which implements an extremely complicated algorithm involving legacy code, and which cannot possibly be rewritten in SKILL(++).

See that program's detailed documentation for more information.

This function takes care of the I/O, and parses the results back into a list of 2-lists of floating-point values.

Unexported function ParseFloatPair

(defun ParseFloatPair (string) ...)

ParseFloatPair expects two (and exactly two) whitespace-separated, atof-parseable values in string, and returns them as a SKILL list of floating-point values.

It returns nil on failure.

Unexported function PrepareCommand

(defun PrepareCommand (x0 y0 dx dy steps) ...)

PrepareCommand builds the command line to be used to invoke the delegate. It takes the same arguments as InvokeCDelegate, and massages them into string form.