[INTERPRETER]

* BUG: Do not use GB.ReturnNull() when returning a void string anymore. Use
  the new GB.ReturnVoidString() API instead.


git-svn-id: svn://localhost/gambas/trunk@4216 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-10-24 19:33:41 +00:00
parent 3cb1789157
commit 95aa370a7e
29 changed files with 72 additions and 70 deletions

View file

@ -118,7 +118,6 @@ BEGIN_PROPERTY(CGRIDVIEW_data)
if (!THIS->data)
{
GB.Error("No data event");
GB.ReturnNull();
return;
}
@ -452,7 +451,6 @@ BEGIN_METHOD(CGRIDVIEW_columns_get,GB_INTEGER Column;)
if ( (VARG(Column)<0) || (VARG(Column)>=WIDGET->columnCount() ) )
{
GB.Error("Bad column index");
GB.ReturnNull();
return;
}
@ -576,7 +574,6 @@ BEGIN_METHOD(CGRIDVIEW_rows_get,GB_INTEGER Row;)
if ( (VARG(Row)<0) || (VARG(Row)>=WIDGET->rowCount() ) )
{
GB.Error("Bad row index");
GB.ReturnNull();
return;
}
@ -843,14 +840,12 @@ BEGIN_METHOD(CGRIDVIEW_get, GB_INTEGER Key; GB_INTEGER Column;)
if ( (VARG(Key)<0) || (VARG(Key)>=WIDGET->rowCount()) )
{
GB.Error("Bad row index");
GB.ReturnNull();
return;
}
if ( (VARG(Column)<0) || (VARG(Column)>=WIDGET->columnCount()) )
{
GB.Error("Bad column index");
GB.ReturnNull();
return;
}

View file

@ -393,7 +393,7 @@ END_PROPERTY
BEGIN_PROPERTY(Curl_ErrorText)
if (THIS_STATUS >= 0)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnConstZeroString(curl_easy_strerror((-THIS_STATUS) - 1000));

View file

@ -740,7 +740,7 @@ Returns current foreing host IP (only when connected via TCP)
BEGIN_PROPERTY(Socket_RemoteHost)
if (SOCKET->status != NET_CONNECTED || THIS->conn_type != NET_TYPE_INTERNET)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(THIS->sRemoteHostIP);
@ -752,7 +752,7 @@ Returns current local host IP (only when connected via TCP)
BEGIN_PROPERTY(Socket_LocalHost)
if (SOCKET->status != NET_CONNECTED || THIS->conn_type != NET_TYPE_INTERNET)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(THIS->sLocalHostIP);
@ -804,14 +804,14 @@ BEGIN_METHOD_VOID(Socket_Peek)
{
/* An error happened while trying to receive data : SOCKET ERROR */
if (buf) GB.Free(POINTER(&buf));
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
if (retval > 0)
GB.ReturnNewString(buf, retval);
else
GB.ReturnNull();
GB.ReturnVoidString();
if (buf) GB.Free(POINTER(&buf));

View file

@ -401,7 +401,7 @@ BEGIN_PROPERTY(CUDPSOCKET_SourceHost)
if (THIS->addr.a.sa_family == PF_INET)
GB.ReturnNewZeroString(inet_ntoa(THIS->addr.in.sin_addr));
else
GB.ReturnNull();
GB.ReturnVoidString();
END_PROPERTY
@ -419,7 +419,7 @@ BEGIN_PROPERTY(CUDPSOCKET_SourcePath)
if (THIS->addr.a.sa_family == PF_UNIX)
GB.ReturnNewZeroString(THIS->addr.un.sun_path);
else
GB.ReturnNull();
GB.ReturnVoidString();
END_PROPERTY
@ -527,7 +527,7 @@ BEGIN_METHOD_VOID (CUDPSOCKET_Peek)
CUdpSocket_stream_close(&SOCKET->stream);
SOCKET->status = NET_CANNOT_READ;
GB.Raise(THIS,CUDPSOCKET_SocketError,0);
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
//NoBlock++;
@ -535,12 +535,12 @@ BEGIN_METHOD_VOID (CUDPSOCKET_Peek)
if (retval>0)
GB.ReturnNewString(sData,retval);
else
GB.ReturnNull();
GB.ReturnVoidString();
GB.Free(POINTER(&sData));
}
else
{
GB.ReturnNull();
GB.ReturnVoidString();
}
END_METHOD

View file

