Skip to content

Commit

Permalink
Merge branch 'master' of github.com:richcollins/io
Browse files Browse the repository at this point in the history
  • Loading branch information
richcollins committed Oct 20, 2010
2 parents c3fe82b + af85e92 commit 4064389
Show file tree
Hide file tree
Showing 54 changed files with 309 additions and 136 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Expand Up @@ -24,25 +24,27 @@
cmake_minimum_required(VERSION 2.8)


set(CMAKE_C_FLAGS "-g -O0")

# Project name, this gets prefixed to a bunch of stuff under the hood. No
# spaces, or anything silly like that please.
project(IoLanguage)

# Default config when building with gcc variants
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_BUILD_TYPE_DebugFast)
SET(CMAKE_CXX_FLAGS_DEBUGFAST "-g -O0")
SET(CMAKE_C_FLAGS_DEBUGFAST "-g -O0")

if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DebugFast")
endif(NOT CMAKE_BUILD_TYPE)
ENDIF(CMAKE_COMPILER_IS_GNUCC)

MESSAGE(STATUS "Configuration set to: ${CMAKE_BUILD_TYPE}")

# Don't want a coloured Makefile. On some platforms, the blue that is used is
# so dark it's illegible.
set(CMAKE_COLOR_MAKEFILE off)

OPTION(WITH_DEBUG "enable debug module" ON)
if (DEBUG)
message(STATUS "Configuring for debug")
set(CMAKE_BUILD_TYPE Debug)
else (DEBUG)
message(STATUS "Configuring for release")
set(CMAKE_BUILD_TYPE Release)
endif (DEBUG)

# Ensure that we find all of our support CMake scripts. These are things like
# locating required libraries for addons, etc. Store them in modules/
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/")
Expand Down
4 changes: 4 additions & 0 deletions README.txt
Expand Up @@ -15,6 +15,10 @@ There are a couple ways you can go about building Io, I will give the recommende
OSX
---

If you are using the homebrew package manager you can install Io (though it may not be the latest version) with:

brew install io

Note: Assuming you wish to install to an alternate location, ensure you supply as an argument to the following command, a -DCMAKE_INSTALL_PREFIX=/path where /path is where you wish to install Io to. This is akin to setting INSTALL_PREFIX with the old build system if you are familiar with it, or --prefix with GNU autotools if you are familiar with that suite.

Ensure you are at the top level of the source tree, that is where this file lives. From here, you are in the right spot to enter these commands:
Expand Down
2 changes: 2 additions & 0 deletions addons/Box/CMakeLists.txt
Expand Up @@ -20,6 +20,8 @@ set(SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoBoxInit.c"
)

add_definitions(-DBUILDING_BOX_ADDON)

