parameters: (self)
return_statement: return string
docstring: crates the main entry point for the mex file
docstring_summary: crates the main entry point for the mex file
docstring_tokens: crates the main entry point for the mex file
function: def create_mex_dispatcher(self):
          '''crates the main entry point for the mex file'''        
          
          indent = 4*' '   
          string = '''
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  
  '''
          string += '/** main entry point of MATLAB, deals as a function dispatcher */\n'
          string += 'void mexFunction%s\n{\n' % self.mex_body
          
          string += '''
      char * functionName = NULL;
      if (nrhs < 1) {
          mexErrMsgTxt("No function argument given!");
          return;
      }
  
      mxToString(prhs[0],&functionName);
  
  ''' 
          call = ''
          defs = (fun for fun in self.cparser.declarations if fun.method_name not in self.blacklist)
          for index, func in enumerate(defs):
              if index > 0:
                  call += 'else '
              call += 'if (strcmp(functionName, "%s") == 0) {\n' % func.method_name
              call += '    mex_%s(nlhs, plhs, nrhs, prhs);\n' % func.method_name
              call += '}\n'
          
          call += '''else {
      // this is only executed if the function could not be identified
      char text[255];
  '''
          call += '    snprintf(text, 250, "%%s is not a valid %s function!\\n", functionName);\n' % self.prefix
          call += '''    mxFree(functionName);
      mexErrMsgTxt(text);
  }
  mxFree(functionName);
  ''' 
          
          for line in call.splitlines():
              string += indent + line + '\n'
              
          string += '}\n'
          string += '''
  #ifdef __cplusplus
  } /* extern C */
  #endif
  
  '''   
          return string
function_tokens: def create_mex_dispatcher ( self ) : indent = 4 * ' ' string = '''
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  
  ''' string += '/** main entry point of MATLAB, deals as a function dispatcher */\n' string += 'void mexFunction%s\n{\n' % self . mex_body string += '''
      char * functionName = NULL;
      if (nrhs < 1) {
          mexErrMsgTxt("No function argument given!");
          return;
      }
  
      mxToString(prhs[0],&functionName);
  
  ''' call = '' defs = ( fun for fun in self . cparser . declarations if fun . method_name not in self . blacklist ) for index , func in enumerate ( defs ) : if index > 0 : call += 'else ' call += 'if (strcmp(functionName, "%s") == 0) {\n' % func . method_name call += '    mex_%s(nlhs, plhs, nrhs, prhs);\n' % func . method_name call += '}\n' call += '''else {
      // this is only executed if the function could not be identified
      char text[255];
  ''' call += '    snprintf(text, 250, "%%s is not a valid %s function!\\n", functionName);\n' % self . prefix call += '''    mxFree(functionName);
      mexErrMsgTxt(text);
  }
  mxFree(functionName);
  ''' for line in call . splitlines ( ) : string += indent + line + '\n' string += '}\n' string += '''
  #ifdef __cplusplus
  } /* extern C */
  #endif
  
  ''' return string