package org.cafebabepy.runtime.module.builtins;

import org.cafebabepy.annotation.DefineCafeBabePyType;
import org.cafebabepy.runtime.PyObject;
import org.cafebabepy.runtime.Python;
import org.cafebabepy.runtime.module.AbstractCafeBabePyType;

/**
 * Created by yotchang4s on 2017/05/13.
 */
@DefineCafeBabePyType(name = "builtins.tuple")
public class PyTupleType extends AbstractCafeBabePyType {

    public static final String JAVA_TUPLE_NAME = "tuple";

    public PyTupleType(Python runtime) {
        super(runtime);
    }

    public static PyObject newTuple(Python runtime, PyObject... vars) {
        PyObject type = runtime.moduleOrThrow(Python.BUILTINS_MODULE_NAME).getObjectOrThrow("tuple");
        if (!(type instanceof PyTupleType)) {
            // FIXME To CPython message
            throw runtime.newRaiseException(
                    "builtins.TypeError", "'" + type.getName() + "' is not str");
        }

        PyObject object = type.call();
        object.putJavaObject(JAVA_TUPLE_NAME, vars);

        return object;
    }
}

@@ -237,16 +237,65 @@
 yType;%0A%0A
+import java.util.Arrays;%0Aimport java.util.List;%0A%0A
 /**%0A * C
@@ -637,18 +637,158 @@
 ct... va
-rs
+lue) %7B%0A        return newTuple(runtime, Arrays.asList(value));%0A    %7D%0A%0A    public static PyObject newTuple(Python runtime, List%3CPyObject%3E value
 ) %7B%0A    
@@ -1200,10 +1200,11 @@
 , va
-rs
+lue
 );%0A%0A

Add List argument method