Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
61352e50
Commit
61352e50
authored
Jul 18, 2016
by
Wenzel Jakob
Committed by
GitHub
Jul 18, 2016
Browse files
Merge pull request #289 from jagerman/example-renaming
Rename examples files, as per #288
parents
fb6aed21
3e2e44f5
Changes
65
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
207 additions
and
17 deletions
+207
-17
example/example-eval_call.py
example/example-eval_call.py
+0
-0
example/example-inheritance.cpp
example/example-inheritance.cpp
+72
-0
example/example-inheritance.py
example/example-inheritance.py
+0
-0
example/example-inheritance.ref
example/example-inheritance.ref
+0
-0
example/example-keep-alive.cpp
example/example-keep-alive.cpp
+2
-2
example/example-keep-alive.py
example/example-keep-alive.py
+0
-0
example/example-keep-alive.ref
example/example-keep-alive.ref
+0
-0
example/example-methods-and-attributes.cpp
example/example-methods-and-attributes.cpp
+92
-0
example/example-methods-and-attributes.py
example/example-methods-and-attributes.py
+3
-3
example/example-methods-and-attributes.ref
example/example-methods-and-attributes.ref
+26
-0
example/example-modules.cpp
example/example-modules.cpp
+2
-2
example/example-modules.py
example/example-modules.py
+0
-0
example/example-modules.ref
example/example-modules.ref
+0
-0
example/example-numpy-vectorize.cpp
example/example-numpy-vectorize.cpp
+2
-2
example/example-numpy-vectorize.py
example/example-numpy-vectorize.py
+0
-0
example/example-numpy-vectorize.ref
example/example-numpy-vectorize.ref
+0
-0
example/example-opaque-types.cpp
example/example-opaque-types.cpp
+2
-2
example/example-opaque-types.py
example/example-opaque-types.py
+2
-2
example/example-opaque-types.ref
example/example-opaque-types.ref
+2
-2
example/example-operator-overloading.cpp
example/example-operator-overloading.cpp
+2
-2
No files found.
example/example
18
_call.py
→
example/example
-eval
_call.py
View file @
61352e50
File moved
example/example
16
.cpp
→
example/example
-inheritance
.cpp
View file @
61352e50
/*
/*
example/example
16.cpp --
automatic upcasting for polymorphic types
example/example
-inheritance.cpp -- inheritance,
automatic upcasting for polymorphic types
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -9,11 +9,59 @@
...
@@ -9,11 +9,59 @@
#include "example.h"
#include "example.h"
class
Pet
{
public:
Pet
(
const
std
::
string
&
name
,
const
std
::
string
&
species
)
:
m_name
(
name
),
m_species
(
species
)
{}
std
::
string
name
()
const
{
return
m_name
;
}
std
::
string
species
()
const
{
return
m_species
;
}
private:
std
::
string
m_name
;
std
::
string
m_species
;
};
class
Dog
:
public
Pet
{
public:
Dog
(
const
std
::
string
&
name
)
:
Pet
(
name
,
"dog"
)
{}
void
bark
()
const
{
std
::
cout
<<
"Woof!"
<<
std
::
endl
;
}
};
class
Rabbit
:
public
Pet
{
public:
Rabbit
(
const
std
::
string
&
name
)
:
Pet
(
name
,
"parrot"
)
{}
};
void
pet_print
(
const
Pet
&
pet
)
{
std
::
cout
<<
pet
.
name
()
+
" is a "
+
pet
.
species
()
<<
std
::
endl
;
}
void
dog_bark
(
const
Dog
&
dog
)
{
dog
.
bark
();
}
struct
BaseClass
{
virtual
~
BaseClass
()
{}
};
struct
BaseClass
{
virtual
~
BaseClass
()
{}
};
struct
DerivedClass1
:
BaseClass
{
};
struct
DerivedClass1
:
BaseClass
{
};
struct
DerivedClass2
:
BaseClass
{
};
struct
DerivedClass2
:
BaseClass
{
};
void
init_ex16
(
py
::
module
&
m
)
{
void
init_ex_inheritance
(
py
::
module
&
m
)
{
py
::
class_
<
Pet
>
pet_class
(
m
,
"Pet"
);
pet_class
.
def
(
py
::
init
<
std
::
string
,
std
::
string
>
())
.
def
(
"name"
,
&
Pet
::
name
)
.
def
(
"species"
,
&
Pet
::
species
);
/* One way of declaring a subclass relationship: reference parent's class_ object */
py
::
class_
<
Dog
>
(
m
,
"Dog"
,
pet_class
)
.
def
(
py
::
init
<
std
::
string
>
());
/* Another way of declaring a subclass relationship: reference parent's C++ type */
py
::
class_
<
Rabbit
>
(
m
,
"Rabbit"
,
py
::
base
<
Pet
>
())
.
def
(
py
::
init
<
std
::
string
>
());
m
.
def
(
"pet_print"
,
pet_print
);
m
.
def
(
"dog_bark"
,
dog_bark
);
py
::
class_
<
BaseClass
>
(
m
,
"BaseClass"
).
def
(
py
::
init
<>
());
py
::
class_
<
BaseClass
>
(
m
,
"BaseClass"
).
def
(
py
::
init
<>
());
py
::
class_
<
DerivedClass1
>
(
m
,
"DerivedClass1"
).
def
(
py
::
init
<>
());
py
::
class_
<
DerivedClass1
>
(
m
,
"DerivedClass1"
).
def
(
py
::
init
<>
());
py
::
class_
<
DerivedClass2
>
(
m
,
"DerivedClass2"
).
def
(
py
::
init
<>
());
py
::
class_
<
DerivedClass2
>
(
m
,
"DerivedClass2"
).
def
(
py
::
init
<>
());
...
...
example/example
16
.py
→
example/example
-inheritance
.py
View file @
61352e50
File moved
example/example
16
.ref
→
example/example
-inheritance
.ref
View file @
61352e50
File moved
example/example
13
.cpp
→
example/example
-keep-alive
.cpp
View file @
61352e50
/*
/*
example/example
13
.cpp -- keep_alive modifier (pybind11's version
example/example
-keep-alive
.cpp -- keep_alive modifier (pybind11's version
of Boost.Python's with_custodian_and_ward / with_custodian_and_ward_postcall)
of Boost.Python's with_custodian_and_ward / with_custodian_and_ward_postcall)
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -24,7 +24,7 @@ public:
...
@@ -24,7 +24,7 @@ public:
Child
*
returnChild
()
{
return
new
Child
();
}
Child
*
returnChild
()
{
return
new
Child
();
}
};
};
void
init_ex
13
(
py
::
module
&
m
)
{
void
init_ex
_keep_alive
(
py
::
module
&
m
)
{
py
::
class_
<
Parent
>
(
m
,
"Parent"
)
py
::
class_
<
Parent
>
(
m
,
"Parent"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<>
())
.
def
(
"addChild"
,
&
Parent
::
addChild
)
.
def
(
"addChild"
,
&
Parent
::
addChild
)
...
...
example/example
13
.py
→
example/example
-keep-alive
.py
View file @
61352e50
File moved
example/example
13
.ref
→
example/example
-keep-alive
.ref
View file @
61352e50
File moved
example/example
1
.cpp
→
example/example
-methods-and-attributes
.cpp
View file @
61352e50
/*
/*
example/example
1
.cpp -- constructors, deconstructors, attribute access,
example/example
-methods-and-attributes
.cpp -- constructors, deconstructors, attribute access,
__str__, argument and return value conventions
__str__, argument and return value conventions
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -10,36 +10,36 @@
...
@@ -10,36 +10,36 @@
#include "example.h"
#include "example.h"
class
Example
1
{
class
Example
MandA
{
public:
public:
Example
1
()
{
Example
MandA
()
{
cout
<<
"Called Example
1
default constructor.."
<<
endl
;
cout
<<
"Called Example
MandA
default constructor.."
<<
endl
;
}
}
Example
1
(
int
value
)
:
value
(
value
)
{
Example
MandA
(
int
value
)
:
value
(
value
)
{
cout
<<
"Called Example
1
constructor with value "
<<
value
<<
".."
<<
endl
;
cout
<<
"Called Example
MandA
constructor with value "
<<
value
<<
".."
<<
endl
;
}
}
Example
1
(
const
Example
1
&
e
)
:
value
(
e
.
value
)
{
Example
MandA
(
const
Example
MandA
&
e
)
:
value
(
e
.
value
)
{
cout
<<
"Called Example
1
copy constructor with value "
<<
value
<<
".."
<<
endl
;
cout
<<
"Called Example
MandA
copy constructor with value "
<<
value
<<
".."
<<
endl
;
}
}
Example
1
(
Example
1
&&
e
)
:
value
(
e
.
value
)
{
Example
MandA
(
Example
MandA
&&
e
)
:
value
(
e
.
value
)
{
cout
<<
"Called Example
1
move constructor with value "
<<
value
<<
".."
<<
endl
;
cout
<<
"Called Example
MandA
move constructor with value "
<<
value
<<
".."
<<
endl
;
e
.
value
=
0
;
e
.
value
=
0
;
}
}
~
Example
1
()
{
~
Example
MandA
()
{
cout
<<
"Called Example
1
destructor ("
<<
value
<<
")"
<<
endl
;
cout
<<
"Called Example
MandA
destructor ("
<<
value
<<
")"
<<
endl
;
}
}
std
::
string
toString
()
{
std
::
string
toString
()
{
return
"Example
1
[value="
+
std
::
to_string
(
value
)
+
"]"
;
return
"Example
MandA
[value="
+
std
::
to_string
(
value
)
+
"]"
;
}
}
void
operator
=
(
const
Example
1
&
e
)
{
cout
<<
"Assignment operator"
<<
endl
;
value
=
e
.
value
;
}
void
operator
=
(
const
Example
MandA
&
e
)
{
cout
<<
"Assignment operator"
<<
endl
;
value
=
e
.
value
;
}
void
operator
=
(
Example
1
&&
e
)
{
cout
<<
"Move assignment operator"
<<
endl
;
value
=
e
.
value
;
e
.
value
=
0
;}
void
operator
=
(
Example
MandA
&&
e
)
{
cout
<<
"Move assignment operator"
<<
endl
;
value
=
e
.
value
;
e
.
value
=
0
;}
void
add1
(
Example
1
other
)
{
value
+=
other
.
value
;
}
// passing by value
void
add1
(
Example
MandA
other
)
{
value
+=
other
.
value
;
}
// passing by value
void
add2
(
Example
1
&
other
)
{
value
+=
other
.
value
;
}
// passing by reference
void
add2
(
Example
MandA
&
other
)
{
value
+=
other
.
value
;
}
// passing by reference
void
add3
(
const
Example
1
&
other
)
{
value
+=
other
.
value
;
}
// passing by const reference
void
add3
(
const
Example
MandA
&
other
)
{
value
+=
other
.
value
;
}
// passing by const reference
void
add4
(
Example
1
*
other
)
{
value
+=
other
->
value
;
}
// passing by pointer
void
add4
(
Example
MandA
*
other
)
{
value
+=
other
->
value
;
}
// passing by pointer
void
add5
(
const
Example
1
*
other
)
{
value
+=
other
->
value
;
}
// passing by const pointer
void
add5
(
const
Example
MandA
*
other
)
{
value
+=
other
->
value
;
}
// passing by const pointer
void
add6
(
int
other
)
{
value
+=
other
;
}
// passing by value
void
add6
(
int
other
)
{
value
+=
other
;
}
// passing by value
void
add7
(
int
&
other
)
{
value
+=
other
;
}
// passing by reference
void
add7
(
int
&
other
)
{
value
+=
other
;
}
// passing by reference
...
@@ -47,11 +47,11 @@ public:
...
@@ -47,11 +47,11 @@ public:
void
add9
(
int
*
other
)
{
value
+=
*
other
;
}
// passing by pointer
void
add9
(
int
*
other
)
{
value
+=
*
other
;
}
// passing by pointer
void
add10
(
const
int
*
other
)
{
value
+=
*
other
;
}
// passing by const pointer
void
add10
(
const
int
*
other
)
{
value
+=
*
other
;
}
// passing by const pointer
Example
1
self1
()
{
return
*
this
;
}
// return by value
Example
MandA
self1
()
{
return
*
this
;
}
// return by value
Example
1
&
self2
()
{
return
*
this
;
}
// return by reference
Example
MandA
&
self2
()
{
return
*
this
;
}
// return by reference
const
Example
1
&
self3
()
{
return
*
this
;
}
// return by const reference
const
Example
MandA
&
self3
()
{
return
*
this
;
}
// return by const reference
Example
1
*
self4
()
{
return
this
;
}
// return by pointer
Example
MandA
*
self4
()
{
return
this
;
}
// return by pointer
const
Example
1
*
self5
()
{
return
this
;
}
// return by const pointer
const
Example
MandA
*
self5
()
{
return
this
;
}
// return by const pointer
int
internal1
()
{
return
value
;
}
// return by value
int
internal1
()
{
return
value
;
}
// return by value
int
&
internal2
()
{
return
value
;
}
// return by reference
int
&
internal2
()
{
return
value
;
}
// return by reference
...
@@ -62,31 +62,31 @@ public:
...
@@ -62,31 +62,31 @@ public:
int
value
=
0
;
int
value
=
0
;
};
};
void
init_ex
1
(
py
::
module
&
m
)
{
void
init_ex
_methods_and_attributes
(
py
::
module
&
m
)
{
py
::
class_
<
Example
1
>
(
m
,
"Example
1
"
)
py
::
class_
<
Example
MandA
>
(
m
,
"Example
MandA
"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<
int
>
())
.
def
(
py
::
init
<
int
>
())
.
def
(
py
::
init
<
const
Example
1
&>
())
.
def
(
py
::
init
<
const
Example
MandA
&>
())
.
def
(
"add1"
,
&
Example
1
::
add1
)
.
def
(
"add1"
,
&
Example
MandA
::
add1
)
.
def
(
"add2"
,
&
Example
1
::
add2
)
.
def
(
"add2"
,
&
Example
MandA
::
add2
)
.
def
(
"add3"
,
&
Example
1
::
add3
)
.
def
(
"add3"
,
&
Example
MandA
::
add3
)
.
def
(
"add4"
,
&
Example
1
::
add4
)
.
def
(
"add4"
,
&
Example
MandA
::
add4
)
.
def
(
"add5"
,
&
Example
1
::
add5
)
.
def
(
"add5"
,
&
Example
MandA
::
add5
)
.
def
(
"add6"
,
&
Example
1
::
add6
)
.
def
(
"add6"
,
&
Example
MandA
::
add6
)
.
def
(
"add7"
,
&
Example
1
::
add7
)
.
def
(
"add7"
,
&
Example
MandA
::
add7
)
.
def
(
"add8"
,
&
Example
1
::
add8
)
.
def
(
"add8"
,
&
Example
MandA
::
add8
)
.
def
(
"add9"
,
&
Example
1
::
add9
)
.
def
(
"add9"
,
&
Example
MandA
::
add9
)
.
def
(
"add10"
,
&
Example
1
::
add10
)
.
def
(
"add10"
,
&
Example
MandA
::
add10
)
.
def
(
"self1"
,
&
Example
1
::
self1
)
.
def
(
"self1"
,
&
Example
MandA
::
self1
)
.
def
(
"self2"
,
&
Example
1
::
self2
)
.
def
(
"self2"
,
&
Example
MandA
::
self2
)
.
def
(
"self3"
,
&
Example
1
::
self3
)
.
def
(
"self3"
,
&
Example
MandA
::
self3
)
.
def
(
"self4"
,
&
Example
1
::
self4
)
.
def
(
"self4"
,
&
Example
MandA
::
self4
)
.
def
(
"self5"
,
&
Example
1
::
self5
)
.
def
(
"self5"
,
&
Example
MandA
::
self5
)
.
def
(
"internal1"
,
&
Example
1
::
internal1
)
.
def
(
"internal1"
,
&
Example
MandA
::
internal1
)
.
def
(
"internal2"
,
&
Example
1
::
internal2
)
.
def
(
"internal2"
,
&
Example
MandA
::
internal2
)
.
def
(
"internal3"
,
&
Example
1
::
internal3
)
.
def
(
"internal3"
,
&
Example
MandA
::
internal3
)
.
def
(
"internal4"
,
&
Example
1
::
internal4
)
.
def
(
"internal4"
,
&
Example
MandA
::
internal4
)
.
def
(
"internal5"
,
&
Example
1
::
internal5
)
.
def
(
"internal5"
,
&
Example
MandA
::
internal5
)
.
def
(
"__str__"
,
&
Example
1
::
toString
)
.
def
(
"__str__"
,
&
Example
MandA
::
toString
)
.
def_readwrite
(
"value"
,
&
Example
1
::
value
);
.
def_readwrite
(
"value"
,
&
Example
MandA
::
value
);
}
}
example/example
1
.py
→
example/example
-methods-and-attributes
.py
View file @
61352e50
...
@@ -3,10 +3,10 @@ from __future__ import print_function
...
@@ -3,10 +3,10 @@ from __future__ import print_function
import
sys
import
sys
sys
.
path
.
append
(
'.'
)
sys
.
path
.
append
(
'.'
)
from
example
import
Example
1
from
example
import
Example
MandA
instance1
=
Example
1
()
instance1
=
Example
MandA
()
instance2
=
Example
1
(
32
)
instance2
=
Example
MandA
(
32
)
instance1
.
add1
(
instance2
)
instance1
.
add1
(
instance2
)
instance1
.
add2
(
instance2
)
instance1
.
add2
(
instance2
)
instance1
.
add3
(
instance2
)
instance1
.
add3
(
instance2
)
...
...
example/example-methods-and-attributes.ref
0 → 100644
View file @
61352e50
Called ExampleMandA default constructor..
Called ExampleMandA constructor with value 32..
Called ExampleMandA copy constructor with value 32..
Called ExampleMandA copy constructor with value 32..
Called ExampleMandA destructor (32)
Called ExampleMandA destructor (32)
Instance 1: ExampleMandA[value=320]
Instance 2: ExampleMandA[value=32]
Called ExampleMandA copy constructor with value 320..
Called ExampleMandA move constructor with value 320..
Called ExampleMandA destructor (0)
ExampleMandA[value=320]
Called ExampleMandA destructor (320)
ExampleMandA[value=320]
ExampleMandA[value=320]
ExampleMandA[value=320]
ExampleMandA[value=320]
320
320
320
320
320
Instance 1, direct access = 320
Instance 1: ExampleMandA[value=100]
Called ExampleMandA destructor (32)
Called ExampleMandA destructor (100)
example/example
9
.cpp
→
example/example
-modules
.cpp
View file @
61352e50
/*
/*
example/example
9
.cpp -- nested modules, importing modules, and
example/example
-modules
.cpp -- nested modules, importing modules, and
internal references
internal references
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -36,7 +36,7 @@ public:
...
@@ -36,7 +36,7 @@ public:
A
a2
{
2
};
A
a2
{
2
};
};
};
void
init_ex
9
(
py
::
module
&
m
)
{
void
init_ex
_modules
(
py
::
module
&
m
)
{
py
::
module
m_sub
=
m
.
def_submodule
(
"submodule"
);
py
::
module
m_sub
=
m
.
def_submodule
(
"submodule"
);
m_sub
.
def
(
"submodule_func"
,
&
submodule_func
);
m_sub
.
def
(
"submodule_func"
,
&
submodule_func
);
...
...
example/example
9
.py
→
example/example
-modules
.py
View file @
61352e50
File moved
example/example
9
.ref
→
example/example
-modules
.ref
View file @
61352e50
File moved
example/example
10
.cpp
→
example/example
-numpy-vectorize
.cpp
View file @
61352e50
/*
/*
example/example
10
.cpp -- auto-vectorize functions over NumPy array
example/example
-numpy-vectorize
.cpp -- auto-vectorize functions over NumPy array
arguments
arguments
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -20,7 +20,7 @@ std::complex<double> my_func3(std::complex<double> c) {
...
@@ -20,7 +20,7 @@ std::complex<double> my_func3(std::complex<double> c) {
return
c
*
std
::
complex
<
double
>
(
2.
f
);
return
c
*
std
::
complex
<
double
>
(
2.
f
);
}
}
void
init_ex
10
(
py
::
module
&
m
)
{
void
init_ex
_numpy_vectorize
(
py
::
module
&
m
)
{
// Vectorize all arguments of a function (though non-vector arguments are also allowed)
// Vectorize all arguments of a function (though non-vector arguments are also allowed)
m
.
def
(
"vectorized_func"
,
py
::
vectorize
(
my_func
));
m
.
def
(
"vectorized_func"
,
py
::
vectorize
(
my_func
));
...
...
example/example
10
.py
→
example/example
-numpy-vectorize
.py
View file @
61352e50
File moved
example/example
10
.ref
→
example/example
-numpy-vectorize
.ref
View file @
61352e50
File moved
example/example
14
.cpp
→
example/example
-opaque-types
.cpp
View file @
61352e50
/*
/*
example/example
14
.cpp -- opaque types, passing void pointers
example/example
-opaque-types
.cpp -- opaque types, passing void pointers
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -21,7 +21,7 @@ public:
...
@@ -21,7 +21,7 @@ public:
/* IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures */
/* IMPORTANT: Disable internal pybind11 translation mechanisms for STL data structures */
PYBIND11_MAKE_OPAQUE
(
StringList
);
PYBIND11_MAKE_OPAQUE
(
StringList
);
void
init_ex
14
(
py
::
module
&
m
)
{
void
init_ex
_opaque_types
(
py
::
module
&
m
)
{
py
::
class_
<
StringList
>
(
m
,
"StringList"
)
py
::
class_
<
StringList
>
(
m
,
"StringList"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<>
())
.
def
(
"pop_back"
,
&
StringList
::
pop_back
)
.
def
(
"pop_back"
,
&
StringList
::
pop_back
)
...
...
example/example
14
.py
→
example/example
-opaque-types
.py
View file @
61352e50
...
@@ -8,7 +8,7 @@ from example import ClassWithSTLVecProperty
...
@@ -8,7 +8,7 @@ from example import ClassWithSTLVecProperty
from
example
import
return_void_ptr
,
print_void_ptr
from
example
import
return_void_ptr
,
print_void_ptr
from
example
import
return_null_str
,
print_null_str
from
example
import
return_null_str
,
print_null_str
from
example
import
return_unique_ptr
from
example
import
return_unique_ptr
from
example
import
Example
1
from
example
import
Example
MandA
#####
#####
...
@@ -33,7 +33,7 @@ print_opaque_list(cvp.stringList)
...
@@ -33,7 +33,7 @@ print_opaque_list(cvp.stringList)
#####
#####
print_void_ptr
(
return_void_ptr
())
print_void_ptr
(
return_void_ptr
())
print_void_ptr
(
Example
1
())
# Should also work for other C++ types
print_void_ptr
(
Example
MandA
())
# Should also work for other C++ types
try
:
try
:
print_void_ptr
([
1
,
2
,
3
])
# This should not work
print_void_ptr
([
1
,
2
,
3
])
# This should not work
...
...
example/example
14
.ref
→
example/example
-opaque-types
.ref
View file @
61352e50
...
@@ -6,9 +6,9 @@ Opaque list: [Element 1]
...
@@ -6,9 +6,9 @@ Opaque list: [Element 1]
Opaque list: []
Opaque list: []
Opaque list: [Element 1, Element 3]
Opaque list: [Element 1, Element 3]
Got void ptr : 0x1234
Got void ptr : 0x1234
Called Example
1
default constructor..
Called Example
MandA
default constructor..
Got void ptr : 0x7f9ba0f3c430
Got void ptr : 0x7f9ba0f3c430
Called Example
1
destructor (0)
Called Example
MandA
destructor (0)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
Caught expected exception: Incompatible function arguments. The following argument types are supported:
1. (capsule) -> NoneType
1. (capsule) -> NoneType
Invoked with: [1, 2, 3]
Invoked with: [1, 2, 3]
...
...
example/example
3
.cpp
→
example/example
-operator-overloading
.cpp
View file @
61352e50
/*
/*
example/example
3
.cpp -- operator overloading
example/example
-operator-overloading
.cpp -- operator overloading
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
...
@@ -52,7 +52,7 @@ private:
...
@@ -52,7 +52,7 @@ private:
};
};
void
init_ex
3
(
py
::
module
&
m
)
{
void
init_ex
_operator_overloading
(
py
::
module
&
m
)
{
py
::
class_
<
Vector2
>
(
m
,
"Vector2"
)
py
::
class_
<
Vector2
>
(
m
,
"Vector2"
)
.
def
(
py
::
init
<
float
,
float
>
())
.
def
(
py
::
init
<
float
,
float
>
())
.
def
(
py
::
self
+
py
::
self
)
.
def
(
py
::
self
+
py
::
self
)
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment