Permalink
Browse files

Adding LICENSE file (going with MIT license for now) as well

as copyright message in each source file. The message is added
to the *bottom* of M-files because I (and most people) would
probably prefer that it not show up in the output of MATLAB's
help command, which takes the first comment block above (or within)
the function or class to be the help message.
  • Loading branch information...
1 parent 382b2ea commit 1d82901e9bd818534745abf3d6ba67aa43f9cac7 @kw committed Nov 24, 2009
Showing with 183 additions and 26 deletions.
  1. +3 −1 +py/+types/+builtin/object.m
  2. +4 −0 +py/+types/+numpy/ndarray.m
  3. +4 −0 +py/+types/voidptr.m
  4. +4 −0 +py/Ellipsis.m
  5. +4 −0 +py/None.m
  6. +4 −0 +py/asarray.m
  7. +4 −0 +py/asmatrix.m
  8. +4 −0 +py/bool.m
  9. +4 −0 +py/dict.m
  10. +4 −0 +py/float.m
  11. +3 −0 +py/int.m
  12. +5 −1 +py/list.m
  13. +4 −0 +py/slice.m
  14. +5 −1 +py/tuple.m
  15. +22 −0 LICENSE
  16. +4 −0 any2str.m
  17. +3 −0 commands.c
  18. +3 −0 engmodule.c
  19. +4 −3 kw.m
  20. +3 −0 matlabmodule.c
  21. +3 −0 matmodule.c
  22. +15 −6 mexmodule.c
  23. +3 −0 mltypes/__init__.py
  24. +4 −0 mro.m
  25. +3 −0 mxmodule.c
  26. +4 −0 py.m
  27. +4 −0 pybuiltins.m
  28. +4 −0 pycall.m
  29. +4 −0 pyimport.m
  30. +29 −14 pymex.c
  31. +3 −0 pymex.h
  32. +4 −0 pymex.m
  33. +3 −0 sharedfuncs.c
  34. +5 −0 unpy.m
