Skip to content

Instantly share code, notes, and snippets.

@ng420
Created July 28, 2016 19:05
Show Gist options
  • Save ng420/9d8297ba33b337e956a2fdfa121e5596 to your computer and use it in GitHub Desktop.
Save ng420/9d8297ba33b337e956a2fdfa121e5596 to your computer and use it in GitHub Desktop.
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.11
*
* 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.
* ----------------------------------------------------------------------------- */
#include "hphp/runtime/ext/extension.h"
#include "hphp/runtime/base/execution-context.h"
#include "hphp/runtime/vm/native-data.h"
#include "hphp/runtime/vm/native-prop-handler.h"
#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 defined(__GNUC__)
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif
# endif
#endif
#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(STATIC_LINKED)
# define SWIGEXPORT
# else
# define SWIGEXPORT __declspec(dllexport)
# endif
# else
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
# define SWIGEXPORT __attribute__ ((visibility("default")))
# else
# define SWIGEXPORT
# endif
# endif
#endif
/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
# endif
#endif
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#endif
/* Intel's compiler complains if a variable which was never initialised is
* cast to void, which is a common idiom which we use to indicate that we
* are aware a variable isn't used. So we just silence that warning.
* See: https://github.com/swig/swig/issues/192 for more discussion.
*/
#ifdef __INTEL_COMPILER
# pragma warning disable 592
#endif
namespace HPHP {
namespace {
template<typename T>
struct SWIG_Ptr : public SweepableResourceData {
private:
T* m_ptr;
public:
DECLARE_RESOURCE_ALLOCATION(SWIG_Ptr)
CLASSNAME_IS("SWIG_Ptr")
const String& o_getClassNameHook() const override { return classnameof(); }
explicit SWIG_Ptr(T* ptr) : m_ptr(ptr) {}
virtual ~SWIG_Ptr() { close(); }
void close() {
m_ptr = nullptr;
}
T* get() const { return m_ptr; }
};
template<typename T> inline void SWIG_Ptr<T>::sweep() { close(); }
}
}
#include "example.h"
Vector addv(Vector &a, Vector &b) {
return a+b;
}
SWIGINTERN Vector &VectorArray_get(VectorArray *self,int index){
printf("VectorArray extended get: %p %d\n", (void *)self, index);
return (*self)[index];
}
SWIGINTERN void VectorArray_set(VectorArray *self,int index,Vector &a){
(*self)[index] = a;
}
class _wrap_Vector {
public:
void sweep() {
if (!isRef) {
delete _obj_ptr;
}
_obj_ptr = nullptr;
}
~_wrap_Vector() { sweep(); }
Vector* _obj_ptr;
bool isRef{false};
}; // class _wrap_Vector
class _wrap_VectorArray {
public:
void sweep() {
if (!isRef) {
delete _obj_ptr;
}
_obj_ptr = nullptr;
}
~_wrap_VectorArray() { sweep(); }
VectorArray* _obj_ptr;
bool isRef{false};
}; // class _wrap_VectorArray
SWIGINTERN
HPHP::Object _wrap_new_Vector(double targ1, double targ2, double targ3) {
double arg1 ;
double arg2 ;
double arg3 ;
HPHP::Object tresult ;
Vector *result = 0 ;
arg1 = (double)targ1;
arg2 = (double)targ2;
arg3 = (double)targ3;
result = (Vector *)new Vector(arg1,arg2,arg3);
auto result_cls = HPHP::Unit::lookupClass(HPHP::makeStaticString("Vector"));
tresult = HPHP::Object(result_cls);
auto wrap_result = HPHP::Native::data<_wrap_Vector>(tresult);
wrap_result->_obj_ptr = result;
wrap_result->isRef = true;
return tresult;
}
SWIGINTERN
void _wrap_delete_Vector(const HPHP::Object& targ1) {
Vector *arg1 = (Vector *) 0 ;
arg1 = HPHP::Native::data<_wrap_Vector>(targ1)->_obj_ptr;
delete arg1;
}
SWIGINTERN
HPHP::String _wrap_Vector_as_string(const HPHP::Object& targ1) {
Vector *arg1 = (Vector *) 0 ;
HPHP::String tresult ;
char *result = 0 ;
arg1 = HPHP::Native::data<_wrap_Vector>(targ1)->_obj_ptr;
result = (char *)(arg1)->as_string();
tresult = HPHP::String(result, HPHP::CopyString);
return tresult;
}
SWIGINTERN
HPHP::Object _wrap_addv(HPHP::VRefParam targ1, HPHP::VRefParam targ2) {
Vector *arg1 = 0 ;
Vector *arg2 = 0 ;
HPHP::Object tresult ;
SwigValueWrapper< Vector > result;
arg1 = HPHP::Native::data<_wrap_Vector>(targ1.toObject())->_obj_ptr;
arg2 = HPHP::Native::data<_wrap_Vector>(targ2.toObject())->_obj_ptr;
result = addv(*arg1,*arg2);
auto cls = HPHP::Unit::lookupClass(HPHP::makeStaticString("Vector"));
tresult = HPHP::Object(cls);
auto wrap_result = HPHP::Native::data<_wrap_Vector>(tresult);
wrap_result->_obj_ptr = new Vector((const Vector &) result);
return tresult;
}
SWIGINTERN
HPHP::Object _wrap_new_VectorArray(int64_t targ1) {
int arg1 ;
HPHP::Object tresult ;
VectorArray *result = 0 ;
arg1 = (int)targ1;
result = (VectorArray *)new VectorArray(arg1);
auto result_cls = HPHP::Unit::lookupClass(HPHP::makeStaticString("VectorArray"));
tresult = HPHP::Object(result_cls);
auto wrap_result = HPHP::Native::data<_wrap_VectorArray>(tresult);
wrap_result->_obj_ptr = result;
wrap_result->isRef = true;
return tresult;
}
SWIGINTERN
void _wrap_delete_VectorArray(const HPHP::Object& targ1) {
VectorArray *arg1 = (VectorArray *) 0 ;
arg1 = HPHP::Native::data<_wrap_VectorArray>(targ1)->_obj_ptr;
delete arg1;
}
SWIGINTERN
int64_t _wrap_VectorArray_size(const HPHP::Object& targ1) {
VectorArray *arg1 = (VectorArray *) 0 ;
int64_t tresult ;
int result;
arg1 = HPHP::Native::data<_wrap_VectorArray>(targ1)->_obj_ptr;
result = (int)(arg1)->size();
tresult = result;
return tresult;
}
SWIGINTERN
HPHP::Variant _wrap_VectorArray_get(const HPHP::Object& targ1, int64_t targ2) {
VectorArray *arg1 = (VectorArray *) 0 ;
int arg2 ;
HPHP::Variant tresult ;
Vector *result = 0 ;
arg1 = HPHP::Native::data<_wrap_VectorArray>(targ1)->_obj_ptr;
arg2 = (int)targ2;
result = (Vector *) &VectorArray_get(arg1,arg2);
auto result_cls = HPHP::Unit::lookupClass(HPHP::makeStaticString("Vector"));
tresult = HPHP::Object(result_cls);
auto wrap_result = HPHP::Native::data<_wrap_Vector>(tresult.toObject());
wrap_result->_obj_ptr = result;
wrap_result->isRef = true;
return tresult;
}
SWIGINTERN
void _wrap_VectorArray_set(const HPHP::Object& targ1, int64_t targ2, HPHP::VRefParam targ3) {
VectorArray *arg1 = (VectorArray *) 0 ;
int arg2 ;
Vector *arg3 = 0 ;
arg1 = HPHP::Native::data<_wrap_VectorArray>(targ1)->_obj_ptr;
arg2 = (int)targ2;
arg3 = HPHP::Native::data<_wrap_Vector>(targ3.toObject())->_obj_ptr;
VectorArray_set(arg1,arg2,*arg3);
}
namespace HPHP {
void HHVM_METHOD(_wrap_Vector, __construct, double arg1, double arg2, double arg3) {
auto data = Object(this_);
auto new_obj = _wrap_new_Vector(arg1, arg2, arg3);
Vector *result;
result = HPHP::Native::data<_wrap_Vector>(new_obj)->_obj_ptr;
Native::data<_wrap_Vector>(this_)->_obj_ptr = result;
Native::data<_wrap_Vector>(this_)->isRef = false;
}
void HHVM_METHOD(_wrap_Vector, __destruct) {
auto data = Object(this_);
if (!Native::data<_wrap_Vector>(this_)->isRef)
_wrap_delete_Vector(data);
}
HPHP::String HHVM_METHOD(_wrap_Vector, as_string) {
auto data = Object(this_);
return _wrap_Vector_as_string(data);
}
static Native::PropAccessor Vector_properties[] {
{ nullptr }
};
static Native::PropAccessorMap Vector_properties_map{ Vector_properties };
struct VectorPropHandler : public Native::MapPropHandler<VectorPropHandler> {
static constexpr Native::PropAccessorMap& map = Vector_properties_map;
};
HPHP::Object HHVM_FUNCTION(addv, HPHP::VRefParam arg1, HPHP::VRefParam arg2) {
return _wrap_addv(arg1, arg2);
}
void HHVM_METHOD(_wrap_VectorArray, __construct, int64_t arg1) {
auto data = Object(this_);
auto new_obj = _wrap_new_VectorArray(arg1);
VectorArray *result;
result = HPHP::Native::data<_wrap_VectorArray>(new_obj)->_obj_ptr;
Native::data<_wrap_VectorArray>(this_)->_obj_ptr = result;
Native::data<_wrap_VectorArray>(this_)->isRef = false;
}
void HHVM_METHOD(_wrap_VectorArray, __destruct) {
auto data = Object(this_);
if (!Native::data<_wrap_VectorArray>(this_)->isRef)
_wrap_delete_VectorArray(data);
}
int64_t HHVM_METHOD(_wrap_VectorArray, size) {
auto data = Object(this_);
return _wrap_VectorArray_size(data);
}
HPHP::Variant HHVM_METHOD(_wrap_VectorArray, get, int64_t arg2) {
auto data = Object(this_);
return _wrap_VectorArray_get(data, arg2);
}
void HHVM_METHOD(_wrap_VectorArray, set, int64_t arg2, HPHP::VRefParam arg3) {
auto data = Object(this_);
_wrap_VectorArray_set(data, arg2, arg3);
}
static Native::PropAccessor VectorArray_properties[] {
{ nullptr }
};
static Native::PropAccessorMap VectorArray_properties_map{ VectorArray_properties };
struct VectorArrayPropHandler : public Native::MapPropHandler<VectorArrayPropHandler> {
static constexpr Native::PropAccessorMap& map = VectorArray_properties_map;
};
class EXAMPLEExtension : public Extension {
public:
EXAMPLEExtension(): Extension("example", NO_EXTENSION_VERSION_YET) {}
void moduleInit() override {
const StaticString s_Vector("Vector");
Native::registerNativeDataInfo<_wrap_Vector>(s_Vector.get());
HHVM_MALIAS(Vector, __construct, _wrap_Vector, __construct);
HHVM_MALIAS(Vector, __destruct, _wrap_Vector, __destruct);
HHVM_MALIAS(Vector, as_string, _wrap_Vector, as_string);
Native::registerNativePropHandler<VectorPropHandler>(s_Vector);
HHVM_FE(addv);
const StaticString s_VectorArray("VectorArray");
Native::registerNativeDataInfo<_wrap_VectorArray>(s_VectorArray.get());
HHVM_MALIAS(VectorArray, __construct, _wrap_VectorArray, __construct);
HHVM_MALIAS(VectorArray, __destruct, _wrap_VectorArray, __destruct);
HHVM_MALIAS(VectorArray, size, _wrap_VectorArray, size);
HHVM_MALIAS(VectorArray, get, _wrap_VectorArray, get);
HHVM_MALIAS(VectorArray, set, _wrap_VectorArray, set);
Native::registerNativePropHandler<VectorArrayPropHandler>(s_VectorArray);
loadSystemlib();
}
} s_example_extension;
HHVM_GET_MODULE(example);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment