Fix PHP sync example
Mostly it was missing `%include <std_string.i>`
This commit is contained in:
parent
a49cc60772
commit
09d06843d1
4 changed files with 19 additions and 19 deletions
|
|
@ -12,8 +12,8 @@ void Sync::printer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sync::all_change() {
|
void Sync::all_change() {
|
||||||
::s = "global change";
|
::s = "global change";
|
||||||
++::x;
|
++::x;
|
||||||
this->s = "local change";
|
this->s = "local change";
|
||||||
++this->x;
|
++this->x;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ extern std::string s;
|
||||||
extern int x;
|
extern int x;
|
||||||
|
|
||||||
class Sync {
|
class Sync {
|
||||||
public:
|
public:
|
||||||
int x;
|
int x;
|
||||||
std::string s;
|
std::string s;
|
||||||
void printer();
|
void printer();
|
||||||
void all_change();
|
void all_change();
|
||||||
|
|
||||||
Sync() : x(0) { }
|
Sync() : x(0) { }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
|
%include <std_string.i>
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -11,23 +11,21 @@ echo "PHP reading object: string is '", $o->s, "' and value is ", $o->x, "\n";
|
||||||
|
|
||||||
$o->printer();
|
$o->printer();
|
||||||
|
|
||||||
// FIXME something is up with the setter
|
example::s_set("global string");
|
||||||
// type error - s_set("global string");
|
example::x_set(42);
|
||||||
x_set(42);
|
|
||||||
|
|
||||||
// FIXME something is up with the setter
|
$o->s = "object string";
|
||||||
// type error - $o->s = "object string";
|
|
||||||
$o->x = 1234;
|
$o->x = 1234;
|
||||||
|
|
||||||
echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
|
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
|
||||||
echo "PHP reading object: string is '", $o->s, "' and value is ", $s->x, "\n";
|
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
|
||||||
|
|
||||||
$o->printer();
|
$o->printer();
|
||||||
|
|
||||||
echo "Calling all_change() method\n";
|
echo "Calling all_change() method\n";
|
||||||
$o->all_change();
|
$o->all_change();
|
||||||
|
|
||||||
echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
|
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
|
||||||
echo "PHP reading object: string is '", $o->s, "' and value is ", $o->x, "\n";
|
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
|
||||||
|
|
||||||
$o->printer();
|
$o->printer();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue