Skip to content

Commit

Permalink
PICOC_VERSION is now defined as a macro in picoc
Browse files Browse the repository at this point in the history
  • Loading branch information
zik.saleeba committed Feb 14, 2011
1 parent b1d2b2f commit 151bced
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ all: depend $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

# rebuild the version number every time so we always have the
# correct subversion version
version.h:
echo "#define PICOC_SUBVERSION_VERSION \"`svnversion`\"" > version.h

.PHONY: version.h

test: all
(cd tests; make test)

clean:
rm -f $(TARGET) $(OBJS) *~
rm -f $(TARGET) $(OBJS) version.h *~

count:
@echo "Core:"
Expand All @@ -30,6 +37,7 @@ count:
@cat $(SRCS) *.h */*.h | wc

depend:
touch version.h
$(CC) -MM $(SRCS) >.depend

-include .depend
19 changes: 17 additions & 2 deletions clibrary.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#include "picoc.h"
#include "version.h"

/* initialise a library */
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList)
/* the picoc version string */
#define PICOC_VERSION "v2.1 beta r" PICOC_SUBVERSION_VERSION
static const char *VersionString = NULL;


/* global initialisation for libraries */
void LibraryInit()
{
/* define the version number macro */
VersionString = TableStrRegister(PICOC_VERSION);
VariableDefinePlatformVar(NULL, "PICOC_VERSION", CharPtrType, (union AnyValue *)&VersionString, FALSE);
}

/* add a library */
void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList)
{
struct ParseState Parser;
int Count;
Expand All @@ -11,6 +25,7 @@ void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct Libr
void *Tokens;
const char *IntrinsicName = TableStrRegister("c library");

/* read all the library definitions */
for (Count = 0; FuncList[Count].Prototype != NULL; Count++)
{
Tokens = LexAnalyse(IntrinsicName, FuncList[Count].Prototype, strlen((char *)FuncList[Count].Prototype), NULL);
Expand Down
2 changes: 1 addition & 1 deletion include.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void IncludeFile(char *FileName)

/* set up the library functions */
if (LInclude->FuncList != NULL)
LibraryInit(&GlobalTable, FileName, LInclude->FuncList);
LibraryAdd(&GlobalTable, FileName, LInclude->FuncList);
}

return;
Expand Down
3 changes: 2 additions & 1 deletion picoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ void Initialise(int StackSize)
#ifndef NO_HASH_INCLUDE
IncludeInit();
#endif
LibraryInit();
#ifdef BUILTIN_MINI_STDLIB
LibraryInit(&GlobalTable, "c library", &CLibrary[0]);
LibraryAdd(&GlobalTable, "c library", &CLibrary[0]);
CLibraryInit();
#endif
PlatformLibraryInit();
Expand Down
3 changes: 2 additions & 1 deletion picoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ void *VariableDereferencePointer(struct ParseState *Parser, struct Value *Pointe

/* clibrary.c */
void BasicIOInit();
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList);
void LibraryInit();
void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList);
void CLibraryInit();
void PrintCh(char OutCh, IOFILE *Stream);
void PrintSimpleInt(long Num, IOFILE *Stream);
Expand Down

0 comments on commit 151bced

Please sign in to comment.