POV-Ray : Newsgroups : povray.programming : #set source code Server Time
24 Dec 2024 23:36:48 EST (-0500)
  #set source code (Message 1 to 1 of 1)  
From: Chris Huff
Subject: #set source code
Date: 30 Aug 2000 14:18:21
Message: <chrishuff-49FC28.13195430082000@news.povray.org>
Here are the changes necessary to add my #set patch, based on the 
MegaPOV 0.5 source. More details are in the povray.unofficial.patches 
group. If anyone needs help integrating the patch, just ask.
I hope I didn't forget anything...


frame.h:
Add:
#define SetPatch/*Chris Huff 2000.8.30*/

****************************************
parse.h, TOKEN_IDS:
Add:
#ifdef SetPatch
  SET_TOKEN,
#endif

****************************************
tokenize.h, "Global functions":
Add:
#ifdef SetPatch
SYM_ENTRY *Find_Symbol(int Index,char *Name);
#endif


****************************************
****************************************
parse.c, Parse_Declare():
Replace:

  if (Local_Flag=(Token.Token_Id==LOCAL_TOKEN || 
Token.Token_Id==PERCENT_TOKEN))
  {
     Local_Index=Table_Index;
  }
  else
  {
     Local_Index=1;
  }
  
With:

  /*Chris Huff 2000.8.30 - added #set */
#ifdef SetPatch
  Local_Flag = (Token.Token_Id==LOCAL_TOKEN || 
Token.Token_Id==PERCENT_TOKEN);
  if(Local_Flag)
  {
     Local_Index=Table_Index;
  }
  else
  {
     if(Token.Token_Id==SET_TOKEN)
     {
        /*Search for most recent table with an identifier with this name
        Parts copied from Read_Symbol*/
        int Idx;
        int Found = FALSE;
        
        Get_Token();
        /* Search tables from newest to oldest */
        for(Idx=Table_Index; Idx > 0; Idx--)
        {
            if(Find_Symbol(Idx, Token.Token_String) != NULL)
            {
                Local_Index = Idx;
                Found = TRUE;
                break;
            }
        }
        if(Found != TRUE)
        {
            Error("#set cannot assign to uninitialized identifier 
%s.\n", Token.Token_String);
        }
        Unget_Token();
     }
     else
     {
        Local_Index=1;
     }
  }
#else
  if (Local_Flag=(Token.Token_Id==LOCAL_TOKEN || 
Token.Token_Id==PERCENT_TOKEN))
  {
     Local_Index=Table_Index;
  }
  else
  {
     Local_Index=1;
  }
#endif

****************************************
tokenize.c, Reserved_Words:
Add:

#ifdef SetPatch
  {SET_TOKEN, "set"},
#endif
****************************************
tokenize.c, static Function Prototypes:
Replace:

static SYM_ENTRY *Find_Symbol (int Index, char *s);

With:

#ifndef SetPatch
static SYM_ENTRY *Find_Symbol (int Index, char *s);
#endif

****************************************
tokenize.c, Parse_Directive():
Replace:

    CASE2 (DECLARE_TOKEN,LOCAL_TOKEN)

With:

#ifdef SetPatch
    CASE3(DECLARE_TOKEN, LOCAL_TOKEN, SET_TOKEN)
#else
    CASE2 (DECLARE_TOKEN,LOCAL_TOKEN)
#endif

****************************************
tokenize.c, Find_Symbol():
Replace:

static SYM_ENTRY *Find_Symbol(int Index,char *Name)

With:

#ifdef SetPatch
SYM_ENTRY *Find_Symbol(int Index,char *Name)
#else
static SYM_ENTRY *Find_Symbol(int Index,char *Name)
#endif

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.