# Now build the shared library
add_library(IoBox SHARED ${SRCS})
add_dependencies(IoBox iovmall)
Expand Down
4 changes: 3 additions & 1 deletion addons/Oauth/io/OauthResponse.io
Expand Up @@ -13,7 +13,9 @@ OauthResponse := Object clone do(
parseData := method(
debugWriteln(data)
headersSeq := data beforeSeq("\n\n")
if(headersSeq isEmpty, Exception raise("Empty Response for " .. request url))
if(headersSeq isEmpty,
Exception raise("Empty Response for " .. request url .. ":\n" .. data)
)
lines := headersSeq split("\n")
setStatusCode(lines removeFirst betweenSeq(" ", " ") asNumber)
lines foreach(headerLine,
Expand Down
4 changes: 2 additions & 2 deletions addons/Python/CMakeLists.txt
Expand Up @@ -25,13 +25,13 @@ if(PYTHONLIBS_FOUND)
# if-endif bellow should do the trick.
#
# Another solution is to build the Python package in DEBUG mode.
if(WIN32)
if(MSVC)
if(${PYTHON_DEBUG_LIBRARIES} MATCHES "NOTFOUND")
MESSAGE(STATUS "Python addon will be built in RELEASE mode due to the lack of a pythonXY_d.lib")
MESSAGE(STATUS " see addons/Python/CMakeLists.txt for an explanation and possible workarounds")
set(CMAKE_BUILD_TYPE "Release")
endif(${PYTHON_DEBUG_LIBRARIES} MATCHES "NOTFOUND")
endif(WIN32)
endif(MSVC)


# Output our dynamic library to the top-level _build hierarchy
Expand Down
6 changes: 4 additions & 2 deletions addons/Range/io/Range.io
Expand Up @@ -66,14 +66,16 @@ Range do(
//doc Range slice(start, end, [by]) Returns a list containing the values from the Range starting at the start parameter, ending at the end parameter, and optionally incremented by the by parameter.
slice := method(s, e, b,
if(e compare(s) < 0, Exception raise("Starting point must be greater than the ending point."))
// keep slice without side-effects
self = self clone
if(b isNil, b = 1)
l := list
s repeat(self = self next)
i := s
while(i <= e,
l append(value)
self = next
i = i + 1
self = b repeat(self = self next)
i = i + b
)
l
)
Expand Down
2 changes: 1 addition & 1 deletion addons/Regex/io/Regex.io
Expand Up @@ -9,7 +9,7 @@ using the <a href=http://www.pcre.org/>PCRE</a> library by Philip Hazel.</p>
<pre>
Io> re := "is.*a" asRegex
Io> "This is a test. This is also a test." \
allMatchesOfRegex("is.*a") replaceAllWith("is not a")
allMatchesOfRegex(" is[^.]*a") replaceAllWith(" is not a")
==> "This is not a test. This is not a test.
</pre>
Expand Down
4 changes: 3 additions & 1 deletion addons/Regex/io/RegexMatch.io
Expand Up @@ -28,7 +28,9 @@ Io> match at(2)
Io> match at(3)
==> nil
# You can access captures by name:
# You can access captures by name, if you name them:
Io> match := "37signals" findRegex("(?<number>[0-9]+)(?<word>[a-z]+)(!!)?")
==> RegexMatch: "37signals"
Io> match at("number")
==> 37
Io> match at("word")
Expand Down
39 changes: 38 additions & 1 deletion addons/Regex/io/RegexMatches.io
Expand Up @@ -4,11 +4,48 @@ A regular expression match iterator.
*/

RegexMatches do(
/*doc RegexMatches reset
/*!doc RegexMatches reset
Resets the search position to the beginning of the string. Returns self.
*/
reset := method(setPosition(0))

/*!doc RegexMatches at(n) # debug usage
Returns the n-th RegexMatch or nil if n is out of bounds
*/
at := method(n,
i := 0; ret := nil
self foreach(m,
if (i == n , ret := m; break , i = i + 1)
)
ret
)

/*!doc RegexMatches asStrings # debug usage
Returns the list of all matched strings
*/
asStrings := method(
self all map(m,
self string exSlice(m range first, m range last))
)

/*!doc RegexMatches asStringAt(n) # debug usage
Returns the n-th matched string or nil if n ist our of bounds
*/
asStringAt := method(n,
i := 0; ret := nil
self foreach(m,
if (i == n ,
ret := self string exSlice(m range first, m range last); break ,
i = i + 1
) )
ret
)

/*!doc RegexMatches count # debug usage
Returns the number of matches in the string
*/
count := method(i := 0; foreach(m, i = i + 1))

/*doc RegexMatches last
Returns the last match in the string.
*/
Expand Down
8 changes: 4 additions & 4 deletions addons/Regex/source/IoRegexMatch.c
@@ -1,7 +1,7 @@
//metadoc RegexMatche copyright Daniel Rosengren danne.rosengren@gmail.com
//metadoc RegexMatche license BSD revised
//metadoc RegexMatche category Parsers
/*metadoc RegexMatche description
//metadoc RegexMatch copyright Daniel Rosengren danne.rosengren@gmail.com
//metadoc RegexMatch license BSD revised
//metadoc RegexMatch category Parsers
/*metadoc RegexMatch description
*/
#include "IoRegexMatch.h"
Expand Down
6 changes: 6 additions & 0 deletions addons/Regex/source/IoRegexMatches.c
Expand Up @@ -342,12 +342,18 @@ static IoRegexMatch *IoRegexMatches_searchFrom_withOptions_(IoRegexMatches *self
rangeList = IoList_new(IOSTATE);
for (i = 0; i < captureCount; i++) {
IoObject *element = 0;
// unsure about this locals initialization ...
IoObject *locals = NULL;
IoMessage *message = IoMessage_new(IOSTATE);

if (capture[0] == -1 && capture[1] == -1) {
/* This capture was not matched. */
element = IONIL(self);
} else {
element = IoRange_new(IOSTATE);
IoMessage_setCachedArg_to_(message, 0, IONUMBER(capture[0]));
IoMessage_setCachedArg_to_(message, 1, IONUMBER(capture[1]));
IoRange_setRange(element, locals, message);
IoRange_setFirst(element, IONUMBER(capture[0]));
IoRange_setLast(element, IONUMBER(capture[1]));
}
Expand Down
4 changes: 4 additions & 0 deletions addons/SGML/source/libsgml-1.1.4/src/CMakeLists.txt
Expand Up @@ -31,5 +31,9 @@ endif(MSVC)
# Our library!
add_library(sgml STATIC ${SRCS})

if(NOT WIN32)
set_target_properties(sgml PROPERTIES COMPILE_FLAGS "-fPIC")
endif(NOT WIN32)

# Don't install it, we do that ourselves when the addon gets
# installed.
4 changes: 2 additions & 2 deletions addons/SHA1/source/sha1.h
Expand Up @@ -9,7 +9,7 @@
#ifndef _SHA1_H
#define _SHA1_H

#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <sys/types.h>
typedef unsigned __int8 u_int8_t;
typedef unsigned __int16 u_int16_t;
Expand All @@ -33,7 +33,7 @@ typedef struct {

//#define sha1_ctx SHA1_CTX

#ifndef _MSC_VER
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <sys/cdefs.h>
#else
#define __BEGIN_DECLS
Expand Down
6 changes: 4 additions & 2 deletions addons/Socket/CMakeLists.txt
Expand Up @@ -42,9 +42,11 @@ if(EVENT_FOUND)

set(LIBS "")

if(WIN32)
if(MSVC)
set(LIBS "Ws2_32.lib Iphlpapi.lib")
endif(WIN32)
elseif(MINGW)
set(LIBS "-lws2_32 -liphlpapi")
endif()

# Now build the shared library
add_library(IoSocket SHARED ${SRCS})
Expand Down
3 changes: 0 additions & 3 deletions build/test.io

This file was deleted.

32 changes: 24 additions & 8 deletions docs/reference/Core/Core/List/index.html
Expand Up @@ -193,10 +193,10 @@ <h1>Io Reference</h1>
<p>
<div class=slotDescription>
Returns the first value for which the message evaluates to a non-nil. Example:
<code>list(1, 2, 3, 4) detect(i, v, v > 2)
<pre>list(1, 2, 3, 4) detect(i, v, v > 2)
==> 3
list(1, 2, 3, 4) detect(v, v > 2)
==> 3</code>
==> 3</pre>
</div>
<a name="List-difference"></a><b>
difference(list)
Expand Down Expand Up @@ -255,6 +255,22 @@ <h1>Io Reference</h1>

Also see: List asEncodedList.
</div>
<a name="List-groupBy"></a><b>
groupBy
</b>
<p>
<div class=slotDescription>
Group items in a List by common expression value and return them aggregated in a Map.
<em>Note</em>: asJson is used because Map doesn't have asString method implemented.
<pre>
Io> list("a", "b", "cd") groupBy(size) asJson
==> {"2":["cd"],"1":["a","b"]}
Io> list("a", "b", "cd") groupBy(v, v containsSeq("c")) asJson
==> {"false":["a","b"],"true":["cd"]}
Io> list("a", "b", "cd") groupBy(i, v, i == 1) asJson
==> {"false":["a","cd"],"true":["b"]}
</pre>
</div>
<a name="List-indexOf"></a><b>
indexOf(anObject)
</b>
Expand Down Expand Up @@ -347,10 +363,10 @@ <h1>Io Reference</h1>
<div class=slotDescription>
Replaces each item in the reciever with the result of applying a given message
to that item. Example:
<code>list(1, 5, 7, 2) mapInPlace(i, v, i + v)
<pre>list(1, 5, 7, 2) mapInPlace(i, v, i + v)
==> list(1, 6, 9, 5)
list(1, 5, 7, 2) mapInPlace(v, v + 3)
==> list(4, 8, 10, 5)</code>
==> list(4, 8, 10, 5)</pre>
</div>
<a name="List-pop"></a><b>
pop
Expand Down Expand Up @@ -388,7 +404,7 @@ <h1>Io Reference</h1>
<div class=slotDescription>
Also known as foldl or inject. Combines values in target starting on the left.
If no initial value is paseed the head of the list is used. <br />
<code>
<pre>
Io> list(1, 2, 3) reduce(+)
==> 6
Io> list(1, 2, 3) reduce(xs, x, xs + x)
Expand All @@ -397,7 +413,7 @@ <h1>Io Reference</h1>
==> 0
Io> list(1, 2, 3) reduce(xs, x, xs + x, -6)
==> 0
</code>
</pre>
</div>
<a name="List-remove"></a><b>
remove(anObject, ...)
Expand Down Expand Up @@ -492,10 +508,10 @@ <h1>Io Reference</h1>
<div class=slotDescription>
Like foreach, but the values for which the result of message is either nil
or false are removed from the List. Example:
<code>list(1, 5, 7, 2) selectInPlace(i, v, v > 3)
<pre>list(1, 5, 7, 2) selectInPlace(i, v, v > 3)
==> 5, 7
list(1, 5, 7, 2) selectInPlace(v, v > 3)
==> 5, 7</code>
==> 5, 7</pre>
</div>
<a name="List-setSize"></a><b>
setSize
Expand Down
9 changes: 8 additions & 1 deletion docs/reference/Core/Core/Map/index.html
Expand Up @@ -35,6 +35,13 @@ <h1>Io Reference</h1>
<td>
<hr align=left color=#ddd height=1>
<br><br>
<a name="Map-asFormEncodedBody"></a><b>
asFormEncodedBody
</b>
<p>
<div class=slotDescription>
Returns a urlencoded query string representation of this map
</div>
<a name="Map-asJson"></a><b>
asJson
</b>
Expand All @@ -61,7 +68,7 @@ <h1>Io Reference</h1>
</b>
<p>
<div class=slotDescription>
Returns an escaped query string representation of this map
Returns a urlencoded query string representation of this map
</div>
<a name="Map-at"></a><b>
at(keyString, optionalDefaultValue)
Expand Down
28 changes: 28 additions & 0 deletions docs/reference/Core/Core/Sequence/index.html
Expand Up @@ -1162,6 +1162,20 @@ <h1>Io Reference</h1>
<div class=slotDescription>
Returns a string containing the receiver clipped up to the last period.
</div>
<a name="Sequence-percentDecoded"></a><b>
percentDecoded
</b>
<p>
<div class=slotDescription>
Returns percent decoded version of receiver.
</div>
<a name="Sequence-percentEncoded"></a><b>
percentEncoded
</b>
<p>
<div class=slotDescription>
Returns percent encoded version of receiver.
</div>
<a name="Sequence-preallocateToSize"></a><b>
preallocateToSize(aNumber)
</b>
Expand Down Expand Up @@ -1574,6 +1588,20 @@ <h1>Io Reference</h1>
<div class=slotDescription>
Makes all characters of the receiver uppercase.
</div>
<a name="Sequence-urlDecoded"></a><b>
urlDecoded
</b>
<p>
<div class=slotDescription>
Returns url decoded version of receiver.
</div>
<a name="Sequence-urlEncoded"></a><b>
urlEncoded
</b>
<p>
<div class=slotDescription>
Returns url encoded version of receiver.
</div>
<a name="Sequence-whiteSpaceStrings"></a><b>
whiteSpaceStrings
</b>
Expand Down

0 comments on commit 4064389

Please sign in to comment.