PLT Foreign Interface Manual

How to Design Programs: An Introduction to Programming and Computing

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: PLT Foreign Interface Manual PLT (scheme@plt-scheme.org) 372 Released December 2007 Copyright notice Copyright c 1996-2007 PLT Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Library General Public License, Version 2 published by the Free Software Foundation. A copy of the license is included in the appendix entitled License. Contents 1 Introduction 1 2 Loading Foreign Libraries 2 3 C Types 4 3.1 Numeric Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.2 Other Atomic Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3 String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3.1 Primitive String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3.2 Fixed Auto-Converting String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.3.3 Variable Auto-Converting String Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.3.4 Other String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.4 Pointer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.5 Function Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.5.1 Custom Function Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.6 C Struct Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.6.1 C Struct Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.7 Enumerations and Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4 Pointer Functions 14 4.1 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5 Derived Utilities 18 5.1 Tagged C Pointer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.2 Safe C Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 5.3 SRFI-4 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 i CONTENTS CONTENTS 6 Miscellaneous Support 21 7 Unexported Primitive Functions 22 License 23 Index 27 ii 1. Introduction The foreign.ss library enables the direct use of C-based APIs within Scheme programs (i.e., without writing any new C code). From the Scheme perspective, functions and data with a C-based API are foreign , hence the term foreign interface . Furthermore, since most APIs consist mostly of functions, the foreign interface is sometimes called a foreign function interface , abbreviated FFI ....
View Full Document

Page1 / 32

PLT Foreign Interface Manual - PLT Foreign Interface Manual...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online