[Liblas-commits] libpc: start at bindings
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 2 23:43:44 EST 2011
details: http://hg.liblas.orglibpc/rev/735337180ebd
changeset: 158:735337180ebd
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Mar 02 20:43:42 2011 -0800
description:
start at bindings
diffstat:
csharp/README.txt | 45 +
csharp/libpc_swig_cpp/libpc.i | 130 +
csharp/libpc_swig_cpp/libpc_wrap.cpp | 1722 +++++++++++++++++++++
csharp/libpc_swig_cs/Dimension.cs | 179 ++
csharp/libpc_swig_cs/Properties/AssemblyInfo.cs | 36 +
csharp/libpc_swig_cs/VectorU32.cs | 349 ++++
csharp/libpc_swig_cs/VectorU8.cs | 349 ++++
csharp/libpc_swig_cs/libpc_swig_cpp.cs | 17 +
csharp/libpc_swig_cs/libpc_swig_cppPINVOKE.cs | 427 +++++
csharp/libpc_swig_cs/libpc_swig_cs.csproj | 105 +
csharp/libpc_swig_test/Program.cs | 70 +
csharp/libpc_swig_test/Properties/AssemblyInfo.cs | 36 +
csharp/libpc_swig_test/TestDimension.cs | 28 +
csharp/libpc_swig_test/libpc_swig_test.csproj | 96 +
14 files changed, 3589 insertions(+), 0 deletions(-)
diffs (truncated from 3647 to 300 lines):
diff -r 11e7f5485f7e -r 735337180ebd csharp/README.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/README.txt Wed Mar 02 20:43:42 2011 -0800
@@ -0,0 +1,45 @@
+README for libPC C# Support
+===========================
+
+ *** UNDER DEVELOPMENT *** (proceed with caution)
+
+This directory contains the code needed to create C# bindings and the pcview
+app for libPC.
+
+If questions, contact mpg at flaxen.com.
+
+The C# work does not use CMake, as CMake doesn't yet support C# builds.
+
+
+* The solution file libpc_swig.sln has three projects:
+ - libpc_swig_cpp
+ . runs swig on the .i file
+ - creates the .cpp wrapper file
+ - creates the .cs wrapper classes
+ . compiles the .cpp wrapper file
+ . creates libpc_swig_cpp.dll
+ - libpc_swig_cs
+ . compiled the .cs wrapper classes
+ . creates libpc_swig_cs.dll
+ - libpc_swig_test
+ . compiles a simple test app to verify the bindings work
+ . creates swig_test.exe
+
+
+* The two DLLs and the EXE are put into the main libpc bin directory, for ease of use.
+
+
+* Only Visual Studio 2010 is supported. Four build configurations are possible:
+ - x86/Debug
+ - x86/Release
+ - x64/Debug
+ - x64/Release
+Of these four, only x64/Debug has actually been tested :-)
+
+There seems to be an issue with running swig-generated code in x86 mode on a
+64-bit OS, and the examples that ship with swig bear this out. I'm not sure
+what's up with that. See this thread:
+ http://old.nabble.com/SWIG-examples-will-not-run-on-my-windows-7---64-bits-td29085404.html
+
+
+* The test app should be run from the csharp/libpc-swig-test directory.
diff -r 11e7f5485f7e -r 735337180ebd csharp/libpc_swig_cpp/libpc.i
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/libpc_swig_cpp/libpc.i Wed Mar 02 20:43:42 2011 -0800
@@ -0,0 +1,130 @@
+/******************************************************************************
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: swig/C# bindings for liblas
+ * Author: Michael P. Gerlek (mpg at flaxen.com)
+ *
+ ******************************************************************************
+ * Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+%module libpc_swig_cpp
+
+%{
+#include "libpc/libpc_config.hpp"
+#include "libpc/Dimension.hpp"
+%}
+
+%include "typemaps.i"
+
+// C# support for std::string
+%include "std_string.i"
+
+// C# support for std::vector<T>
+%include "std_vector.i"
+namespace std {
+ %template(VectorU8) vector<unsigned char>;
+ %template(VectorU32) vector<unsigned int>;
+};
+
+
+// fix up some missing types
+namespace std
+{
+ typedef unsigned int size_t;
+};
+
+namespace boost
+{
+ typedef unsigned char uint8_t;
+ typedef signed char int8_t;
+ typedef unsigned short uint16_t;
+ typedef signed short int16_t;
+ typedef unsigned int uint32_t;
+ typedef signed int int32_t;
+};
+
+// BUG: how do I do a rename such that "SWIGTYPE_p_std__istream" can
+// become something like "IStreamHandle"?
+
+namespace libpc
+{
+
+class Dimension
+{
+public:
+ enum DataType
+ {
+ Int8,
+ Uint8,
+ Int16,
+ Uint16,
+ Int32,
+ Uint32,
+ Int64,
+ Uint64,
+ Float, // 32 bits
+ Double // 64 bits
+ };
+
+public:
+ Dimension(std::string const& name, DataType type);
+ inline std::string const& getName() const;
+ DataType getDataType() const;
+ static std::string getDataTypeName(DataType);
+ static DataType getDataTypeFromString(const std::string&);
+ static std::size_t getDataTypeSize(DataType);
+ static bool getDataTypeIsNumeric(DataType);
+ static bool getDataTypeIsSigned(DataType);
+ static bool getDataTypeIsInteger(DataType);
+ std::size_t getByteSize() const;
+ inline std::string getDescription() const;
+ inline void setDescription(std::string const& v);
+ inline bool isNumeric() const;
+ inline bool isSigned() const;
+ inline bool isInteger() const;
+ inline double getMinimum() const;
+ inline void setMinimum(double min);
+ inline double getMaximum() const;
+ inline void setMaximum(double max);
+ inline double getNumericScale() const;
+ inline void setNumericScale(double v);
+ inline double getNumericOffset() const;
+ inline void setNumericOffset(double v);
+ inline bool isFinitePrecision() const;
+ inline void isFinitePrecision(bool v);
+};
+
+
+
+}; // namespace
diff -r 11e7f5485f7e -r 735337180ebd csharp/libpc_swig_cpp/libpc_wrap.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/libpc_swig_cpp/libpc_wrap.cpp Wed Mar 02 20:43:42 2011 -0800
@@ -0,0 +1,1722 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.1
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGCSHARP
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+ struct SwigMovePointer {
+ T *ptr;
+ SwigMovePointer(T *p) : ptr(p) { }
+ ~SwigMovePointer() { delete ptr; }
+ SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+ } pointer;
+ SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+ SwigValueWrapper() : pointer(0) { }
+ SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+ operator T&() const { return *pointer.ptr; }
+ T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+ return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
More information about the Liblas-commits
mailing list