class AbstractObject(object):
    
    def __init__(self):
        pass
        
    def send(self, selector_string, arguments, universe):
        # Turn the selector string into a selector
        selector = universe.symbol_for(selector_string)
        invokable = self.get_class(universe).lookup_invokable(selector)
        return invokable.invoke(self, arguments)

    def send_void(self, selector_string, arguments, universe):
        # Turn the selector string into a selector
        selector = universe.symbol_for(selector_string)
        invokable = self.get_class(universe).lookup_invokable(selector)
        invokable.invoke_void(self, arguments)


    def send_does_not_understand(self, selector, arguments, universe):
        args = self._prepare_dnu_arguments(arguments, selector, universe)
        return self.send("doesNotUnderstand:arguments:", args, universe)

    @staticmethod
    def _prepare_dnu_arguments(arguments, selector, universe):
        # Compute the number of arguments
        number_of_arguments = selector.get_number_of_signature_arguments()
        arguments_array = universe.new_array_with_length(number_of_arguments)
        for i in range(0, number_of_arguments - 1):
            arguments_array.set_indexable_field(i, arguments[i])
        args = [selector, arguments_array]
        return args

    def send_does_not_understand_void(self, selector, arguments, universe):
        args = self._prepare_dnu_arguments(arguments, selector, universe)
        return self.send_void("doesNotUnderstand:arguments:", args,
                              universe)

    def send_unknown_global(self, global_name, universe):
        arguments = [global_name]
        return self.send("unknownGlobal:", arguments, universe)

    def send_escaped_block(self, block, universe):
        arguments = [block]
        return self.send("escapedBlock:", arguments, universe)

    def get_class(self, universe):
        raise NotImplementedError("Subclasses need to implement get_class(universe).")

    def is_invokable(self):
        return False

    def __str__(self):
        from som.vm.universe import get_current
        return "a " + self.get_class(get_current()).get_name().get_string()

class AbstractObject(object):
    
    def __init__(self):
        pass
        
    def send(self, selector_string, arguments, universe):
        # Turn the selector string into a selector
        selector = universe.symbol_for(selector_string)
        invokable = self.get_class(universe).lookup_invokable(selector)
        return invokable.invoke(self, arguments)

    def send_void(self, selector_string, arguments, universe):
        # Turn the selector string into a selector
        selector = universe.symbol_for(selector_string)
        invokable = self.get_class(universe).lookup_invokable(selector)
        invokable.invoke_void(self, arguments)


    def send_does_not_understand(self, selector, arguments, universe):
        args = self._prepare_dnu_arguments(arguments, selector, universe)
        return self.send("doesNotUnderstand:arguments:", args, universe)

    @staticmethod
    def _prepare_dnu_arguments(arguments, selector, universe):
        # Compute the number of arguments
        number_of_arguments = selector.get_number_of_signature_arguments() - 1 ## without self
        assert number_of_arguments == len(arguments)

        arguments_array = universe.new_array_with_length(number_of_arguments)
        for i in range(0, number_of_arguments):
            arguments_array.set_indexable_field(i, arguments[i])
        args = [selector, arguments_array]
        return args

    def send_does_not_understand_void(self, selector, arguments, universe):
        args = self._prepare_dnu_arguments(arguments, selector, universe)
        return self.send_void("doesNotUnderstand:arguments:", args,
                              universe)

    def send_unknown_global(self, global_name, universe):
        arguments = [global_name]
        return self.send("unknownGlobal:", arguments, universe)

    def send_escaped_block(self, block, universe):
        arguments = [block]
        return self.send("escapedBlock:", arguments, universe)

    def get_class(self, universe):
        raise NotImplementedError("Subclasses need to implement get_class(universe).")

    def is_invokable(self):
        return False

    def __str__(self):
        from som.vm.universe import get_current
        return "a " + self.get_class(get_current()).get_name().get_string()

Fix implementation of #dnu