Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed obsolete methods

  • Loading branch information...
commit b94b5e3c3a5f4665bc26d349432d93910198a407 1 parent bbdd1ba
@tokuhirom authored
Showing with 10 additions and 10 deletions.
  1. +5 −3 tora/object/array.cc
  2. +5 −7 tora/value/array.h
View
8 tora/object/array.cc
@@ -39,8 +39,8 @@ static SharedPtr<Value> av_sort(VM* vm, Value* self) {
* Perl5: push(@array, $elem);
*/
static SharedPtr<Value> av_push(VM * vm, Value* self, Value* v) {
- Inspector ins(vm);
- printf("# ARRY PUSH: %p\n", v);
+ // Inspector ins(vm);
+ // printf("# ARRY PUSH: %p\n", v);
self->upcast<ArrayValue>()->set_item(self->upcast<ArrayValue>()->size()-1+1, v);
// self->upcast<ArrayValue>()->push_back(v);
return self;
@@ -52,7 +52,9 @@ static SharedPtr<Value> av_push(VM * vm, Value* self, Value* v) {
* Pop a object from array.
*/
static SharedPtr<Value> av_pop(VM * vm, Value* self) {
- return self->upcast<ArrayValue>()->pop();
+ SharedPtr<Value> v = self->upcast<ArrayValue>()->back();
+ self->upcast<ArrayValue>()->pop_back();
+ return v;
}
/**
View
12 tora/value/array.h
@@ -34,7 +34,9 @@ class ArrayValue: public Value {
const_iterator begin() const { return VAL()->begin(); }
const_iterator end() const { return VAL()->end(); }
- // retain before push
+ void pop_back() {
+ VAL()->pop_back();
+ }
void push_back(Value *v) {
VAL()->push_back(v);
}
@@ -56,12 +58,8 @@ class ArrayValue: public Value {
void resize(size_t n) {
VAL()->resize(n);
}
- // release after pop by your hand
- SharedPtr<Value> pop() {
- fprintf(stderr, "# Obsolete function: ArrayValue::pop() was called at XS level\n");
- SharedPtr<Value> v = VAL()->back();
- VAL()->pop_back();
- return v;
+ const SharedPtr<Value>& back() const {
+ return VAL()->back();
}
SharedPtr<Value>at(int i) const {
return VAL()->at(i);
Please sign in to comment.
Something went wrong with that request. Please try again.