@ -47,7 +47,7 @@ BEGIN_METHOD(GLGETPROGRAMINFOLOG, GB_INTEGER program)
if (!length)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
else

View file

@ -93,7 +93,7 @@ BEGIN_METHOD(GLGETSHADERINFOLOG, GB_INTEGER shader)
if (!length)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
else
@ -127,7 +127,7 @@ BEGIN_METHOD(GLGETSHADERSOURCE, GB_INTEGER shader)
if (!length)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
else

View file

@ -164,7 +164,7 @@ END_PROPERTY
BEGIN_PROPERTY(RegExp_Text)
if (THIS->count == 0)
GB.ReturnNull();
GB.ReturnVoidString();
else
return_match(THIS, 0);

View file

@ -165,13 +165,15 @@ static void aux_return_date_info(void *_object, const char *key)
char *datestr=NULL,*tofree=NULL;
int nnum;
GB.ReturnDate(NULL);
THIS->doc->getDocInfo (&obj);
if (!obj.isDict()) { GB.ReturnNull(); return; }
if (!obj.isDict()) return;
info_dict=obj.getDict();
info_dict->lookup ((char *)key, &dst);
if (!dst.isString ()) { GB.ReturnNull(); }
else {
if (dst.isString ())
{
goo = dst.getString();
if (goo->hasUnicodeMarker())
GB.ConvString (&datestr,goo->getCString()+2,goo->getLength()-2,"UTF-16BE","UTF-8");
@ -181,18 +183,14 @@ static void aux_return_date_info(void *_object, const char *key)
tofree=datestr;
}
if (!datestr) { GB.ReturnNull(); }
else
if (datestr)
{
if (datestr[0] == 'D' && datestr[1] == ':') datestr += 2;
nnum=sscanf(datestr, "%4hd%2hd%2hd%2hd%2hd%2hd",&ds.year, &ds.month, \
&ds.day, &ds.hour, &ds.min, &ds.sec);
if (nnum != 6) { GB.ReturnNull(); }
else
if (nnum == 6)
{
if (GB.MakeDate(&ds,&ret))
GB.ReturnNull();
else
if (!GB.MakeDate(&ds,&ret))
GB.ReturnDate(&ret);
}
}
@ -507,7 +505,6 @@ BEGIN_METHOD(PDFDOCUMENT_get,GB_INTEGER index;)
if (!THIS->doc || (VARG(index)<1) || ( VARG(index)>THIS->doc->getNumPages() ) )
{
GB.Error("Invalid page number");
GB.ReturnNull();
return;
}
@ -1007,7 +1004,7 @@ BEGIN_METHOD (PDFPAGELINKS_get,GB_INTEGER ind;)
}
}
if (!pok) { GB.Error("Out of bounds"); GB.ReturnNull(); return; }
if (!pok) { GB.Error("Out of bounds"); return; }
THIS->lcurrent=VARG(ind);
THIS->action=THIS->links->getLink(THIS->lcurrent)->getAction();

View file

@ -203,7 +203,7 @@ BEGIN_PROPERTY(CLISTBOX_text)
QListWidgetItem *item = WIDGET->currentItem();
if (!item)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnNewZeroString(TO_UTF8(item->text()));

View file

@ -695,7 +695,7 @@ BEGIN_PROPERTY(TreeView_key)
//THIS->item = item;
if (item == 0)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(item->key);
@ -888,7 +888,7 @@ END_METHOD
BEGIN_PROPERTY(TreeViewItem_key)
if (!THIS->item)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(THIS->item->key);

View file

@ -471,7 +471,7 @@ BEGIN_PROPERTY(CMENU_shortcut)
if (CMENU_is_toplevel(THIS) || THIS->menu)
{
if (READ_PROPERTY)
GB.ReturnNull();
GB.ReturnVoidString();
return;
}

View file

@ -346,7 +346,7 @@ BEGIN_METHOD(CTEXTAREA_line_get, int line)
int line = PARAM(line);
if (line < 0 || line >= WIDGET->numLines())
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnNewZeroString(WIDGET->textLine(PARAM(line)));

View file

@ -722,7 +722,7 @@ BEGIN_PROPERTY(CTREEVIEW_key)
//THIS->item = item;
if (item == 0)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(item->key);
@ -918,7 +918,7 @@ END_METHOD
BEGIN_PROPERTY(CTREEVIEWITEM_key)
if (!THIS->item)
GB.ReturnNull();
GB.ReturnVoidString();
else
GB.ReturnString(THIS->item->key);

