Home | History | Annotate | Download | only in emugen
      1 /*
      2 * Copyright (C) 2011 The Android Open Source Project
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 * http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 #ifndef __EntryPoint__H__
     17 #define __EntryPoint__H__
     18 
     19 #include <string>
     20 #include <vector>
     21 #include <stdio.h>
     22 
     23 #include "Var.h"
     24 
     25 //---------------------------------------------------
     26 
     27 typedef std::vector<Var> VarsArray;
     28 
     29 class EntryPoint {
     30 public:
     31     EntryPoint();
     32     virtual ~EntryPoint();
     33     bool parse(unsigned int lc, const std::string & str);
     34     void reset(); // reset the class to empty;
     35     void print(FILE *fp = stdout, bool newline = true,
     36                const std::string & name_suffix = std::string(""),
     37                const std::string & name_prefix = std::string(""),
     38                const std::string & ctx_param = std::string("")) const;
     39     const std::string & name() const { return m_name; }
     40     VarsArray & vars() { return m_vars; }
     41     Var & retval() { return m_retval; }
     42     Var * var(const std::string & name);
     43     bool hasPointers();
     44     bool unsupported() const { return m_unsupported; }
     45     void setUnsupported(bool state) { m_unsupported = state; }
     46     bool customDecoder() { return m_customDecoder; }
     47     void setCustomDecoder(bool state) { m_customDecoder = state; }
     48     bool notApi() const { return m_notApi; }
     49     void setNotApi(bool state) { m_notApi = state; }
     50     int setAttribute(const std::string &line, size_t lc);
     51 
     52 private:
     53     enum { PR_RETVAL = 0, PR_NAME, PR_VARS, PR_DONE } prState;
     54     std::string m_name;
     55     Var m_retval;
     56     VarsArray m_vars;
     57     bool m_unsupported;
     58     bool m_customDecoder;
     59     bool m_notApi;
     60 
     61     void err(unsigned int lc, const char *msg) {
     62         fprintf(stderr, "line %d: %s\n", lc, msg);
     63     }
     64 };
     65 
     66 
     67 #endif
     68