[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog extensions/fileio/fileio.cpp ex...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog extensions/fileio/fileio.cpp ex... |
Date: |
Wed, 09 May 2007 14:12:58 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/09 14:12:57
Modified files:
. : ChangeLog
extensions/fileio: fileio.cpp fileio.h
Log message:
* extensions/fileio/fileio.{cpp,h}: don't forget to setup
the FileIO exported interface; Fix some const-correctness
for the class methods; have seek() return the correct value;
cast arguments to the expected type. Needs more love, but
I won't give it *now* :)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3141&r2=1.3142
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/fileio/fileio.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/fileio/fileio.h?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3141
retrieving revision 1.3142
diff -u -b -r1.3141 -r1.3142
--- ChangeLog 9 May 2007 10:25:13 -0000 1.3141
+++ ChangeLog 9 May 2007 14:12:57 -0000 1.3142
@@ -1,5 +1,10 @@
2007-05-09 Sandro Santilli <address@hidden>
+ * extensions/fileio/fileio.{cpp,h}: don't forget to setup
+ the FileIO exported interface; Fix some const-correctness
+ for the class methods; have seek() return the correct value;
+ cast arguments to the expected type. Needs more love, but
+ I won't give it *now* :)
* configure.ac: drop unneeded LTVERSION_VERSION macro call.
* gui/: fltk.cpp, gtk.cpp, sdl.cpp:
Check if createRenderHandler of the glue returns
Index: extensions/fileio/fileio.cpp
===================================================================
RCS file: /sources/gnash/gnash/extensions/fileio/fileio.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- extensions/fileio/fileio.cpp 24 Apr 2007 17:52:47 -0000 1.11
+++ extensions/fileio/fileio.cpp 9 May 2007 14:12:57 -0000 1.12
@@ -70,31 +70,31 @@
LogFile& dbglogfile = LogFile::getDefaultInstance();
static void
-attachInterface(as_object *obj)
+attachInterface(as_object& obj)
{
// GNASH_REPORT_FUNCTION;
- obj->init_member("fopen", new builtin_function(fileio_fopen));
- obj->init_member("fread", new builtin_function(fileio_fread));
- obj->init_member("fgetc", new builtin_function(fileio_fgetc));
- obj->init_member("fgets", new builtin_function(fileio_fgets));
- obj->init_member("gets", new builtin_function(fileio_fgets));
- obj->init_member("getchar", new builtin_function(fileio_getchar));
+ obj.init_member("fopen", new builtin_function(fileio_fopen));
+ obj.init_member("fread", new builtin_function(fileio_fread));
+ obj.init_member("fgetc", new builtin_function(fileio_fgetc));
+ obj.init_member("fgets", new builtin_function(fileio_fgets));
+ obj.init_member("gets", new builtin_function(fileio_fgets));
+ obj.init_member("getchar", new builtin_function(fileio_getchar));
- obj->init_member("fwrite", new builtin_function(fileio_fwrite));
- obj->init_member("fputc", new builtin_function(fileio_fputc));
- obj->init_member("fputs", new builtin_function(fileio_fputs));
- obj->init_member("puts", new builtin_function(fileio_puts));
- obj->init_member("putchar", new builtin_function(fileio_putchar));
+ obj.init_member("fwrite", new builtin_function(fileio_fwrite));
+ obj.init_member("fputc", new builtin_function(fileio_fputc));
+ obj.init_member("fputs", new builtin_function(fileio_fputs));
+ obj.init_member("puts", new builtin_function(fileio_puts));
+ obj.init_member("putchar", new builtin_function(fileio_putchar));
- obj->init_member("fflush", new builtin_function(fileio_fflush));
- obj->init_member("fseek", new builtin_function(fileio_fseek));
- obj->init_member("ftell", new builtin_function(fileio_ftell));
- obj->init_member("fclose", new builtin_function(fileio_fclose));
+ obj.init_member("fflush", new builtin_function(fileio_fflush));
+ obj.init_member("fseek", new builtin_function(fileio_fseek));
+ obj.init_member("ftell", new builtin_function(fileio_ftell));
+ obj.init_member("fclose", new builtin_function(fileio_fclose));
- obj->init_member("unlink", new builtin_function(fileio_unlink));
+ obj.init_member("unlink", new builtin_function(fileio_unlink));
- obj->init_member("scandir", new builtin_function(fileio_scandir));
+ obj.init_member("scandir", new builtin_function(fileio_scandir));
}
static as_object*
@@ -104,6 +104,7 @@
static boost::intrusive_ptr<as_object> o;
if (o == NULL) {
o = new as_object();
+ attachInterface(*o);
}
return o.get();
}
@@ -114,13 +115,22 @@
// GNASH_REPORT_FUNCTION;
Fileio * obj = new Fileio();
- attachInterface(obj);
+ if ( fn.nargs > 0 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("new FileIO(%s): all arguments discarded",
ss.str().c_str());
+ );
+ }
+
return as_value(obj); // will keep alive
}
Fileio::Fileio()
- : _stream(0)
+ :
+ as_object(getInterface()),
+ _stream(0)
{
// GNASH_REPORT_FUNCTION;
}
@@ -155,7 +165,7 @@
{
// GNASH_REPORT_FUNCTION;
if (_stream) {
- ::fseek(_stream, offset, SEEK_SET);
+ return ::fseek(_stream, offset, SEEK_SET);
}
return -1;
}
@@ -181,7 +191,7 @@
}
bool
-Fileio::fopen(string &filespec, string &mode)
+Fileio::fopen(const string &filespec, const string &mode)
{
// GNASH_REPORT_FUNCTION;
_stream = ::fopen(filespec.c_str(), mode.c_str());
@@ -233,7 +243,7 @@
}
int
-Fileio::fwrite(string &str)
+Fileio::fwrite(const string &str)
{
// GNASH_REPORT_FUNCTION;
return ::fwrite(str.c_str(), str.size(), 1, _stream);
@@ -253,7 +263,7 @@
}
bool
-Fileio::fputs(string &str)
+Fileio::fputs(const string &str)
{
// GNASH_REPORT_FUNCTION;
if (_stream) {
@@ -277,14 +287,14 @@
}
bool
-Fileio::unlink(std::string &filespec)
+Fileio::unlink(const std::string &filespec)
{
// GNASH_REPORT_FUNCTION;
return ::unlink(filespec.c_str()) >= 0;
}
void
-Fileio::scandir(const string dir, as_value* result)
+Fileio::scandir(const std::string& dir, as_value* result)
{
struct dirent **namelist;
@@ -320,11 +330,19 @@
boost::intrusive_ptr<Fileio> ptr = ensureType<Fileio>(fn.this_ptr);
assert(ptr);
- if (fn.nargs > 0) {
- string filespec = fn.arg(0).to_string();
- string mode = fn.arg(1).to_string();
- return as_value(ptr->fopen(filespec, mode));
+ if (fn.nargs < 2)
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("FileIO.fopen(%s): need two arguments",
ss.str().c_str());
+ );
+ return as_value(false);
}
+
+ string filespec = fn.arg(0).to_string(&fn.env());
+ string mode = fn.arg(1).to_string(&fn.env());
+ return as_value(ptr->fopen(filespec, mode));
+
}
as_value
@@ -424,8 +442,8 @@
{
// GNASH_REPORT_FUNCTION;
boost::intrusive_ptr<Fileio> ptr = ensureType<Fileio>(fn.this_ptr);
- assert(ptr);
- string str = fn.arg(0).to_string();
+
+ string str = fn.arg(0).to_string(&fn.env());
return as_value(ptr->fputs(str));
}
@@ -520,7 +538,7 @@
cl = new builtin_function(&fileio_ctor, getInterface());
// // replicate all interface to class, to be able to access
// // all methods as static functions
- attachInterface(cl.get());
+ //attachInterface(*cl);
}
VM& vm = VM::get(); // cache this ?
Index: extensions/fileio/fileio.h
===================================================================
RCS file: /sources/gnash/gnash/extensions/fileio/fileio.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- extensions/fileio/fileio.h 7 Mar 2007 13:01:01 -0000 1.3
+++ extensions/fileio/fileio.h 9 May 2007 14:12:57 -0000 1.4
@@ -30,26 +30,29 @@
namespace gnash
{
+// TODO: Document this class !!
class Fileio : public as_object {
public:
Fileio();
~Fileio();
- bool fopen(std::string &filespec, std::string &mode);
+
+ bool fopen(const std::string &filespec, const std::string &mode);
+
int fread(std::string &str);
int fgetc();
std::string &fgets(std::string &str);
- int fwrite(std::string &str);
+ int fwrite(const std::string &str);
bool fputc(int c);
- bool fputs(std::string &str);
+ bool fputs(const std::string &str);
int fclose();
int fflush();
void rewind();
int fseek(long offset);
int fseek(long offset, int whence);
long ftell();
- bool unlink(std::string &filespec);
- void scandir(const string dir, as_value* result);
+ bool unlink(const std::string &filespec);
+ void scandir(const std::string& dir, as_value* result);
private:
FILE *_stream;
std::string _filespec;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog extensions/fileio/fileio.cpp ex...,
Sandro Santilli <=