Cpp64¤
Communicates with the cpp_lib library via the Cpp32 class that is running on a server.
Cpp64 ¤
Cpp64()
Bases: Client64
Communicates with a 32-bit C++ library.
This class demonstrates how to communicate with a 32-bit C++ library if an instance of this class is created within a 64-bit Python interpreter.
Source code in src/msl/examples/loadlib/cpp64.py
19 20 21 22 23 24 25 26 27 |
|
add ¤
add(a, b)
Add two integers.
See the corresponding Cpp32.add method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
int
|
First integer. |
required |
b
|
int
|
Second integer. |
required |
Returns:
Type | Description |
---|---|
int
|
The sum, |
Source code in src/msl/examples/loadlib/cpp64.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
add_or_subtract ¤
add_or_subtract(a, b, *, do_addition)
Add or subtract two floating-point numbers ('double' refers to the C++ data type).
See the corresponding Cpp32.add_or_subtract method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
float
|
First double-precision number. |
required |
b
|
float
|
Second double-precision number. |
required |
do_addition
|
bool
|
Whether to add or subtract the numbers. |
required |
Returns:
Type | Description |
---|---|
float
|
|
Source code in src/msl/examples/loadlib/cpp64.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
circumference ¤
circumference(radius, n)
Estimates the circumference of a circle.
This method calls the distance_n_points
function in cpp_lib.
See the corresponding Cpp32.circumference method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius
|
float
|
The radius of the circle. |
required |
n
|
int
|
The number of points to use to estimate the circumference. |
required |
Returns:
Type | Description |
---|---|
float
|
The estimated circumference of the circle. |
Source code in src/msl/examples/loadlib/cpp64.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
distance_4_points ¤
distance_4_points(points)
Calculates the total distance connecting 4 Points.
See the corresponding Cpp32.distance_4_points method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
FourPoints
|
The points to use to calculate the total distance.
Since |
required |
Returns:
Type | Description |
---|---|
float
|
The total distance connecting the 4 points. |
Source code in src/msl/examples/loadlib/cpp64.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
reverse_string_v1 ¤
reverse_string_v1(original)
Reverse a string (version 1).
In this method Python allocates the memory for the reversed string and passes the string to C++.
See the corresponding Cpp32.reverse_string_v1 method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original
|
str
|
The original string. |
required |
Returns:
Type | Description |
---|---|
str
|
The string reversed. |
Source code in src/msl/examples/loadlib/cpp64.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
reverse_string_v2 ¤
reverse_string_v2(original)
Reverse a string (version 2).
In this method C++ allocates the memory for the reversed string and passes the string to Python.
See the corresponding Cpp32.reverse_string_v2 method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original
|
str
|
The original string. |
required |
Returns:
Type | Description |
---|---|
str
|
The string reversed. |
Source code in src/msl/examples/loadlib/cpp64.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
scalar_multiply ¤
scalar_multiply(a, xin)
Multiply each element in an array by a number.
See the corresponding Cpp32.scalar_multiply method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
float
|
Scalar value. |
required |
xin
|
Sequence[float]
|
Array to modify. |
required |
Returns:
Type | Description |
---|---|
list[float]
|
A new array with each element in |
Source code in src/msl/examples/loadlib/cpp64.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
subtract ¤
subtract(a, b)
Subtract two floating-point numbers ('float' refers to the C++ data type).
See the corresponding Cpp32.subtract method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
float
|
First floating-point number. |
required |
b
|
float
|
Second floating-point number. |
required |
Returns:
Type | Description |
---|---|
float
|
The difference, |
Source code in src/msl/examples/loadlib/cpp64.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|