Return a reference to the actual item instead of a clone when accessing contents of a SurfaceCollection

This commit is contained in:
Alessandro Ranellucci 2013-07-15 13:50:53 +02:00
parent f612d4c64e
commit e485f0b130
3 changed files with 12 additions and 3 deletions

View file

@ -19,6 +19,7 @@ SurfaceCollection::new(...)
RETVAL->surfaces.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
RETVAL->surfaces[i-1] = *(Surface *)SvIV((SV*)SvRV( ST(i) ));
RETVAL->surfaces[i-1].in_collection = true;
}
OUTPUT:
RETVAL
@ -31,7 +32,7 @@ SurfaceCollection::arrayref()
int i = 0;
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::Surface", new Surface(*it) );
sv_setref_pv( sv, "Slic3r::Surface", &*it );
av_store(av, i++, sv);
}
RETVAL = newRV_noinc((SV*)av);
@ -43,6 +44,7 @@ SurfaceCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
THIS->surfaces.push_back(*(Surface *)SvIV((SV*)SvRV( ST(i) )));
THIS->surfaces.back().in_collection = true;
}
%}