1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS 4 * Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET 5 * 6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 7 * 8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 10 * This file was originally licensed under the terms of the CeCILL v2.1, 11 * and continues to be available under such terms. 12 * For more information, see the COPYING file which you should have received 13 * along with this program. 14 * 15 */ 16 17 #ifndef __CALLABLE_HXX__ 18 #define __CALLABLE_HXX__ 19 20 #include <string> 21 #include "internal.hxx" 22 23 #include "visitor.hxx" 24 25 //disable warnings about exports STL items 26 #ifdef _MSC_VER 27 #pragma warning (disable : 4251) 28 #endif 29 30 namespace types 31 { 32 class EXTERN_AST Callable : public InternalType 33 { 34 public : 35 enum ReturnValue 36 { 37 OK, 38 OK_NoResult, 39 Error 40 }; 41 Callable()42 Callable(): InternalType() 43 { 44 m_iFirstLine = 0; 45 m_iLastLine = 0; 46 } ~Callable()47 virtual ~Callable() {} 48 isCallable()49 bool isCallable() override 50 { 51 return true; 52 } 53 54 virtual ReturnValue call(typed_list &in, optional_list &opt, int _iRetCount, typed_list &out) = 0; 55 56 virtual bool invoke(typed_list & in, optional_list & opt, int _iRetCount, typed_list & out, const ast::Exp & e) override; 57 isInvokable() const58 virtual bool isInvokable() const override 59 { 60 return true; 61 } 62 hasInvokeOption() const63 virtual bool hasInvokeOption() const override 64 { 65 return true; 66 } 67 getInvokeNbIn()68 virtual int getInvokeNbIn() override 69 { 70 return getNbInputArgument(); 71 } 72 getInvokeNbOut()73 virtual int getInvokeNbOut() override 74 { 75 return getNbOutputArgument(); 76 } 77 setName(const std::wstring & _wstName)78 void setName(const std::wstring& _wstName) 79 { 80 m_wstName = _wstName; 81 } getName()82 const std::wstring& getName() 83 { 84 return m_wstName; 85 } setModule(const std::wstring & _wstModule)86 void setModule(const std::wstring& _wstModule) 87 { 88 m_wstModule = _wstModule; 89 } getModule()90 std::wstring getModule() 91 { 92 return m_wstModule; 93 } 94 95 /* return type as string ( double, int, cell, list, ... )*/ getTypeStr() const96 virtual std::wstring getTypeStr() const override 97 { 98 return L"callable"; 99 } 100 /* return type as short string ( s, i, ce, l, ... )*/ 101 virtual std::wstring getShortTypeStr() const override = 0; 102 virtual InternalType* clone(void) override = 0; 103 isAssignable(void)104 virtual bool isAssignable(void) override 105 { 106 return true; 107 } 108 getNbInputArgument(void)109 virtual int getNbInputArgument(void) 110 { 111 return -1; 112 } 113 getNbOutputArgument(void)114 virtual int getNbOutputArgument(void) 115 { 116 return -1; 117 } 118 getFirstLine(void)119 virtual int getFirstLine(void) 120 { 121 return m_iFirstLine; 122 } 123 getLastLine(void)124 virtual int getLastLine(void) 125 { 126 return m_iLastLine; 127 } 128 setLines(int _iFirstLine,int _iLastLine)129 virtual void setLines(int _iFirstLine, int _iLastLine) 130 { 131 m_iFirstLine = _iFirstLine; 132 m_iLastLine = _iLastLine; 133 } 134 135 protected : 136 std::wstring m_wstName; 137 std::string m_stName; 138 std::wstring m_wstModule; 139 int m_iFirstLine; 140 int m_iLastLine; 141 }; 142 } 143 144 145 #endif /* !__CALLABLE_HXX__ */ 146