Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers func.h Source File

func.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall.
00003 #
00004 # This file is part of the PyMite VM.
00005 # The PyMite VM is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2.
00007 #
00008 # The PyMite VM is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2
00012 # is seen in the file COPYING in this directory.
00013 */
00014 
00015 
00016 #ifndef __FUNC_H__
00017 #define __FUNC_H__
00018 
00019 /**
00020  * \file
00021  * \brief Function Object Type
00022  *
00023  * Function object type header.
00024  */
00025 
00026 /**
00027  * Function obj
00028  *
00029  * A function is like an instance of a code obj.
00030  * Contains ptr to its code obj and has its own attributes dict.
00031  *
00032  * The first (__main__) module that is executed has a function obj
00033  * created for it to execute the bytecode which builds the module.
00034  */
00035 typedef struct PmFunc_s
00036 {
00037     /** Object descriptor */
00038     PmObjDesc_t od;
00039 
00040     /** Ptr to code obj */
00041     pPmCo_t f_co;
00042 
00043     /** Ptr to attribute dict */
00044     pPmDict_t f_attrs;
00045 
00046     /** Ptr to globals dict */
00047     pPmDict_t f_globals;
00048 
00049 #ifdef HAVE_DEFAULTARGS
00050     /** Ptr to tuple holding default args */
00051     pPmTuple_t f_defaultargs;
00052 #endif /* HAVE_DEFAULTARGS */
00053 
00054 #ifdef HAVE_CLOSURES
00055     /** Ptr to tuple of cell values */
00056     pPmTuple_t f_closure;
00057 #endif /* HAVE_CLOSURES */
00058 
00059 } PmFunc_t,
00060  *pPmFunc_t;
00061 
00062 
00063 /**
00064  * Creates a Function Obj for the given Code Obj.
00065  * Allocate space for a Func obj and fill the fields.
00066  *
00067  * @param   pco ptr to code obj
00068  * @param   pglobals ptr to globals dict (from containing func/module)
00069  * @param   r_pfunc Return by reference; pointer to new function
00070  * @return  Return status
00071  */
00072 PmReturn_t func_new(pPmObj_t pco, pPmObj_t pglobals, pPmObj_t *r_pfunc);
00073 
00074 #endif /* __FUNC_H__ */