-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various cleanups #23
base: master
Are you sure you want to change the base?
Various cleanups #23
Changes from all commits
27b2c84
59c3947
9ee0a86
4321d4b
7b03657
e3d76cc
1d7e42c
043c0a4
f9fde72
99f4927
8ec798e
d02a4f4
33544cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
all: | ||
gcc -pthread *.c -o bin/bitlash | ||
CFLAGS := -DUNIX_BUILD -pthread | ||
LDFLAGS := -lstdc++ -pthread | ||
SOURCES := $(wildcard *.cpp) | ||
BINARY := bin/bitlash | ||
PREFIX := /usr/local | ||
BINPATH := $(PREFIX)/bin | ||
|
||
all: | ||
gcc -DUNIX_BUILD $(LDFLAGS) $(CFLAGS) $(SOURCES) -o $(BINARY) | ||
|
||
install: | ||
sudo cp bin/bitlash /usr/local/bin/ | ||
sudo cp $(BINARY) $(BINPATH) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ jmp_buf env; | |
// | ||
// doCommand: main entry point to execute a bitlash command | ||
// | ||
numvar doCommand(char *cmd) { | ||
numvar doCommand(const char *cmd) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why const? There are many users building buffers with commands to pass to Bitlash. Wouldn't this be a breaking change for them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the reverse. Adding const here means "doCommand will not change the string passed in". Any callers that have a non-const The rationale for this change was that a literal string is also const, so a line like:
results in a compiler warning (at least with -Wall). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That’s cool. I am wondering if this will break the earlier versions of avr-gcc. Would you please collect a list of API-breaking changes and build settings changes in your contribution so we have all of them on the table at once for discussion? Thanks! -br On Feb 5, 2014, at 8:58 AM, Matthijs Kooijman [email protected] wrote:
|
||
return execscript(SCRIPT_RAM, (numvar) cmd, 0); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ const prog_char builtin_table[] PROGMEM = { | |
|
||
|
||
|
||
byte findbuiltin(char *name) { | ||
byte findbuiltin(const char *name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why const? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See reply above. |
||
const prog_char *wordlist = builtin_table; | ||
|
||
while (pgm_read_byte(wordlist)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ byte putlbuf(char c) { | |
|
||
void pointToError(void) { | ||
if (fetchtype == SCRIPT_RAM) { | ||
int i = (char *) fetchptr - lbuf; | ||
int i = (const char *) fetchptr - lbuf; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why const? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See reply above. |
||
if ((i < 0) || (i >= LBUFLEN)) return; | ||
speol(); | ||
while (i-- >= 0) spb('-'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,7 @@ numvar func_pulsein(void) { reqargs(3); return pulseIn(arg1, arg2, arg3); } | |
numvar func_snooze(void) { reqargs(1); snooze(arg1); return 0; } | ||
numvar func_delay(void) { reqargs(1); delay(arg1); return 0; } | ||
|
||
#if !defined(TINY_BUILD) | ||
#if defined(SOFTWARE_SERIAL_TX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't remove the TINY_BUILD mechanism. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not removed, but setBaud is needed only if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, thanks for the clarification. I can live with that. The build flags are not as clean as I’d like but to a degree it cannot be helped. -br On Feb 5, 2014, at 9:01 AM, Matthijs Kooijman [email protected] wrote:
|
||
numvar func_setBaud(void) { reqargs(2); setBaud(arg1, arg2); return 0; } | ||
#endif | ||
|
||
|
@@ -189,14 +189,14 @@ numvar func_bitread(void) { reqargs(2); return (arg1 & ((numvar)1 << arg2)) != 0 | |
numvar func_bitwrite(void) { reqargs(3); return arg3 ? func_bitset() : func_bitclear(); } | ||
|
||
numvar func_getkey(void) { | ||
if (getarg(0) > 0) sp((char *) getarg(1)); | ||
if (getarg(0) > 0) sp((const char *) getarg(1)); | ||
while (!serialAvailable()) {;} // blocking! | ||
return (numvar) serialRead(); | ||
} | ||
|
||
numvar func_getnum(void) { | ||
numvar num = 0; | ||
if (getarg(0) > 0) sp((char *) getarg(1)); | ||
if (getarg(0) > 0) sp((const char *) getarg(1)); | ||
for (;;) { | ||
while (!serialAvailable()) {;} // blocking! | ||
int k = serialRead(); | ||
|
@@ -274,7 +274,9 @@ const prog_char functiondict[] PROGMEM = { | |
"abs\0" | ||
"ar\0" | ||
"aw\0" | ||
#if defined(SOFTWARE_SERIAL_TX) | ||
"baud\0" | ||
#endif | ||
"bc\0" | ||
"beep\0" | ||
"br\0" | ||
|
@@ -351,7 +353,9 @@ const bitlash_function function_table[] PROGMEM = { | |
func_abs, | ||
func_ar, | ||
func_aw, | ||
#if defined(SOFTWARE_SERIAL_TX) | ||
func_setBaud, | ||
#endif | ||
func_bitclear, | ||
func_beep, | ||
func_bitread, | ||
|
@@ -383,13 +387,6 @@ const bitlash_function function_table[] PROGMEM = { | |
}; | ||
#endif | ||
|
||
// Enable USER_FUNCTIONS to include the add_bitlash_function() extension mechanism | ||
// This costs about 256 bytes | ||
// | ||
#if !defined(TINY_BUILD) | ||
#define USER_FUNCTIONS | ||
#endif | ||
|
||
#ifdef USER_FUNCTIONS | ||
#define MAX_USER_FUNCTIONS 20 // increase this if needed, but keep free() > 200 ish | ||
#define USER_FUNCTION_FLAG 0x80 | ||
|
@@ -441,7 +438,7 @@ void addBitlashFunction(const char *name, bitlash_function func_ptr) { | |
// find_user_function: find id in the user function table. | ||
// return true if found, with the user function token in symval (with USER_FUNCTION_FLAG set) | ||
// | ||
char find_user_function(char *id) { | ||
char find_user_function(const char *id) { | ||
symval = 0; | ||
while (symval < bf_install_count) { | ||
if (!strcmp(id, user_functions[symval].name)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support for Arduino pre-1.0 cannot be dropped, for backwards compatibility with existing projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular change does not drop pre-1.0 support, it just removes these includes from bitlash.h in favor of src/bitlash.h (I was planning to drop pre-1.0 support for my upcoming pullrequest, but let's discuss this separately there).