From 9da32ae8be205781e0e54f8cba574a9a2c432883 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 25 Mar 2002 01:24:35 +0000 Subject: [PATCH 1/1] r1654: Added atoifl example --- examples/atoifl.cl | 36 ++++++++++++++++++++++++++++++++++++ test-examples.cl | 3 ++- tests/atoifl.cl | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 examples/atoifl.cl create mode 100644 tests/atoifl.cl diff --git a/examples/atoifl.cl b/examples/atoifl.cl new file mode 100644 index 0000000..d6e48fd --- /dev/null +++ b/examples/atoifl.cl @@ -0,0 +1,36 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: atoifl.cl +;;;; Purpose: UFFI Example file to atoi/atof/atol +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Mar 2002 +;;;; +;;;; $Id: atoifl.cl,v 1.1 2002/03/25 01:24:35 kevin Exp $ +;;;; +;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; +;;;; UFFI users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* + +(in-package :cl-user) + +(uffi:def-function ("atoi" c-atoi) + ((str :cstring)) + :returning :int) + +(defun atoi (str) + "Returns a int from a string." + (uffi:with-cstring (str-cstring str) + (c-atoi str-cstring))) + +#+test-uffi +(progn + (flet ((print-results (str) + (format t "~&(atoi ~S) => ~S" str (atoi str)))) + (print-results "55"))) + + diff --git a/test-examples.cl b/test-examples.cl index 301e9cd..4d1dcbf 100644 --- a/test-examples.cl +++ b/test-examples.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: test-examples.cl,v 1.7 2002/03/21 07:56:45 kevin Exp $ +;;;; $Id: test-examples.cl,v 1.8 2002/03/25 01:24:35 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -31,6 +31,7 @@ (load-test "arrays") (load-test "union") (load-test "strtol") + (load-test "atoifl") (load-test "gettime") (load-test "getenv") (load-test "gethostname") diff --git a/tests/atoifl.cl b/tests/atoifl.cl new file mode 100644 index 0000000..d6e48fd --- /dev/null +++ b/tests/atoifl.cl @@ -0,0 +1,36 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: atoifl.cl +;;;; Purpose: UFFI Example file to atoi/atof/atol +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Mar 2002 +;;;; +;;;; $Id: atoifl.cl,v 1.1 2002/03/25 01:24:35 kevin Exp $ +;;;; +;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; +;;;; UFFI users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* + +(in-package :cl-user) + +(uffi:def-function ("atoi" c-atoi) + ((str :cstring)) + :returning :int) + +(defun atoi (str) + "Returns a int from a string." + (uffi:with-cstring (str-cstring str) + (c-atoi str-cstring))) + +#+test-uffi +(progn + (flet ((print-results (str) + (format t "~&(atoi ~S) => ~S" str (atoi str)))) + (print-results "55"))) + + -- 2.34.1