Skip to content

Commit

Permalink
Remember the sqVirtualMachine changes for methodReturnFloat: et al.
Browse files Browse the repository at this point in the history
Fix compilation of the SerialPlugin on Mac OS X (temporary; the
correct fix is to have the Mac builds build from the unix sources).
  • Loading branch information
eliotmiranda committed Mar 17, 2018
1 parent 54d6379 commit f45adcf
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
3 changes: 3 additions & 0 deletions platforms/Cross/plugins/SerialPlugin/SerialPlugin.h
Expand Up @@ -9,6 +9,9 @@ int serialPortClose(int portNum);
int serialPortCount(void);
int serialPortOpen(int portNum, int baudRate, int stopBitsType, int parityType, int dataBits,
int inFlowCtrl, int outFlowCtrl, int xOnChar, int xOffChar);
int serialPortOpenByName(const char *portName, int baudRate, int stopBitsType,
int parityType, int dataBits,
int inFlowCtrl, int outFlowCtrl, int xOnChar, int xOffChar);
int serialPortReadInto(int portNum, int count, void *bufferPtr);
int serialPortReadIntoByName(const char *portName, int count, void *bufferPtr);
int serialPortWriteFrom(int portNum, int count, void *bufferPtr);
Expand Down
14 changes: 14 additions & 0 deletions platforms/Cross/vm/sqVirtualMachine.c
Expand Up @@ -217,10 +217,17 @@ sqInt addGCRoot(sqInt *varLoc);
sqInt removeGCRoot(sqInt *varLoc);

/* Proxy declarations for v1.10 */
# if VM_PROXY_MINOR > 13 /* OS Errors available in primitives; easy return forms */
sqInt methodReturnBool(sqInt);
sqInt methodReturnFloat(double);
sqInt methodReturnInteger(sqInt);
sqInt methodReturnString(char *);
# else
sqInt methodArg(sqInt index);
sqInt objectArg(sqInt index);
sqInt integerArg(sqInt index);
double floatArg(sqInt index);
#endif
sqInt methodReturnValue(sqInt oop);
sqInt topRemappableOop(void);

Expand Down Expand Up @@ -464,10 +471,17 @@ struct VirtualMachine* sqGetInterpreterProxy(void)
#endif

#if VM_PROXY_MINOR > 9
# if VM_PROXY_MINOR > 13 /* OS Errors available in primitives; easy return forms */
VM->methodReturnBool = methodReturnBool;
VM->methodReturnFloat = methodReturnFloat;
VM->methodReturnInteger = methodReturnInteger;
VM->methodReturnString = methodReturnString;
# else
VM->methodArg = methodArg;
VM->objectArg = objectArg;
VM->integerArg = integerArg;
VM->floatArg = floatArg;
# endif
VM->methodReturnValue = methodReturnValue;
VM->topRemappableOop = topRemappableOop;
#endif
Expand Down
14 changes: 11 additions & 3 deletions platforms/Cross/vm/sqVirtualMachine.h
Expand Up @@ -180,7 +180,7 @@ typedef struct VirtualMachine {
/* InterpreterProxy methodsFor: 'compiler' */

CompilerHook *(*compilerHookVector)(void);
sqInt (*setCompilerInitialized)(sqInt initFlag);
sqInt (*setCompilerInitialized)(sqInt initFlag);
# endif

#if VM_PROXY_MINOR > 1
Expand Down Expand Up @@ -297,10 +297,18 @@ typedef struct VirtualMachine {
#endif

#if VM_PROXY_MINOR > 9
sqInt (*methodArg) (sqInt index);
# if VM_PROXY_MINOR > 13 /* OS Errors available in primitives; easy return forms */
sqInt (*methodReturnBool)(sqInt);
sqInt (*methodReturnFloat)(double);
sqInt (*methodReturnInteger)(sqInt);
sqInt (*methodReturnString)(char *);
# define returnSelf() methodReturnValue(0)
# else
sqInt (*methodArg) (sqInt index); /* These ended up never being used. */
sqInt (*objectArg) (sqInt index);
sqInt (*integerArg) (sqInt index);
double (*floatArg) (sqInt index);
# endif
sqInt (*methodReturnValue) (sqInt oop);
sqInt (*topRemappableOop) (void);
#endif
Expand Down Expand Up @@ -348,7 +356,7 @@ typedef struct VirtualMachine {
sqInt (*unpinObject)(sqInt objOop);
#endif

#if VM_PROXY_MINOR > 13 /* OS Errors available in primitives */
#if VM_PROXY_MINOR > 13 /* OS Errors available in primitives; easy return forms (see above) */
sqInt (*primitiveFailForOSError)(sqLong osErrorCode);
#endif
} VirtualMachine;
Expand Down
29 changes: 29 additions & 0 deletions platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c
Expand Up @@ -88,6 +88,16 @@ EXPORT (int) serialPortOpen(
return false;
}

EXPORT (int) serialPortOpenByName(
const char *portName, int baudRate, int stopBitsType, int parityType, int dataBits,
int inFlowCtrl, int outFlowCtrl, int xOnChar, int xOffChar) {
/* Open the given serial port using the given settings. The baud rate can be
any number between about 224 and 57600; the driver will pick a clock
divisor that will generate the closest available baud rate. */
#pragma unused(portName,baudRate,stopBitsType,parityType,dataBits,inFlowCtrl,outFlowCtrl,xOnChar,xOffChar)
return false;
}

EXPORT (int) serialPortReadInto(int portNum, int count, void *bufferPtr) {
/* Read up to count bytes from the given serial port into the given byte array.
Read only up to the number of bytes in the port's input buffer; if fewer bytes
Expand All @@ -97,6 +107,15 @@ EXPORT (int) serialPortReadInto(int portNum, int count, void *bufferPtr) {
return false;
}

EXPORT (int) serialPortReadIntoByName(const char *portName, int count, void *bufferPtr) {
/* Read up to count bytes from the given serial port into the given byte array.
Read only up to the number of bytes in the port's input buffer; if fewer bytes
than count have been received, do not wait for additional data to arrive.
Return zero if no data is available. */
#pragma unused(portName,count,bufferPtr)
return false;
}

EXPORT (int) serialPortWriteFrom(int portNum, int count, void *bufferPtr) {
/* Write count bytes from the given byte array to the given serial port's
output buffer. Return the number of bytes written. This implementation is
Expand All @@ -116,3 +135,13 @@ EXPORT (int) serialPortWriteFrom(int portNum, int count, void *bufferPtr) {
}
return byteCount;
}

EXPORT (int) serialPortWriteFromByName(const char *portName, int count, void *bufferPtr) {
/* Write count bytes from the given byte array to the given serial port's
output buffer. Return the number of bytes written. This implementation is
synchronous: it doesn't return until the data has been sent. However, other
implementations may return before transmission is complete. */

#pragma unused(portName,count,bufferPtr)
return interpreterProxy->success(false);
}

0 comments on commit f45adcf

Please sign in to comment.