c++ compatibility: rename reserved c++ keywords 'public' and 'this'

This commit is contained in:
Daniel Appiagyei
2023-09-10 12:32:34 -07:00
committed by Xiang Xiao
parent 017ccca5d6
commit 5bfda12634
56 changed files with 647 additions and 628 deletions
+39 -35
View File
@@ -36,12 +36,13 @@
* Name: stdsostream_putc
****************************************************************************/
static void stdsostream_putc(FAR struct lib_sostream_s *this, int ch)
static void stdsostream_putc(FAR struct lib_sostream_s *self, int ch)
{
FAR struct lib_stdsostream_s *sthis = (FAR struct lib_stdsostream_s *)this;
FAR struct lib_stdsostream_s *stream =
(FAR struct lib_stdsostream_s *)self;
int result;
DEBUGASSERT(this && sthis->stream);
DEBUGASSERT(self && stream->handle);
/* Loop until the character is successfully transferred or an irrecoverable
* error occurs.
@@ -49,10 +50,10 @@ static void stdsostream_putc(FAR struct lib_sostream_s *this, int ch)
do
{
result = fputc(ch, sthis->stream);
result = fputc(ch, stream->handle);
if (result != EOF)
{
this->nput++;
self->nput++;
return;
}
@@ -67,13 +68,14 @@ static void stdsostream_putc(FAR struct lib_sostream_s *this, int ch)
* Name: stdsostream_puts
****************************************************************************/
static int stdsostream_puts(FAR struct lib_sostream_s *this,
static int stdsostream_puts(FAR struct lib_sostream_s *self,
FAR const void *buffer, int len)
{
FAR struct lib_stdsostream_s *sthis = (FAR struct lib_stdsostream_s *)this;
FAR struct lib_stdsostream_s *stream =
(FAR struct lib_stdsostream_s *)self;
int result;
DEBUGASSERT(this && sthis->stream);
DEBUGASSERT(self && stream->handle);
/* Loop until the character is successfully transferred or an irrecoverable
* error occurs.
@@ -81,10 +83,10 @@ static int stdsostream_puts(FAR struct lib_sostream_s *this,
do
{
result = lib_fwrite(buffer, len, sthis->stream);
result = lib_fwrite(buffer, len, stream->handle);
if (result >= 0)
{
this->nput += result;
self->nput += result;
return result;
}
@@ -104,12 +106,13 @@ static int stdsostream_puts(FAR struct lib_sostream_s *this,
****************************************************************************/
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
static int stdsostream_flush(FAR struct lib_sostream_s *this)
static int stdsostream_flush(FAR struct lib_sostream_s *self)
{
FAR struct lib_stdsostream_s *sthis = (FAR struct lib_stdsostream_s *)this;
FAR struct lib_stdsostream_s *stream =
(FAR struct lib_stdsostream_s *)self;
DEBUGASSERT(sthis != NULL && sthis->stream != NULL);
return lib_fflush(sthis->stream, true);
DEBUGASSERT(stream != NULL && stream->handle != NULL);
return lib_fflush(stream->handle, true);
}
#endif
@@ -117,13 +120,14 @@ static int stdsostream_flush(FAR struct lib_sostream_s *this)
* Name: stdsostream_seek
****************************************************************************/
static off_t stdsostream_seek(FAR struct lib_sostream_s *this, off_t offset,
static off_t stdsostream_seek(FAR struct lib_sostream_s *self, off_t offset,
int whence)
{
FAR struct lib_stdsostream_s *sthis = (FAR struct lib_stdsostream_s *)this;
FAR struct lib_stdsostream_s *stream =
(FAR struct lib_stdsostream_s *)self;
DEBUGASSERT(sthis != NULL && sthis->stream != NULL);
return fseek(sthis->stream, offset, whence);
DEBUGASSERT(stream != NULL && stream->handle != NULL);
return fseek(stream->handle, offset, whence);
}
/****************************************************************************
@@ -137,48 +141,48 @@ static off_t stdsostream_seek(FAR struct lib_sostream_s *this, off_t offset,
* Initializes a stream for use with a FILE instance.
*
* Input Parameters:
* outstream - User allocated, uninitialized instance of struct
* lib_stdsostream_s to be initialized.
* stream - User provided stream instance (must have been opened for
* write access).
* stream - User allocated, uninitialized instance of struct
* lib_stdsostream_s to be initialized.
* handle - User provided FILE instance (must have been opened for
* write access).
*
* Returned Value:
* None (User allocated instance initialized).
*
****************************************************************************/
void lib_stdsostream(FAR struct lib_stdsostream_s *outstream,
FAR FILE *stream)
void lib_stdsostream(FAR struct lib_stdsostream_s *stream,
FAR FILE *handle)
{
/* Select the putc operation */
outstream->public.putc = stdsostream_putc;
outstream->public.puts = stdsostream_puts;
stream->common.putc = stdsostream_putc;
stream->common.puts = stdsostream_puts;
/* Select the correct flush operation. This flush is only called when
* a newline is encountered in the output stream. However, we do not
* want to support this line buffering behavior if the stream was
* a newline is encountered in the output file stream. However, we do not
* want to support this line buffering behavior if the file was
* opened in binary mode. In binary mode, the newline has no special
* meaning.
*/
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
if (stream->fs_bufstart != NULL && (stream->fs_oflags & O_TEXT) != 0)
if (handle->fs_bufstart != NULL && (handle->fs_oflags & O_TEXT) != 0)
{
outstream->public.flush = stdsostream_flush;
stream->common.flush = stdsostream_flush;
}
else
#endif
{
outstream->public.flush = lib_snoflush;
stream->common.flush = lib_snoflush;
}
/* Select the seek operation */
outstream->public.seek = stdsostream_seek;
stream->common.seek = stdsostream_seek;
/* Set the number of bytes put to zero and remember the stream */
/* Set the number of bytes put to zero and remember the handle */
outstream->public.nput = 0;
outstream->stream = stream;
stream->common.nput = 0;
stream->handle = handle;
}