View file

@ -46,7 +46,7 @@ BEGIN_PROPERTY(Cookie_ExpirationDate)
{
if (COOKIE->isSessionCookie())
{
GB.ReturnNull();
GB.ReturnDate(NULL);
return;
}

View file

@ -352,7 +352,7 @@ BEGIN_PROPERTY(WebViewAuth_Url)
if (THIS->reply)
GB.ReturnNewZeroString(TO_UTF8(THIS->reply->url().toString()));
else
GB.ReturnNull();
GB.ReturnVoidString();
END_PROPERTY
@ -361,7 +361,7 @@ BEGIN_PROPERTY(WebViewAuth_Realm)
if (THIS->authenticator)
GB.ReturnNewZeroString(TO_UTF8(THIS->authenticator->realm()));
else
GB.ReturnNull();
GB.ReturnVoidString();
END_PROPERTY
@ -372,7 +372,7 @@ BEGIN_PROPERTY(WebViewAuth_User)
if (THIS->authenticator)
GB.ReturnNewZeroString(TO_UTF8(THIS->authenticator->user()));
else
GB.ReturnNull();
GB.ReturnVoidString();
}
else
{
@ -391,7 +391,7 @@ BEGIN_PROPERTY(WebViewAuth_Password)
if (THIS->authenticator)
GB.ReturnNewZeroString(TO_UTF8(THIS->authenticator->password()));
else
GB.ReturnNull();
GB.ReturnVoidString();
}
else
{

View file

@ -1506,8 +1506,8 @@ Features
***************************************************************************/
void return_array(char *array,long mmax)
{
long bucle;
long max=mmax;
int bucle;
int max=mmax;
for (bucle=0;bucle<max;bucle++)
{
@ -1537,7 +1537,7 @@ BEGIN_PROPERTY(VideoDevice_Driver)
else dev = DEVICE->dev;
if ( ioctl(dev,VIDIOC_QUERYCAP,&vcap)!=0 )
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
return_array((char*)vcap.driver,16);
@ -1557,7 +1557,7 @@ BEGIN_PROPERTY(VideoDevice_Bus)
if ( ioctl(dev,VIDIOC_QUERYCAP,&vcap)!=0 )
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
@ -1580,7 +1580,7 @@ BEGIN_PROPERTY(VideoDevice_Card)
if ( ioctl(dev,VIDIOC_QUERYCAP,&vcap)!=0 )
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
return_array((char*)vcap.driver,16);
@ -1602,7 +1602,7 @@ BEGIN_PROPERTY(VideoDevice_Version)
if ( ioctl(dev,VIDIOC_QUERYCAP,&vcap)!=0 )
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
@ -1677,7 +1677,7 @@ BEGIN_PROPERTY(CTUNER_name)
if (vd_ioctl (DEVICE, VIDIOCGTUNER, &vtuner)!=0)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}

View file

@ -123,7 +123,7 @@ BEGIN_METHOD(CXMLDocument_ToString, GB_STRING Encoding)
if (!THIS->doc)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}

View file

@ -292,7 +292,7 @@ BEGIN_METHOD_VOID(CXmlWriter_EndDocument)
THIS->writer=NULL;
if (!THIS->buffer)
{
GB.ReturnNull();
GB.ReturnVoidString();
return;
}
GB.ReturnNewZeroString((char *)THIS->buffer->content);

View file

@ -143,6 +143,7 @@ void *GAMBAS_Api[] =
(void *)GB_ReturnSelf,
(void *)GB_ReturnString,
(void *)GB_ReturnVoidString,
(void *)GB_ReturnConstString,
(void *)GB_ReturnConstZeroString,
(void *)GB_ReturnNewString,
@ -1197,8 +1198,16 @@ void GB_ReturnFloat(double val)
void GB_ReturnDate(GB_DATE *date)
{
TEMP.type = T_DATE;
if (date)
{
TEMP._date.date = date->value.date;
TEMP._date.time = date->value.time;
}
else
{
TEMP._date.date = 0;
TEMP._date.time = 0;
}
}

View file

@ -140,7 +140,7 @@ BEGIN_METHOD(Application_Args_get, GB_INTEGER index)
}
if (index >= PROJECT_argc)
GB_ReturnNull();
GB_ReturnVoidString();
else
GB_ReturnConstZeroString(PROJECT_argv[index]);
@ -201,7 +201,7 @@ BEGIN_METHOD_VOID(Application_Env_next)
key = environ[*index];
pos = strchr(key, '=');
if (!pos)
GB_ReturnNull();
GB_ReturnVoidString();
else
GB_ReturnConstString(key, pos - key);
(*index)++;

