Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-chailove
Commits
4333b732
Verified
Commit
4333b732
authored
May 04, 2018
by
RobLoach
Browse files
Add Http()
parent
65cb2cfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile.common
View file @
4333b732
...
@@ -154,6 +154,11 @@ ifeq ($(HAVE_CHAISCRIPT),)
...
@@ -154,6 +154,11 @@ ifeq ($(HAVE_CHAISCRIPT),)
FLAGS
+=
-DCHAISCRIPT_NO_THREADS
-DCHAISCRIPT_NO_THREADS_WARNING
-DCHAISCRIPT_NO_DYNLOAD
FLAGS
+=
-DCHAISCRIPT_NO_THREADS
-DCHAISCRIPT_NO_THREADS_WARNING
-DCHAISCRIPT_NO_DYNLOAD
endif
endif
# ChaiScript Extras Http
ifeq
($(HAVE_CHAISCRIPT),)
FLAGS
+=
-I
$(CORE_DIR)
/vendor/ChaiScript_Extras_Http/include
endif
# SDL
# SDL
ifeq
($(platform), win)
ifeq
($(platform), win)
SOURCES_C
+=
$(
wildcard
./vendor/sdl-libretro/src/
*
.c ./vendor/sdl-libretro/src/audio/
*
.c ./vendor/sdl-libretro/src/cdrom/dummy/
*
.c ./vendor/sdl-libretro/src/cdrom/
*
.c ./vendor/sdl-libretro/src/cpuinfo/
*
.c ./vendor/sdl-libretro/src/events/
*
.c ./vendor/sdl-libretro/src/file/
*
.c ./vendor/sdl-libretro/src/stdlib/
*
.c ./vendor/sdl-libretro/src/thread/
*
.c ./vendor/sdl-libretro/src/timer/
*
.c ./vendor/sdl-libretro/src/video/
*
.c ./vendor/sdl-libretro/src/joystick/
*
.c ./vendor/sdl-libretro/src/video/libretro/
*
.c ./vendor/sdl-libretro/src/joystick/libretro/
*
.c ./vendor/sdl-libretro/src/timer/libretro/
*
.c ./vendor/sdl-libretro/src/audio/libretro/
*
.c ./vendor/sdl-libretro/src/thread/win32/SDL_sysmutex.c ./vendor/sdl-libretro/src/thread/win32/SDL_syssem.c ./vendor/sdl-libretro/src/thread/win32/SDL_systhread.c ./vendor/sdl-libretro/src/thread/generic/SDL_syscond.c ./vendor/sdl-libretro/src/loadso/dummy/
*
.c
)
SOURCES_C
+=
$(
wildcard
./vendor/sdl-libretro/src/
*
.c ./vendor/sdl-libretro/src/audio/
*
.c ./vendor/sdl-libretro/src/cdrom/dummy/
*
.c ./vendor/sdl-libretro/src/cdrom/
*
.c ./vendor/sdl-libretro/src/cpuinfo/
*
.c ./vendor/sdl-libretro/src/events/
*
.c ./vendor/sdl-libretro/src/file/
*
.c ./vendor/sdl-libretro/src/stdlib/
*
.c ./vendor/sdl-libretro/src/thread/
*
.c ./vendor/sdl-libretro/src/timer/
*
.c ./vendor/sdl-libretro/src/video/
*
.c ./vendor/sdl-libretro/src/joystick/
*
.c ./vendor/sdl-libretro/src/video/libretro/
*
.c ./vendor/sdl-libretro/src/joystick/libretro/
*
.c ./vendor/sdl-libretro/src/timer/libretro/
*
.c ./vendor/sdl-libretro/src/audio/libretro/
*
.c ./vendor/sdl-libretro/src/thread/win32/SDL_sysmutex.c ./vendor/sdl-libretro/src/thread/win32/SDL_syssem.c ./vendor/sdl-libretro/src/thread/win32/SDL_systhread.c ./vendor/sdl-libretro/src/thread/generic/SDL_syscond.c ./vendor/sdl-libretro/src/loadso/dummy/
*
.c
)
...
...
src/docs/Http.h
0 → 100644
View file @
4333b732
#ifndef SRC_CHAILOVEDOCS_HTTP_H_
#define SRC_CHAILOVEDOCS_HTTP_H_
/**
* Allows downloading of files over HTTP (no https).
*
* @code
* var request = Http("http://example.com/index.html")
* while (request.process() == "pending") {
* print("Please Wait...")
* }
* if (request.getStatus() == "failed") {
* print("Failed: " + request.getReasonPhrase())
* }
* global response = request.getResponseString()
* print(response)
* @endcode
*/
class
Http
{
public:
/**
* Create a Http() object, to request the given URL.
*/
Http
(
const
std
::
string
&
url
);
/**
* Retrieve the status code.
*/
int
getStatusCode
();
~
Http
();
std
::
string
process
();
/**
* Retrieve the status code.
*/
std
::
string
getStatus
();
/**
* Retrieve the content type.
*/
std
::
string
getContentType
();
/**
* Reason why the request failed.
*/
std
::
string
getReasonPhrase
();
/**
* Retrieve a string representation of the requested data.
*/
std
::
string
getResponseString
();
/**
* Retrieve the size of the response data.
*/
int
getResponseSize
();
}
#endif
src/love/script.cpp
View file @
4333b732
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
#ifdef __HAVE_CHAISCRIPT__
#ifdef __HAVE_CHAISCRIPT__
#include "chaiscript/extras/math.hpp"
#include "chaiscript/extras/math.hpp"
using
namespace
chaiscript
;
using
namespace
chaiscript
;
#define HTTP_IMPLEMENTATION
#include "chaiscript/extras/http.hpp"
#endif
#endif
using
::
ChaiLove
;
using
::
ChaiLove
;
...
@@ -79,6 +81,9 @@ script::script(const std::string& file) {
...
@@ -79,6 +81,9 @@ script::script(const std::string& file) {
chaiscript
::
bootstrap
::
standard_library
::
list_type
<
std
::
list
<
chaiscript
::
Boxed_Value
>
>
(
"List"
,
*
listModule
);
chaiscript
::
bootstrap
::
standard_library
::
list_type
<
std
::
list
<
chaiscript
::
Boxed_Value
>
>
(
"List"
,
*
listModule
);
chai
.
add
(
listModule
);
chai
.
add
(
listModule
);
auto
httplib
=
chaiscript
::
extras
::
http
::
bootstrap
();
chai
.
add
(
httplib
);
// Add the "love" namespace.
// Add the "love" namespace.
chai
.
register_namespace
([](
chaiscript
::
Namespace
&
love
)
{
chai
.
register_namespace
([](
chaiscript
::
Namespace
&
love
)
{
ChaiLove
*
app
=
ChaiLove
::
getInstance
();
ChaiLove
*
app
=
ChaiLove
::
getInstance
();
...
...
test/unittests/http.chai
0 → 100644
View file @
4333b732
var request = Http("http://example.com/index.html")
while (request.process() == "pending") {
print("Please Wait...")
}
if (request.getStatus() == "failed") {
print("Failed: " + request.getReasonPhrase())
}
global response = request.getResponseString()
assert_greater(response.find("Example Domain"), 10, "Http()")
test/unittests/main.chai
View file @
4333b732
...
@@ -15,6 +15,7 @@ def load() {
...
@@ -15,6 +15,7 @@ def load() {
love.filesystem.load("data")
love.filesystem.load("data")
love.filesystem.load("filesystem")
love.filesystem.load("filesystem")
love.filesystem.load("font")
love.filesystem.load("font")
love.filesystem.load("http")
love.filesystem.load("graphics")
love.filesystem.load("graphics")
love.filesystem.load("image")
love.filesystem.load("image")
love.filesystem.load("list")
love.filesystem.load("list")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment