Package ioke.lang

Examples of ioke.lang.IokeObject


        this.lang = ikLanguage;
        register();
    }

    public Object invokeWithArgs(Object[] args) throws Throwable {
        IokeObject msg = ioke.newMessage("invoke");
        Message invoke = (Message) IokeObject.data(msg);

        List<Runtime.RescueInfo> pendingRescues = new ArrayList<Runtime.RescueInfo>();
        IokeObject rr = IokeObject.as(((Message) IokeObject.data(ioke.mimic)).sendTo(ioke.mimic, ioke.ground, ioke.rescue), ioke.ground);
        List<Object> conds = new ArrayList<Object>();
        conds.add(lang.pendingCondition);
        pendingRescues.add(new Runtime.RescueInfo(rr, conds, pendingRescues, ioke.getBindIndex()));
        ioke.registerRescues(pendingRescues);


        List<Runtime.RescueInfo> failureRescues = new ArrayList<Runtime.RescueInfo>();
        IokeObject rr2 = IokeObject.as(((Message) IokeObject.data(ioke.mimic)).sendTo(ioke.mimic, ioke.ground, ioke.rescue), ioke.ground);
        List<Object> failureConds = new ArrayList<Object>();
        failureConds.add(lang.failedExpectationCondition);
        failureRescues.add(new Runtime.RescueInfo(rr2, failureConds, failureRescues, ioke.getBindIndex()));
        ioke.registerRescues(failureRescues);
View Full Code Here


        return regexp_source();
    }

    @SuppressWarnings("unchecked")
    public List<StepArgument> arguments_from(String stepName) throws Throwable {
        IokeObject msg = ioke.newMessage("arguments_from");
        Message arguments_from = (Message) IokeObject.data(msg);
        Object args = arguments_from.sendTo(msg, iokeStepDefObject, iokeStepDefObject, stepName);
        if (args instanceof List<?>) {
            return (List<StepArgument>) args;
        } else {
View Full Code Here

            return null;
        }
    }

    private void findRegexpSource() throws ControlFlow {
        IokeObject msg = ioke.newMessage("regexp_source");
        Message regexp_source = (Message) IokeObject.data(msg);
        regexpSource = regexp_source.sendTo(msg, iokeStepDefObject, iokeStepDefObject).toString();
    }
View Full Code Here

    }

    private Readline() {}

    public static IokeObject create(Runtime runtime) throws ControlFlow {
        IokeObject rl = new IokeObject(runtime, "Readline is a module allows access to the readline native functionality");
        Readline.init(rl);
        return rl;
    }
View Full Code Here

        final ConsoleHolder holder = new ConsoleHolder();
        holder.history = new History();
        holder.currentCompletor = null;

        IokeObject history = runtime.newFromOrigin();
        rl.setCell("HISTORY", history);

        rl.registerMethod(runtime.newNativeMethod("will print a prompt to standard out and then try to read a line with working readline functionality. takes two arguments, the first is the string to prompt, the second is a boolean that says whether we should add the read string to history or not", new NativeMethod("readline") {
                private final DefaultArgumentsDefinition ARGUMENTS = DefaultArgumentsDefinition
                    .builder()
                    .withRequiredPositional("prompt")
                    .withRequiredPositional("addToHistory?")
                    .getArguments();

                @Override
                public DefaultArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, IokeObject context, IokeObject message, Object on) throws ControlFlow {
                    List<Object> args = new ArrayList<Object>();
                    getArguments().getEvaluatedArguments(context, message, on, args, new HashMap<String, Object>());

                    Object line = method.runtime.nil;
                    try {
                        if(holder.readline == null) {
                            initReadline(method.runtime, holder);
                        }
                        holder.readline.getTerminal().disableEcho();
                        String v = holder.readline.readLine(Text.getText(args.get(0)));
                        holder.readline.getTerminal().enableEcho();
                        if(null != v) {
                            if(IokeObject.isTrue(args.get(1))) {
                                holder.readline.getHistory().addToHistory(v);
                            }

                            line = method.runtime.newText(v);
                        }
                    } catch(IOException e) {
                        final Runtime runtime = context.runtime;
                        final IokeObject condition = IokeObject.as(IokeObject.getCellChain(runtime.condition,
                                                                                           message,
                                                                                           context,
                                                                                           "Error",
                                                                                           "IO"), context).mimic(message, context);
                        condition.setCell("message", message);
                        condition.setCell("context", context);
                        condition.setCell("receiver", on);
                        condition.setCell("exceptionMessage", runtime.newText(e.getMessage()));
                        List<Object> ob = new ArrayList<Object>();
                        for(StackTraceElement ste : e.getStackTrace()) {
                            ob.add(runtime.newText(ste.toString()));
                        }

                        condition.setCell("exceptionStackTrace", runtime.newList(ob));

                        runtime.withReturningRestart("ignore", context, new RunnableWithControlFlow() {
                                public void run() throws ControlFlow {
                                    runtime.errorCondition(condition);
                                }});
View Full Code Here

*
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
*/
public class JavaInvocationHelper {
    public static boolean hasProxyMethod(IokeJavaIntegrated object, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();

        Object cell = IokeObject.findCell(pr, name);
        if(cell != null && cell != runtime.nul && cell instanceof IokeObject) {
            return !(IokeObject.data(cell) instanceof NativeImplementedMethod);
View Full Code Here

        return false;
    }

    public static void voidInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Interpreter.send(msg, runtime.ground, pr);
        } catch(Throwable e) {
        }
    }
View Full Code Here

        } catch(Throwable e) {
        }
    }

    public static byte byteInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);

            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Byte) {
                return Byte.valueOf((Byte)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Byte) {
View Full Code Here

        }
        return 0;
    }

    public static int intInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Integer) {
                return Integer.valueOf((Integer)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Integer) {
                return Integer.valueOf((Integer)JavaWrapper.getObject(result));
View Full Code Here

        }
        return 0;
    }

    public static short shortInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Short) {
                return Short.valueOf((Short)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Short) {
                return Short.valueOf((Short)JavaWrapper.getObject(result));
View Full Code Here

TOP

Related Classes of ioke.lang.IokeObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.