View file

@ -1247,7 +1247,7 @@ BEGIN_METHOD(ByteArray_ToString, GB_INTEGER start; GB_INTEGER length)
if (start >= count)
{
GB_ReturnNull();
GB_ReturnVoidString();
return;
}

View file

@ -427,7 +427,7 @@ BEGIN_PROPERTY(Symbol_Signature)
if (sign)
GB_ReturnString(sign);
else
GB_ReturnNull();
GB_ReturnVoidString();
END_METHOD

View file

@ -129,7 +129,7 @@ BEGIN_PROPERTY(Collection_Key)
int len;
if (HASH_TABLE_get_last_key(THIS->hash_table, &key, &len))
GB_ReturnNull();
GB_ReturnVoidString();
else
GB_ReturnNewString(key, len);

View file

@ -86,7 +86,7 @@ BEGIN_PROPERTY(CERROR_text)
}
}
else
GB_ReturnNull();
GB_ReturnVoidString();
END_PROPERTY
@ -106,7 +106,7 @@ BEGIN_PROPERTY(CERROR_where)
if (ERROR_last.code)
GB_ReturnNewZeroString(DEBUG_get_position(ERROR_last.cp, ERROR_last.fp, ERROR_last.pc));
else
GB_ReturnNull();
GB_ReturnVoidString();
END_PROPERTY
@ -136,10 +136,10 @@ END_METHOD
BEGIN_PROPERTY(CERROR_backtrace)
if (!ERROR_backtrace)
GB_ReturnNull();
else
if (ERROR_backtrace)
GB_ReturnObject(DEBUG_get_string_array_from_backtrace(ERROR_backtrace));
else
GB_ReturnNull();
END_PROPERTY

View file

@ -201,7 +201,7 @@ BEGIN_PROPERTY(Stat_Link)
if (THIS_STAT->info.type == GB_STAT_LINK)
GB_ReturnNewZeroString(FILE_readlink(THIS_STAT->path));
else
GB_ReturnNull();
GB_ReturnVoidString();
END_PROPERTY

View file

@ -96,7 +96,7 @@ BEGIN_METHOD (CCOMPRESS_String,GB_STRING Source;GB_INTEGER Level;GB_BOOLEAN Allo
THIS->driver->Compress.String(&target,&lent,STRING(Source),LENGTH(Source),level);
if (!lent) { GB.ReturnNull(); return; }
if (!lent) { GB.ReturnVoidString(); return; }
if ( (!allow) && (LENGTH(Source)<=lent) )
{
if (target) GB.Free(POINTER(&target));
@ -165,7 +165,7 @@ BEGIN_PROPERTY ( COMPRESS_Type )
if (READ_PROPERTY)
{
if (!THIS->driver) { GB.ReturnNull(); return; }
if (!THIS->driver) { GB.ReturnVoidString(); return; }
GB.ReturnNewZeroString(THIS->driver->name);
return;
}

View file

@ -80,11 +80,11 @@ BEGIN_METHOD (CUNCOMPRESS_String,GB_STRING Source;)
unsigned int lent=0;
Check_Driver();
if (!LENGTH(Source)) { GB.ReturnNull(); return; }
if (!LENGTH(Source)) { GB.ReturnVoidString(); return; }
THIS->driver->Uncompress.String(&target,&lent,STRING(Source),LENGTH(Source));
if (!lent) GB.ReturnNull();
if (!lent) { GB.ReturnVoidString(); return; }
GB.ReturnNewString (target,lent);
GB.Free(POINTER(&target));

View file

@ -871,7 +871,7 @@ BEGIN_PROPERTY(CBLOB_data)
if (BLOB->length)
GB.ReturnConstString(BLOB->data, BLOB->length);
else
GB.ReturnNull();
GB.ReturnVoidString();
}
else
{

View file

@ -868,6 +868,7 @@ typedef
void (*ReturnSelf)(void *);
void (*ReturnString)(char *);
void (*ReturnVoidString)(void);
void (*ReturnConstString)(const char *, int);
void (*ReturnConstZeroString)(const char *);
void (*ReturnNewString)(const char *, int);