@@ -447,5 +447,7 @@ function disp(obj)
end
-
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
@@ -55,3 +55,7 @@
end
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -44,3 +44,7 @@ function delete(obj)
end
end
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,2 +1,6 @@
function n = Ellipsis()
n = pybuiltins('Ellipsis');
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,2 +1,6 @@
function n = None()
n = pybuiltins('None');
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function a = asarray(varargin)
numpy = pyimport('numpy');
a = numpy.asarray(varargin{:});
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function a = asmatrix(varargin)
numpy = pyimport('numpy');
a = numpy.asmatrix(varargin{:});
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -8,3 +8,7 @@
else
v = py.array(val, 'bool');
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function d = dict(varargin)
dict = pybuiltins('dict');
d = dict(kw(varargin{:}));
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -8,3 +8,7 @@
else
v = py.array(val, 'float');
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -9,3 +9,6 @@
v = py.array(val, 'int');
end
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function l = list(varargin)
list = pybuiltins('list');
-l = list(pymex('CELL_TO_TUPLE', varargin));
+l = list(varargin);
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -9,3 +9,7 @@
end
end
s = slice(varargin{:});
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function t = tuple(varargin)
tuple = pybuiltins('tuple');
-t = tuple(pymex('CELL_TO_TUPLE', varargin));
+t = tuple(varargin);
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
22 LICENSE
@@ -0,0 +1,22 @@
+ Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
View
@@ -18,3 +18,7 @@
out = sprintf('<%s instance (undisplayable)>', class(arg));
end
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
/* format is:
PYMEX(NAME, minimum_number_of_args, maximum_number_of_args, docstring, { function body} )
*/
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
/* This module is a placeholder - eventually, MATLAB's Engine library
(for spawning and talking to MATLAB processes) should get an interface here. */
#define ENGMODULE
View
7 kw.m
@@ -34,8 +34,9 @@
d{kwargs(i).keyword} = kwargs(i).value;
end
end
- end
-
-
+ end
end
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
#include <Python.h>
#include "structmember.h"
#define MATLABMODULE
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
/* This module is a placeholder - eventually, MATLAB's libmat
(for reading MATLAB's "mat" file format) should get an interface here. */
#define MATMODULE
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
/*
The MATLAB Extension library module.
This module (in theory) handles all communication with MATLAB originating
@@ -8,12 +11,18 @@
mexMakeArrayPersistent when it creates things in mex mode.
*/
/*
- FIXME: libmex is not threadsafe. Neither is CPython, but at least we have the GIL.
- MATLAB does not even have a concept of user-accessible independent threads, so it
- should be no surprise that they have no user-accessible locking mechanism. It might
- be appropriate to add a "MIL" to serialize libmex functions. Note that certain libmx
- functions call into libmex when compiled in mex mode, but which ones exactly? That
- appears to be undocumented, but we can make some educated guesses, and should modify
+ FIXME: libmex is not threadsafe. Neither
+ is CPython, but at least we have the GIL.
+ MATLAB does not even have a concept of
+ user-accessible independent threads, so it
+ should be no surprise that they have no
+ user-accessible locking mechanism. It might
+ be appropriate to add a "MIL" to serialize
+ libmex functions. Note that certain libmx
+ functions call into libmex when compiled in
+ mex mode, but which ones exactly? That
+ appears to be undocumented, but we can make
+ some educated guesses, and should modify
matlab.mx accordingly if a MIL is implemented.
*/
#define MEXMODULE
View
@@ -1,3 +1,6 @@
+# Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+# For full license details, see the LICENSE file.
+
from matlab import mx
from matlab import mex
import numbers
View
4 mro.m
@@ -66,3 +66,7 @@
end
end
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
#define MXMODULE
#import "pymex.h"
#import "structmember.h"
View
4 py.m
@@ -3,3 +3,7 @@
for i=1:numel(varargin)
varargout{i} = pymex('TO_PYOBJECT', varargin{i});
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -27,3 +27,7 @@
else
varargout{1} = b;
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,7 @@
function v = pycall(builtin, varargin)
fun = pybuiltins(builtin);
v = fun(varargin{:});
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -11,3 +11,7 @@
else
varargout{1} = imp;
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
43 pymex.c
@@ -1,5 +1,10 @@
-/* The pymex kernel. See commands.c for kernel commands, or do `c = pymex` for a list. */
-/* FIXME: Make pymex and its related python modules GIL aware. See also mexmodule.c for discussion about a 'MIL'. */
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
+/* The pymex kernel. See commands.c for kernel commands,
+ or do `c = pymex` for a list. */
+/* FIXME: Make pymex and its related python modules GIL aware.
+ See also mexmodule.c for discussion about a 'MIL'. */
#include "pymex.h"
#include <mex.h>
#define XMACRO_DEFS "commands.c"
@@ -96,23 +101,25 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
#include XMACRO_DEFS
#undef PYMEX
default:
- mexErrMsgIdAndTxt("pymex:NotImplemented", "pymex command %d not implemented", cmd);
+ mexErrMsgIdAndTxt("pymex:NotImplemented",
+ "pymex command %d not implemented", cmd);
}
}
else if (mxIsChar(prhs[0])) {
char* cmdstring = mxArrayToString(prhs[0]);
if (!cmdstring) {
mexErrMsgIdAndTxt("pymex:badstring",
- "Could not extract the command string for some reason.");
+ "Could not extract the command string.");
}
else if (!strcmp("help", cmdstring)) {
if (nrhs < 2 || !mxIsChar(prhs[1])) {
- mexErrMsgIdAndTxt("pymex:nohelp", "Please specify a PYMEX command to get help for it.");
+ mexErrMsgIdAndTxt("pymex:nohelp",
+ "Please specify a PYMEX command to get help for it.");
}
char* helpname = mxArrayToString(prhs[1]);
if (!helpname) {
mexErrMsgIdAndTxt("pymex:badstring",
- "Could not extract the command string for some reason.");
+ "Could not extract the command string.");
}
else if (!strcmp(helpname, "help")) {
plhs[0] = mxCreateString("Given the name of another PYMEX command, "
@@ -123,7 +130,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
#undef PYMEX
else {
mexErrMsgIdAndTxt("pymex:nohelp",
- "No command '%s' found. Commands are case sensitive.", helpname);
+ "No command '%s' found. Commands are case sensitive.",
+ helpname);
}
mxFree(cmdstring);
}
@@ -132,17 +140,23 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
#include XMACRO_DEFS
#undef PYMEX
else {
- mexErrMsgIdAndTxt("pymex:NotImplemented", "pymex command '%s' not implemented", cmdstring);
+ mexErrMsgIdAndTxt("pymex:NotImplemented",
+ "pymex command '%s' not implemented", cmdstring);
/* mxFree(cmdstring) */
- /* We'd like to free it, but this won't run. Hopefully MATLAB's magic memory manager
- will handle this for us. If not, this shouldn't be a memory leak. Unless someone decides
- to write code that calls pymex directly, misspells the command string, catchs and ignores
- the error, and then somehow doesn't notice that whatever they're doing isn't working.
+ /* We'd like to free it, but this won't run.
+ Hopefully MATLAB's magic memory manager
+ will handle this for us. If not, this shouldn't
+ be a memory leak. Unless someone decides
+ to write code that calls pymex directly, misspells
+ the command string, catchs and ignores
+ the error, and then somehow doesn't notice that
+ whatever they're doing isn't working.
*/
}
}
else {
- mexErrMsgIdAndTxt("pymex:badcmd", "I don't really know what to do with a %s",
+ mexErrMsgIdAndTxt("pymex:badcmd",
+ "I don't really know what to do with a %s",
mxGetClassName(prhs[0]));
}
@@ -153,7 +167,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
PyErr_Fetch(&err_type, &err_value, &err_traceback);
if (!err_value)
err_value = PyUnicode_FromString("<no value>");
- /* FIXME: This seems a tad overcomplicated for some simple string concatentaion. */
+ /* FIXME: This seems a tad overcomplicated for some
+ simple string concatentaion. */
PyObject* pyid = PyUnicode_FromString("Python:");
PyObject* errname = PyObject_GetAttrString(err_type, "__name__");
PyObject* msgid = PyUnicode_Concat(pyid, errname);
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
#ifndef PYMEX_HELPERS_INCLUDED
#define PYMEX_HELPERS_INCLUDED
#include <Python.h>
View
@@ -18,3 +18,7 @@
% To modify the list of commands, edit commands.c and recompile.
error('pymex:NotBuilt','You must first build pymex.%s using the makefile.', mexext);
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+
View
@@ -1,3 +1,6 @@
+/* Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+ For full license details, see the LICENSE file. */
+
#include "pymex.h"
#include <mex.h>
View
5 unpy.m
@@ -1,5 +1,10 @@
+
function varargout = unpy(varargin)
varargout = cell(size(varargin));
for i=1:numel(varargin)
varargout{i} = pymex('TO_MXARRAY', varargin{i});
end
+
+% Copyright (c) 2009 Ken Watford (kwatford@cise.ufl.edu)
+% For full license details, see the LICENSE file.
+

0 comments on commit 1d82901

Please sign in to comment.