]> gitweb @ CieloNegro.org - bindings-CarbonCore.git/commitdiff
MacTypes.h
authorPHO <pho@cielonegro.org>
Thu, 7 Oct 2010 16:13:36 +0000 (01:13 +0900)
committerPHO <pho@cielonegro.org>
Thu, 7 Oct 2010 16:13:36 +0000 (01:13 +0900)
.gitignore [new file with mode: 0644]
Bindings/CoreServices/CarbonCore/MacTypes.hsc [new file with mode: 0644]
COPYING [new file with mode: 0644]
GNUmakefile [new file with mode: 0644]
Setup.hs [new file with mode: 0644]
bindings-carbon-core.cabal [new file with mode: 0644]
cabal-package.mk [new file with mode: 0644]
cbits/helper_mactypes.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..f76a6e2
--- /dev/null
@@ -0,0 +1,5 @@
+*.hi
+*.o
+
+Setup
+dist
diff --git a/Bindings/CoreServices/CarbonCore/MacTypes.hsc b/Bindings/CoreServices/CarbonCore/MacTypes.hsc
new file mode 100644 (file)
index 0000000..109cef2
--- /dev/null
@@ -0,0 +1,244 @@
+#include <bindings.dsl.h>
+#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
+
+module Bindings.CoreServices.CarbonCore.MacTypes where
+#strict_import
+
+#integral_t UInt8
+#integral_t SInt8
+#integral_t UInt16
+#integral_t SInt16
+#integral_t UInt32
+#integral_t SInt32
+
+#starttype struct wide
+#  field hi, <SInt32>
+#  field lo, <UInt32>
+#stoptype
+
+#starttype struct UnsignedWide
+#  field hi, <UInt32>
+#  field lo, <UInt32>
+#stoptype
+
+#if TYPE_LONGLONG
+#  integral_t SInt64
+#  integral_t UInt64
+#else
+#  synonym_t SInt64, <wide>
+#  synonym_t UInt64, <UnsignedWide>
+#endif
+
+#integral_t Fixed
+#synonym_t  FixedPtr, Ptr <Fixed>
+#integral_t Fract
+#synonym_t  FractPtr, Ptr <Fract>
+#integral_t UnsignedFixed
+#synonym_t  UnsignedFixedPtr, Ptr <UnsignedFixed>
+#integral_t ShortFixed
+#synonym_t  ShortFixedPtr, Ptr <ShortFixed>
+
+#synonym_t Float32, CFloat
+#synonym_t Float64, CDouble
+
+#starttype struct Float80
+#  field       exp, <SInt16>
+#  array_field man, <UInt16>
+#stoptype
+
+#starttype struct Float96
+#  array_field exp, <SInt16>
+#  array_field man, <UInt16>
+#stoptype
+
+#starttype struct Float32Point
+#  field x, <Float32>
+#  field y, <Float32>
+#stoptype
+
+#synonym_t  Ptr   , Ptr CChar
+#synonym_t  Handle, Ptr <Ptr>
+#integral_t Size
+
+#integral_t OSErr
+#integral_t OSStatus
+#synonym_t  LogicalAddress     , Ptr ()
+#synonym_t  ConstLogicalAddress, Ptr ()
+#synonym_t  PhysicalAddress    , Ptr ()
+#synonym_t  BytePtr            , Ptr <UInt8>
+#integral_t ByteCount
+#integral_t ByteOffset
+#integral_t Duration
+#synonym_t  AbsoluteTime, <UnsignedWide>
+#integral_t OptionBits
+#integral_t ItemCount
+#integral_t PBVersion
+#integral_t ScriptCode
+#integral_t LangCode
+#integral_t RegionCode
+#integral_t FourCharCode
+#integral_t OSType
+#integral_t ResType
+#synonym_t  OSTypePtr , Ptr <OSType>
+#synonym_t  ResTypePtr, Ptr <ResType>
+
+#integral_t Boolean
+
+#callback  ProcPtr, IO CLong
+#callback  Register68kProcPtr, IO ()
+
+#if TARGET_RT_MAC_CFM
+#  error CFM Carbon is not supported.
+#else
+#  synonym_t UniversalProcPtr  , <ProcPtr>
+#endif
+
+#synonym_t ProcHandle         , Ptr <ProcPtr>
+#synonym_t UniversalProcHandle, Ptr <UniversalProcPtr>
+
+#synonym_t PRefCon, Ptr ()
+
+#if __LP64__
+#  synonym_t  URefCon, Ptr ()
+#  synonym_t  SRefCon, Ptr ()
+#else
+#  integral_t URefCon
+#  integral_t SRefCon
+#endif
+
+#num noErr
+#num kNilOptions
+#num kInvalidID
+#num kVariableLengthArray
+#num kUnknownType
+
+#integral_t UnicodeScalarValue
+#integral_t UTF32Char
+#integral_t UniChar
+#integral_t UTF16Char
+#integral_t UTF8Char
+#synonym_t  UniCharPtr, Ptr <UniChar>
+#integral_t UniCharCount
+#synonym_t  UniCharCountPtr , Ptr <UniCharCount>
+#synonym_t  Str255          , Ptr CUChar
+#synonym_t  Str63           , Ptr CUChar
+#synonym_t  Str32           , Ptr CUChar
+#synonym_t  Str31           , Ptr CUChar
+#synonym_t  Str27           , Ptr CUChar
+#synonym_t  Str15           , Ptr CUChar
+#synonym_t  Str32Field      , Ptr CUChar
+#synonym_t  StrFileName     , <Str63>
+#synonym_t  StringPtr       , Ptr CUChar
+#synonym_t  StringHandle    , Ptr <StringPtr>
+#synonym_t  ConstStringPtr  , Ptr CUChar
+#synonym_t  ConstStr255Param, Ptr CUChar
+#synonym_t  ConstStr63Param , Ptr CUChar
+#synonym_t  ConstStr32Param , Ptr CUChar
+#synonym_t  ConstStr31Param , Ptr CUChar
+#synonym_t  ConstStr27Param , Ptr CUChar
+#synonym_t  ConstStr15Param , Ptr CUChar
+#synonym_t  ConstStrFileNameParam, <ConstStr63Param>
+
+#cinline StrLength, <ConstStr255Param> -> IO CUChar
+
+#starttype struct ProcessSerialNumber
+#  field highLongOfPSN, <UInt32>
+#  field lowLongOfPSN , <UInt32>
+#stoptype
+#synonym_t ProcessSerialNumberPtr, Ptr <ProcessSerialNumber>
+
+#starttype struct Point
+#  field v, CShort
+#  field h, CShort
+#stoptype
+#synonym_t PointPtr, Ptr <Point>
+
+#starttype struct Rect
+#  field top   , CShort
+#  field left  , CShort
+#  field bottom, CShort
+#  field right , CShort
+#stoptype
+#synonym_t RectPtr, Ptr <Rect>
+
+#starttype struct FixedPoint
+#  field x, <Fixed>
+#  field y, <Fixed>
+#stoptype
+
+#starttype struct FixedRect
+#  field top   , <Fixed>
+#  field left  , <Fixed>
+#  field bottom, <Fixed>
+#  field right , <Fixed>
+#stoptype
+
+#integral_t CharParameter
+#num normal
+#num bold
+#num italic
+#num underline
+#num outline
+#num shadow
+#num condense
+#num extend
+
+#integral_t Style
+#integral_t StyleParameter
+#synonym_t  StyleField, <Style>
+
+#synonym_t TimeValue    , <SInt32>
+#synonym_t TimeScale    , <SInt32>
+#synonym_t CompTimeValue, <wide>
+#synonym_t TimeValue64  , <SInt64>
+
+#opaque_t  TimeBaseRecord
+#synonym_t TimeBase, Ptr <TimeBaseRecord>
+
+#starttype TimeRecord
+#  field value, <CompTimeValue>
+#  field scale, <TimeScale>
+#  field base , <TimeBase>
+#stoptype
+
+#starttype struct NumVersion
+#  field majorRev      , <UInt8>
+#  field minorAndBugRev, <UInt8>
+#  field stage         , <UInt8>
+#  field nonRelRev     , <UInt8>
+#stoptype
+
+#num developStage
+#num alphaStage
+#num betaStage
+#num finalStage
+
+#starttype union NumVersionVariant
+#  union_field parts, <NumVersion>
+#  union_field whole, <UInt32>
+#stoptype
+#synonym_t NumVersionVariantPtr   , Ptr <NumVersionVariant>
+#synonym_t NumVersionVariantHandle, Ptr <NumVersionVariantPtr>
+
+#starttype struct VersRec
+#  field numericVersion, <NumVersion>
+#  field countryCode   , CShort
+#  field shortVersion  , <Str255>
+#  field reserved      , <Str255>
+#stoptype
+#synonym_t VersRecPtr , Ptr <VersRec>
+#synonym_t VersRecHndl, Ptr <VersRecPtr>
+
+#synonym_t Byte           , <UInt8>
+#synonym_t SignedByte     , <SInt8>
+#synonym_t WidePtr        , Ptr <wide>
+#synonym_t UnsignedWidePtr, Ptr <UnsignedWide>
+#synonym_t extended80     , <Float80>
+#synonym_t extended96     , <Float96>
+#synonym_t VHSelect       , <SInt8>
+
+#ccall Debugger    , IO ()
+#ccall DebugStr    , <ConstStr255Param> -> IO ()
+#ccall SysBreak    , IO ()
+#ccall SysBreakStr , <ConstStr255Param> -> IO ()
+#ccall SysBreakFunc, <ConstStr255Param> -> IO ()
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..0294a58
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,29 @@
+<!-- -*- xml -*-
+
+bindings-carbon-core はパブリックドメインに在ります。
+bindings-carbon-core is in the public domain.
+
+See http://creativecommons.org/licenses/publicdomain/
+
+-->
+
+<rdf:RDF xmlns="http://web.resource.org/cc/"
+            xmlns:dc="http://purl.org/dc/elements/1.1/"
+            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+  <Work rdf:about="http://cielonegro.org/Bindings-CarbonCore.html">
+       <dc:title>bindings-carbon-core</dc:title>
+       <dc:rights>
+      <Agent>
+           <dc:title>PHO</dc:title>
+         </Agent>
+    </dc:rights>
+       <license rdf:resource="http://web.resource.org/cc/PublicDomain" />
+  </Work>
+      
+  <License rdf:about="http://web.resource.org/cc/PublicDomain">
+       <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
+       <permits rdf:resource="http://web.resource.org/cc/Distribution" />
+       <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+  </License>
+
+</rdf:RDF>
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644 (file)
index 0000000..15098cd
--- /dev/null
@@ -0,0 +1,5 @@
+#RUN_COMMAND = $(MAKE) -C examples run
+
+CONFIGURE_ARGS = -O
+
+include cabal-package.mk
diff --git a/Setup.hs b/Setup.hs
new file mode 100644 (file)
index 0000000..bd92fff
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,4 @@
+#!/usr/bin/env runghc
+
+import Distribution.Simple
+main = defaultMain
diff --git a/bindings-carbon-core.cabal b/bindings-carbon-core.cabal
new file mode 100644 (file)
index 0000000..2ad84ab
--- /dev/null
@@ -0,0 +1,38 @@
+Name: bindings-carbon-core
+Synopsis: Low level bindings to Apple's CarbonCore Framework
+Description:
+        Bindings to Apple's CarbonCore Framework
+Version: 0.1
+License: PublicDomain
+License-File: COPYING
+Author: PHO <pho at cielonegro dot org>
+Maintainer: PHO <pho at cielonegro dot org>
+Stability: experimental
+Homepage: http://cielonegro.org/Bindings-CarbonCore.html
+Category: FFI
+Tested-With: GHC == 6.12.3
+Cabal-Version: >= 1.6
+Build-Type: Simple
+Extra-Source-Files:
+    COPYING
+
+Source-Repository head
+    Type: git
+    Location: git://git.cielonegro.org/bindings-carbon-core.git
+
+Library
+    Build-Depends:
+        base         == 4.2.*,
+        bindings-DSL == 1.0.*
+
+    Frameworks:
+        CoreServices
+
+    Exposed-Modules:
+        Bindings.CoreServices.CarbonCore.MacTypes
+
+    C-Sources:
+        cbits/helper_mactypes.c
+
+    Extensions:
+        ForeignFunctionInterface
diff --git a/cabal-package.mk b/cabal-package.mk
new file mode 100644 (file)
index 0000000..d8bbaad
--- /dev/null
@@ -0,0 +1,95 @@
+# -*- makefile-gmake -*-
+#
+# Variables:
+#
+#   CONFIGURE_ARGS :: arguments to be passed to ./Setup configure
+#     default: --disable-optimization
+#
+#   RUN_COMMAND :: command to be run for "make run"
+#
+
+GHC      ?= ghc
+FIND     ?= find
+RM_RF    ?= rm -rf
+SUDO     ?= sudo
+AUTOCONF ?= autoconf
+HLINT    ?= hlint
+
+CONFIGURE_ARGS ?= --disable-optimization
+
+SETUP_FILE := $(wildcard Setup.*hs)
+CABAL_FILE := $(wildcard *.cabal)
+
+ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
+  AUTOCONF_AC_FILE := configure.ac
+  AUTOCONF_FILE    := configure
+else
+  ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
+    AUTOCONF_AC_FILE := configure.in
+    AUTOCONF_FILE    := configure
+  else
+    AUTOCONF_AC_FILE :=
+    AUTOCONF_FILE    :=
+  endif
+endif
+
+BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
+BUILDINFO_FILE    := $(BUILDINFO_IN_FILE:.in=)
+
+all: build
+
+build: setup-config build-hook
+       ./Setup build
+
+build-hook:
+
+ifeq ($(RUN_COMMAND),)
+run:
+       @echo "cabal-package.mk: No command to run."
+       @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
+else
+run: build
+       @echo ".:.:. Let's go .:.:."
+       $(RUN_COMMAND)
+endif
+
+setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
+
+setup-config-hook:
+
+dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
+       ./Setup configure $(CONFIGURE_ARGS)
+
+$(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
+       $(AUTOCONF)
+
+$(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
+       ./Setup configure $(CONFIGURE_ARGS)
+
+Setup: $(SETUP_FILE)
+       $(GHC) --make Setup
+
+clean: clean-hook
+       $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo
+       $(FIND) . -name '*~' -exec rm -f {} \;
+
+clean-hook:
+
+doc: setup-config
+       ./Setup haddock
+
+install: build
+       $(SUDO) ./Setup install
+
+sdist: setup-config
+       ./Setup sdist
+
+test: build
+       ./Setup test
+
+lint:
+       $(HLINT) . --report \
+               --ignore="Use string literal" \
+               --ignore="Use concatMap"
+
+.PHONY: build build-hook setup-config setup-config-hook run clean clean-hook install doc sdist test lint
diff --git a/cbits/helper_mactypes.c b/cbits/helper_mactypes.c
new file mode 100644 (file)
index 0000000..fbb4489
--- /dev/null
@@ -0,0 +1,4 @@
+#include <bindings.cmacros.h>
+#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
+
+BC_INLINE1(StrLength, ConstStr255Param, unsigned char)