mcdougallab / matlabneuroninterface

Interface for connecting NEURON and MATLAB
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

methods should return the correct data type #65

Open ramcdougal opened 1 year ago

ramcdougal commented 1 year ago

When calling a method on an object of a built-in type (but nothing else at this point, unfortunately), we should set the top level int hoc_return_type_code to 0.... if when the method returns the value is 2, the double that's returned should be treated as a logical... if the value is 1, then it should be an integer... otherwise it should be treated as a double.

How do we know if it's a built-in class? That's easy, we check the object's ctemplate->id. If it's less-than or equal to the top-level hoc_max_builtin_class_id (which is also an int), then the class is of a built-in type and the hoc_return_type_code should be meaningful... if not, we treat everything as doubles.

(It's a little messy, because the underlying stack machine has no concept of booleans or integers as returnable entities, so this work-around was added to allow Python to receive meaningful types.)