c ++ 11 — Оболочка C ++ to PHP, использующая SWIG для функции, которая будет возвращать массив значений

я недавно начал изучать создание расширения PHP и наткнулся на SWIG. Удалось скомпилировать несколько примеров, включенных в пакет SWIG. Однако не удалось найти хороший пример того, как преобразовать вектор в собственный массив PHP.
Нашел как конвертировать вектор в массив PHP, однако это, кажется, не работает для меня.

test.i — файл интерфейса

    /* File : test.i - interface file*/
%module test

%{
#include "test.h"%}

/* Let's just grab the original header file here */

%include "test.h"
/* end of file : test.i */

файл: test.h

/* file: test.h */
#include <cmath>

#include <ctime>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <regex>
#include <stdlib.h>     /* atof */
#include <stdlib.h>     /* strtod */
#include <cstddef>      // std::size_t
#include <sstream>
#include <vector>
#include <boost/algorithm/string.hpp> // include Boost, a C++ library
using namespace std;

//function declaration
vector<double> test(int start,int cycles,char *start_index);

//function to create and return an array of double values
vector<double> test(int start,int cycles,char *start_index){

int st = start,end=cycles;
vector<double> results;

while (st<end){
results.push_back(1.38762);
st++;

}
return results;
}
/* end of file: test.h */

файл: test.cxx

/* file: test.cxx -  Defines the exported functions for the DLL application.*/

#include "test.h"
/* end of file: test.cxx */

файл: test.php

/* file: test.php -  test  output in PHP*/

<?php
var_dump(test(0,5,'2019-03-01'));
?>
/*end of file: test.php*/
resource(4) of type (_p_std__vectorT_double_t)

Как мне преобразовать ресурс типа _p_std__vectorT_double_t в собственный массив PHP, чтобы вывод в PHP был следующим:

array(
0=>1.38762,
1=>1.38762,
2=>1.38762,
3=>1.38762,
4=>1.38762
);

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …