/[svn]/linuxsampler/trunk/src/scriptvm/common.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/scriptvm/common.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2885 - (hide annotations) (download)
Fri Apr 22 15:37:45 2016 UTC (8 years, 1 month ago) by schoenebeck
File size: 3734 byte(s)
* Instrument script classes now exported with the liblinuxsampler C++ API.
* Added new API method ScriptVM::syntaxHighlighting() which provides
  a convenient syntax highlighting backend for external instrument
  script editor applications.
* Bumped version (2.0.0.svn5).

1 schoenebeck 2596 /*
2 schoenebeck 2885 * Copyright (c) 2014-2016 Christian Schoenebeck
3 schoenebeck 2596 *
4     * http://www.linuxsampler.org
5     *
6     * This file is part of LinuxSampler and released under the same terms.
7     * See README file for details.
8     */
9    
10     #include "common.h"
11 schoenebeck 2598 #include <iostream>
12 schoenebeck 2885 #include "editor/SourceToken.h"
13 schoenebeck 2596
14     namespace LinuxSampler {
15    
16     VMIntExpr* VMExpr::asInt() const {
17     return const_cast<VMIntExpr*>( dynamic_cast<const VMIntExpr*>(this) );
18     }
19    
20     VMStringExpr* VMExpr::asString() const {
21     return const_cast<VMStringExpr*>( dynamic_cast<const VMStringExpr*>(this) );
22     }
23    
24 schoenebeck 2619 VMIntArrayExpr* VMExpr::asIntArray() const {
25     return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) );
26     }
27    
28 schoenebeck 2598 void VMFunction::wrnMsg(const String& txt) {
29     std::cout << "[ScriptVM] " << txt << std::endl;
30     }
31    
32     void VMFunction::errMsg(const String& txt) {
33     std::cerr << "[ScriptVM] " << txt << std::endl;
34     }
35 schoenebeck 2885
36     ///////////////////////////////////////////////////////////////////////
37     // class 'VMSourceToken'
38 schoenebeck 2598
39 schoenebeck 2885 VMSourceToken::VMSourceToken() : m_token(NULL) {
40     }
41    
42     VMSourceToken::VMSourceToken(SourceToken* ct) : m_token(ct) {
43     }
44    
45     VMSourceToken::VMSourceToken(const VMSourceToken& other) {
46     if (other.m_token) {
47     m_token = new SourceToken;
48     *m_token = *other.m_token;
49     } else m_token = NULL;
50     }
51    
52     VMSourceToken::~VMSourceToken() {
53     if (m_token) {
54     delete m_token;
55     m_token = NULL;
56     }
57     }
58    
59     VMSourceToken& VMSourceToken::operator=(const VMSourceToken& other) {
60     if (m_token) delete m_token;
61     if (other.m_token) {
62     m_token = new SourceToken;
63     *m_token = *other.m_token;
64     } else m_token = NULL;
65     return *this;
66     }
67    
68     String VMSourceToken::text() const {
69     return (m_token) ? m_token->text() : "";
70     }
71    
72     int VMSourceToken::firstLine() const {
73     return (m_token) ? m_token->firstLine() : 0;
74     }
75    
76     int VMSourceToken::firstColumn() const {
77     return (m_token) ? m_token->firstColumn() : 0;
78     }
79    
80     bool VMSourceToken::isEOF() const {
81     return (m_token) ? m_token->isEOF() : true;
82     }
83    
84     bool VMSourceToken::isNewLine() const {
85     return (m_token) ? m_token->isNewLine() : false;
86     }
87    
88     bool VMSourceToken::isKeyword() const {
89     return (m_token) ? m_token->isKeyword() : false;
90     }
91    
92     bool VMSourceToken::isVariableName() const {
93     return (m_token) ? m_token->isVariableName() : false;
94     }
95    
96     bool VMSourceToken::isIdentifier() const {
97     return (m_token) ? m_token->isIdentifier() : false;
98     }
99    
100     bool VMSourceToken::isNumberLiteral() const {
101     return (m_token) ? m_token->isNumberLiteral() : false;
102     }
103    
104     bool VMSourceToken::isStringLiteral() const {
105     return (m_token) ? m_token->isStringLiteral() : false;
106     }
107    
108     bool VMSourceToken::isComment() const {
109     return (m_token) ? m_token->isComment() : false;
110     }
111    
112     bool VMSourceToken::isPreprocessor() const {
113     return (m_token) ? m_token->isPreprocessor() : false;
114     }
115    
116     bool VMSourceToken::isOther() const {
117     return (m_token) ? m_token->isOther() : true;
118     }
119    
120     bool VMSourceToken::isIntegerVariable() const {
121     return (m_token) ? m_token->isIntegerVariable() : false;
122     }
123    
124     bool VMSourceToken::isStringVariable() const {
125     return (m_token) ? m_token->isStringVariable() : false;
126     }
127    
128     bool VMSourceToken::isArrayVariable() const {
129     return (m_token) ? m_token->isArrayVariable() : false;
130     }
131    
132     bool VMSourceToken::isEventHandlerName() const {
133     return (m_token) ? m_token->isEventHandlerName() : false;
134     }
135    
136 schoenebeck 2596 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC