Skip to content

Commit

Permalink
DIRECTOR: Lingo: Moved func_mci() to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 45a57ce commit 4e2b3f4
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 41 deletions.
33 changes: 33 additions & 0 deletions engines/director/lingo/lingo-funcs.cpp
@@ -0,0 +1,33 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "engines/director/lingo/lingo.h"

namespace Director {

int Lingo::func_mci(Common::String *s) {
warning("STUB: mci(\"%s\")", s->c_str());

return 0;
}

}
58 changes: 28 additions & 30 deletions engines/director/lingo/lingo-gr.cpp
Expand Up @@ -107,7 +107,11 @@ extern int yylex();
extern int yyparse();
void yyerror(char *s) { error("%s", s); }

int func_mci(Common::String *s);
using namespace Director;

namespace Director {
extern Lingo *g_lingo;
}



Expand All @@ -131,10 +135,10 @@ int func_mci(Common::String *s);

#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 39 "engines/director/lingo/lingo-gr.y"
#line 43 "engines/director/lingo/lingo-gr.y"
{ float f; int i; Common::String *s; }
/* Line 193 of yacc.c. */
#line 138 "engines/director/lingo/lingo-gr.cpp"
#line 142 "engines/director/lingo/lingo-gr.cpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
Expand All @@ -147,7 +151,7 @@ typedef union YYSTYPE


/* Line 216 of yacc.c. */
#line 151 "engines/director/lingo/lingo-gr.cpp"
#line 155 "engines/director/lingo/lingo-gr.cpp"

#ifdef short
# undef short
Expand Down Expand Up @@ -436,8 +440,8 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 62, 62, 63, 66, 67, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 82, 83, 84, 85
0, 66, 66, 67, 70, 71, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 86, 87, 88, 89
};
#endif

Expand Down Expand Up @@ -1359,83 +1363,83 @@ yyparse ()
switch (yyn)
{
case 4:
#line 66 "engines/director/lingo/lingo-gr.y"
#line 70 "engines/director/lingo/lingo-gr.y"
{ warning("%d", (yyvsp[(1) - (1)].i)); ;}
break;

case 5:
#line 67 "engines/director/lingo/lingo-gr.y"
#line 71 "engines/director/lingo/lingo-gr.y"
{ warning("%d", (yyvsp[(1) - (1)].i)); ;}
break;

case 6:
#line 70 "engines/director/lingo/lingo-gr.y"
#line 74 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(1) - (1)].i); ;}
break;

case 7:
#line 71 "engines/director/lingo/lingo-gr.y"
#line 75 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = vars[*(yyvsp[(1) - (1)].s)]; delete (yyvsp[(1) - (1)].s); ;}
break;

case 8:
#line 72 "engines/director/lingo/lingo-gr.y"
#line 76 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(1) - (3)].i) + (yyvsp[(3) - (3)].i); ;}
break;

case 9:
#line 73 "engines/director/lingo/lingo-gr.y"
#line 77 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(1) - (3)].i) - (yyvsp[(3) - (3)].i); ;}
break;

case 10:
#line 74 "engines/director/lingo/lingo-gr.y"
#line 78 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(1) - (3)].i) * (yyvsp[(3) - (3)].i); ;}
break;

case 11:
#line 75 "engines/director/lingo/lingo-gr.y"
#line 79 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(1) - (3)].i) / (yyvsp[(3) - (3)].i); ;}
break;

case 12:
#line 76 "engines/director/lingo/lingo-gr.y"
#line 80 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(2) - (2)].i); ;}
break;

case 13:
#line 77 "engines/director/lingo/lingo-gr.y"
#line 81 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = -(yyvsp[(2) - (2)].i); ;}
break;

case 14:
#line 78 "engines/director/lingo/lingo-gr.y"
#line 82 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = (yyvsp[(2) - (3)].i); ;}
break;

case 16:
#line 82 "engines/director/lingo/lingo-gr.y"
{ func_mci((yyvsp[(2) - (2)].s)); delete (yyvsp[(2) - (2)].s); ;}
#line 86 "engines/director/lingo/lingo-gr.y"
{ g_lingo->func_mci((yyvsp[(2) - (2)].s)); delete (yyvsp[(2) - (2)].s); ;}
break;

case 17:
#line 83 "engines/director/lingo/lingo-gr.y"
#line 87 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = vars[*(yyvsp[(4) - (4)].s)] = (yyvsp[(2) - (4)].i); delete (yyvsp[(4) - (4)].s); ;}
break;

case 18:
#line 84 "engines/director/lingo/lingo-gr.y"
#line 88 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = vars[*(yyvsp[(2) - (4)].s)] = (yyvsp[(4) - (4)].i); delete (yyvsp[(2) - (4)].s); ;}
break;

case 19:
#line 85 "engines/director/lingo/lingo-gr.y"
#line 89 "engines/director/lingo/lingo-gr.y"
{ (yyval.i) = vars[*(yyvsp[(2) - (4)].s)] = (yyvsp[(4) - (4)].i); delete (yyvsp[(2) - (4)].s); ;}
break;


/* Line 1267 of yacc.c. */
#line 1439 "engines/director/lingo/lingo-gr.cpp"
#line 1443 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Expand Down Expand Up @@ -1649,12 +1653,6 @@ yyparse ()
}


#line 88 "engines/director/lingo/lingo-gr.y"

#line 92 "engines/director/lingo/lingo-gr.y"

int func_mci(Common::String *s) {
warning("STUB: mci(\"%s\")", s->c_str());

return 0;
}

2 changes: 1 addition & 1 deletion engines/director/lingo/lingo-gr.h
Expand Up @@ -68,7 +68,7 @@

#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 39 "engines/director/lingo/lingo-gr.y"
#line 43 "engines/director/lingo/lingo-gr.y"
{ float f; int i; Common::String *s; }
/* Line 1529 of yacc.c. */
#line 75 "engines/director/lingo/lingo-gr.hpp"
Expand Down
14 changes: 6 additions & 8 deletions engines/director/lingo/lingo-gr.y
Expand Up @@ -32,7 +32,11 @@ extern int yylex();
extern int yyparse();
void yyerror(char *s) { error("%s", s); }

int func_mci(Common::String *s);
using namespace Director;

namespace Director {
extern Lingo *g_lingo;
}

%}

Expand Down Expand Up @@ -79,16 +83,10 @@ expr: INT { $$ = $1; }
|
;

func: FUNC_MCI STRING { func_mci($2); delete $2; }
func: FUNC_MCI STRING { g_lingo->func_mci($2); delete $2; }
| FUNC_PUT expr OP_INTO VAR { $$ = vars[*$4] = $2; delete $4; }
| FUNC_SET VAR '=' expr { $$ = vars[*$2] = $4; delete $2; }
| FUNC_SET VAR OP_TO expr { $$ = vars[*$2] = $4; delete $2; }
;

%%

int func_mci(Common::String *s) {
warning("STUB: mci(\"%s\")", s->c_str());

return 0;
}
2 changes: 1 addition & 1 deletion engines/director/lingo/lingo-lex.cpp
Expand Up @@ -502,7 +502,7 @@ char *yytext;
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-gr.h"

void yyparse();
int yyparse();

#line 508 "engines/director/lingo/lingo-lex.cpp"

Expand Down
2 changes: 1 addition & 1 deletion engines/director/lingo/lingo-lex.l
Expand Up @@ -30,7 +30,7 @@
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-gr.h"

void yyparse();
int yyparse();

%}

Expand Down
4 changes: 4 additions & 0 deletions engines/director/lingo/lingo.cpp
Expand Up @@ -24,6 +24,8 @@

namespace Director {

Lingo *g_lingo;

struct EventHandlerType {
LEvent handler;
const char *name;
Expand Down Expand Up @@ -65,6 +67,8 @@ struct EventHandlerType {
};

Lingo::Lingo() {
g_lingo = this;

for (const EventHandlerType *t = &eventHanlerDescs[0]; t->handler != kEventNone; ++t)
_eventHandlerTypes[t->handler] = t->name;
}
Expand Down
2 changes: 2 additions & 0 deletions engines/director/lingo/lingo.h
Expand Up @@ -74,6 +74,8 @@ class Lingo {

int parse(char *code);

int func_mci(Common::String *s);

private:
Common::HashMap<uint32, const char *> _eventHandlerTypes;
};
Expand Down
1 change: 1 addition & 0 deletions engines/director/module.mk
Expand Up @@ -8,6 +8,7 @@ MODULE_OBJS = \
score.o \
sound.o \
lingo/lingo.o \
lingo/lingo-funcs.o \
lingo/lingo-gr.o \
lingo/lingo-lex.o

Expand Down

0 comments on commit 4e2b3f4

Please sign in to comment.