Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / PyMite / vm / func.h
blob3405d187db118a37dd31766f413e118bbf2d5be8
1 /*
2 # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall.
4 # This file is part of the PyMite VM.
5 # The PyMite VM is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2.
8 # The PyMite VM is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2
12 # is seen in the file COPYING in this directory.
16 #ifndef __FUNC_H__
17 #define __FUNC_H__
19 /**
20 * \file
21 * \brief Function Object Type
23 * Function object type header.
26 /**
27 * Function obj
29 * A function is like an instance of a code obj.
30 * Contains ptr to its code obj and has its own attributes dict.
32 * The first (__main__) module that is executed has a function obj
33 * created for it to execute the bytecode which builds the module.
35 typedef struct PmFunc_s
37 /** Object descriptor */
38 PmObjDesc_t od;
40 /** Ptr to code obj */
41 pPmCo_t f_co;
43 /** Ptr to attribute dict */
44 pPmDict_t f_attrs;
46 /** Ptr to globals dict */
47 pPmDict_t f_globals;
49 #ifdef HAVE_DEFAULTARGS
50 /** Ptr to tuple holding default args */
51 pPmTuple_t f_defaultargs;
52 #endif /* HAVE_DEFAULTARGS */
54 #ifdef HAVE_CLOSURES
55 /** Ptr to tuple of cell values */
56 pPmTuple_t f_closure;
57 #endif /* HAVE_CLOSURES */
59 } PmFunc_t,
60 *pPmFunc_t;
63 /**
64 * Creates a Function Obj for the given Code Obj.
65 * Allocate space for a Func obj and fill the fields.
67 * @param pco ptr to code obj
68 * @param pglobals ptr to globals dict (from containing func/module)
69 * @param r_pfunc Return by reference; pointer to new function
70 * @return Return status
72 PmReturn_t func_new(pPmObj_t pco, pPmObj_t pglobals, pPmObj_t *r_pfunc);
74 #endif /* __FUNC_H__ */