~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to src/c-parserlib.stub

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;; -*- coding: utf-8; mode: scheme -*-
 
2
;;
 
3
;; c-parserlib.stub
 
4
;; 
 
5
;;  Copyright (c) 2006 KOGURO, Naoki (naoki@koguro.net)
 
6
;; 
 
7
;;  Permission is hereby granted, free of charge, to any person 
 
8
;;  obtaining a copy of this software and associated 
 
9
;;  documentation files (the "Software"), to deal in the 
 
10
;;  Software without restriction, including without limitation 
 
11
;;  the rights to use, copy, modify, merge, publish, distribute, 
 
12
;;  sublicense, and/or sell copies of the Software, and to 
 
13
;;  permit persons to whom the Software is furnished to do so, 
 
14
;;  subject to the following conditions:
 
15
;; 
 
16
;;  The above copyright notice and this permission notice shall 
 
17
;;  be included in all copies or substantial portions of the 
 
18
;;  Software.
 
19
;; 
 
20
;;  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 
 
21
;;  KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
 
22
;;  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 
23
;;  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 
 
24
;;  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
 
25
;;  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
 
26
;;  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 
27
;;  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
28
;; 
 
29
;;  $Id: ffilib.stub 310 2006-08-17 15:00:58Z naoki $
 
30
 
 
31
"
 
32
#include \"c-parser.h\"
 
33
"
 
34
;;
 
35
;; strtoll, strtod
 
36
;;
 
37
(define-cproc strtoll (nptr::<const-cstring>)
 
38
  (code "char *endptr = NULL;"
 
39
        "long long v = strtoll(nptr, &endptr, 0);"
 
40
        "if (nptr == endptr) {"
 
41
        "    SCM_RETURN(SCM_FALSE);"
 
42
        "} else {"
 
43
        "    SCM_RETURN(Scm_MakeInteger64((ScmInt64) v));"
 
44
        "}"))
 
45
 
 
46
(define-cproc strtod (nptr::<const-cstring>)
 
47
  (code "char *endptr = NULL;"
 
48
        "double v = strtod(nptr, &endptr);"
 
49
        "if (nptr == endptr) {"
 
50
        "    SCM_RETURN(SCM_FALSE);"
 
51
        "} else {"
 
52
        "    SCM_RETURN(Scm_MakeFlonum(v));"
 
53
        "}"))
 
54
 
 
55
;; Local variables:
 
56
;; mode: scheme
 
57
;; end: