mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' of github.com:github/linguist into chapel-lang
Conflicts: lib/linguist/samples.json
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
# usage: linguist <path> [<--breakdown>]
|
||||
|
||||
require 'linguist/file_blob'
|
||||
require 'linguist/language'
|
||||
require 'linguist/repository'
|
||||
require 'rugged'
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
require 'linguist/generated'
|
||||
require 'linguist/language'
|
||||
|
||||
require 'charlock_holmes'
|
||||
require 'escape_utils'
|
||||
require 'mime/types'
|
||||
|
||||
@@ -54,7 +54,7 @@ module Linguist
|
||||
name == 'Gemfile.lock' ||
|
||||
minified_files? ||
|
||||
compiled_coffeescript? ||
|
||||
xcode_project_file? ||
|
||||
xcode_file? ||
|
||||
generated_parser? ||
|
||||
generated_net_docfile? ||
|
||||
generated_net_designer_file? ||
|
||||
@@ -67,14 +67,14 @@ module Linguist
|
||||
generated_by_zephir?
|
||||
end
|
||||
|
||||
# Internal: Is the blob an XCode project file?
|
||||
# Internal: Is the blob an Xcode file?
|
||||
#
|
||||
# Generated if the file extension is an XCode project
|
||||
# Generated if the file extension is an Xcode
|
||||
# file extension.
|
||||
#
|
||||
# Returns true of false.
|
||||
def xcode_project_file?
|
||||
['.xib', '.nib', '.storyboard', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname)
|
||||
def xcode_file?
|
||||
['.nib', '.xcworkspacedata', '.xcuserstate'].include?(extname)
|
||||
end
|
||||
|
||||
# Internal: Is the blob minified files?
|
||||
@@ -256,3 +256,4 @@ module Linguist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ end
|
||||
require 'linguist/classifier'
|
||||
require 'linguist/heuristics'
|
||||
require 'linguist/samples'
|
||||
require 'linguist/file_blob'
|
||||
require 'linguist/blob_helper'
|
||||
|
||||
module Linguist
|
||||
# Language names that are recognizable by GitHub. Defined languages
|
||||
|
||||
@@ -321,7 +321,7 @@ CLIPS:
|
||||
CMake:
|
||||
extensions:
|
||||
- .cmake
|
||||
- .cmake.in
|
||||
- .in
|
||||
filenames:
|
||||
- CMakeLists.txt
|
||||
|
||||
@@ -388,7 +388,7 @@ Clojure:
|
||||
- .cljscm
|
||||
- .cljx
|
||||
- .hic
|
||||
- .cljs.hl
|
||||
- .hl
|
||||
filenames:
|
||||
- riemann.config
|
||||
|
||||
@@ -487,6 +487,12 @@ Cuda:
|
||||
- .cu
|
||||
- .cuh
|
||||
|
||||
Cycript:
|
||||
type: programming
|
||||
lexer: JavaScript
|
||||
extensions:
|
||||
- .cy
|
||||
|
||||
Cython:
|
||||
type: programming
|
||||
group: Python
|
||||
@@ -865,7 +871,6 @@ HTML:
|
||||
extensions:
|
||||
- .html
|
||||
- .htm
|
||||
- .html.hl
|
||||
- .st
|
||||
- .xhtml
|
||||
|
||||
@@ -885,9 +890,7 @@ HTML+ERB:
|
||||
- erb
|
||||
extensions:
|
||||
- .erb
|
||||
- .erb.deface
|
||||
- .html.erb
|
||||
- .html.erb.deface
|
||||
- .deface
|
||||
|
||||
HTML+PHP:
|
||||
type: markup
|
||||
@@ -905,17 +908,14 @@ Haml:
|
||||
type: markup
|
||||
extensions:
|
||||
- .haml
|
||||
- .haml.deface
|
||||
- .html.haml.deface
|
||||
- .deface
|
||||
|
||||
Handlebars:
|
||||
type: markup
|
||||
lexer: Text only
|
||||
lexer: Handlebars
|
||||
extensions:
|
||||
- .handlebars
|
||||
- .hbs
|
||||
- .html.handlebars
|
||||
- .html.hbs
|
||||
|
||||
Harbour:
|
||||
type: programming
|
||||
@@ -1353,7 +1353,7 @@ MiniD: # Legacy
|
||||
Mirah:
|
||||
type: programming
|
||||
lexer: Ruby
|
||||
search_term: ruby
|
||||
search_term: mirah
|
||||
color: "#c7a938"
|
||||
extensions:
|
||||
- .druby
|
||||
|
||||
@@ -95,7 +95,8 @@
|
||||
".cljs",
|
||||
".cljscm",
|
||||
".cljx",
|
||||
".hic"
|
||||
".hic",
|
||||
".hl"
|
||||
],
|
||||
"CoffeeScript": [
|
||||
".coffee"
|
||||
@@ -121,6 +122,9 @@
|
||||
".cu",
|
||||
".cuh"
|
||||
],
|
||||
"Cycript": [
|
||||
".cy"
|
||||
],
|
||||
"DM": [
|
||||
".dm"
|
||||
],
|
||||
@@ -212,7 +216,12 @@
|
||||
".html",
|
||||
".st"
|
||||
],
|
||||
"HTML+ERB": [
|
||||
".deface",
|
||||
".erb"
|
||||
],
|
||||
"Haml": [
|
||||
".deface",
|
||||
".haml"
|
||||
],
|
||||
"Handlebars": [
|
||||
@@ -800,8 +809,8 @@
|
||||
"exception.zep.php"
|
||||
]
|
||||
},
|
||||
"tokens_total": 640042,
|
||||
"languages_total": 874,
|
||||
"tokens_total": 642012,
|
||||
"languages_total": 879,
|
||||
"tokens": {
|
||||
"ABAP": {
|
||||
"*/**": 1,
|
||||
@@ -15973,77 +15982,247 @@
|
||||
"container": 3
|
||||
},
|
||||
"Clojure": {
|
||||
"(": 83,
|
||||
"defn": 4,
|
||||
"(": 258,
|
||||
"defn": 14,
|
||||
"prime": 2,
|
||||
"[": 41,
|
||||
"[": 67,
|
||||
"n": 9,
|
||||
"]": 41,
|
||||
"not": 3,
|
||||
"-": 14,
|
||||
"any": 1,
|
||||
"zero": 1,
|
||||
"map": 2,
|
||||
"#": 1,
|
||||
"]": 67,
|
||||
"not": 9,
|
||||
"-": 70,
|
||||
"any": 3,
|
||||
"zero": 2,
|
||||
"map": 3,
|
||||
"#": 14,
|
||||
"rem": 2,
|
||||
"%": 1,
|
||||
")": 84,
|
||||
"%": 6,
|
||||
")": 259,
|
||||
"range": 3,
|
||||
";": 8,
|
||||
";": 353,
|
||||
"while": 3,
|
||||
"stops": 1,
|
||||
"at": 1,
|
||||
"the": 1,
|
||||
"at": 2,
|
||||
"the": 5,
|
||||
"first": 2,
|
||||
"collection": 1,
|
||||
"element": 1,
|
||||
"that": 1,
|
||||
"evaluates": 1,
|
||||
"to": 1,
|
||||
"false": 2,
|
||||
"to": 2,
|
||||
"false": 6,
|
||||
"like": 1,
|
||||
"take": 1,
|
||||
"for": 2,
|
||||
"x": 6,
|
||||
"html": 1,
|
||||
"head": 1,
|
||||
"meta": 1,
|
||||
"{": 8,
|
||||
"charset": 1,
|
||||
"}": 8,
|
||||
"link": 1,
|
||||
"rel": 1,
|
||||
"href": 1,
|
||||
"for": 4,
|
||||
"x": 8,
|
||||
"html": 2,
|
||||
"head": 2,
|
||||
"meta": 3,
|
||||
"{": 17,
|
||||
"charset": 2,
|
||||
"}": 17,
|
||||
"link": 2,
|
||||
"rel": 2,
|
||||
"href": 6,
|
||||
"script": 1,
|
||||
"src": 1,
|
||||
"body": 1,
|
||||
"body": 2,
|
||||
"div.nav": 1,
|
||||
"p": 1,
|
||||
"into": 2,
|
||||
"p": 4,
|
||||
"Copyright": 1,
|
||||
"c": 1,
|
||||
"Alan": 1,
|
||||
"Dipert": 1,
|
||||
"and": 8,
|
||||
"Micha": 1,
|
||||
"Niskin.": 1,
|
||||
"All": 1,
|
||||
"rights": 1,
|
||||
"reserved.": 1,
|
||||
"The": 1,
|
||||
"use": 3,
|
||||
"distribution": 1,
|
||||
"terms": 2,
|
||||
"this": 6,
|
||||
"software": 2,
|
||||
"are": 2,
|
||||
"covered": 1,
|
||||
"by": 4,
|
||||
"Eclipse": 1,
|
||||
"Public": 1,
|
||||
"License": 1,
|
||||
"http": 2,
|
||||
"//opensource.org/licenses/eclipse": 1,
|
||||
"php": 1,
|
||||
"which": 2,
|
||||
"can": 1,
|
||||
"be": 2,
|
||||
"found": 1,
|
||||
"in": 4,
|
||||
"file": 1,
|
||||
"epl": 1,
|
||||
"v10.html": 1,
|
||||
"root": 1,
|
||||
"of": 2,
|
||||
"distribution.": 1,
|
||||
"By": 1,
|
||||
"using": 1,
|
||||
"fashion": 1,
|
||||
"you": 1,
|
||||
"agreeing": 1,
|
||||
"bound": 1,
|
||||
"license.": 1,
|
||||
"You": 1,
|
||||
"must": 1,
|
||||
"remove": 3,
|
||||
"notice": 1,
|
||||
"or": 2,
|
||||
"other": 1,
|
||||
"from": 1,
|
||||
"software.": 1,
|
||||
"page": 2,
|
||||
"refer": 4,
|
||||
"clojure": 1,
|
||||
"exclude": 1,
|
||||
"nth": 2,
|
||||
"require": 2,
|
||||
"tailrecursion.hoplon.reload": 1,
|
||||
"reload": 2,
|
||||
"all": 5,
|
||||
"tailrecursion.hoplon.util": 1,
|
||||
"name": 1,
|
||||
"pluralize": 2,
|
||||
"tailrecursion.hoplon.storage": 1,
|
||||
"atom": 1,
|
||||
"local": 3,
|
||||
"storage": 2,
|
||||
"utility": 1,
|
||||
"functions": 2,
|
||||
"declare": 1,
|
||||
"route": 11,
|
||||
"state": 15,
|
||||
"editing": 13,
|
||||
"def": 4,
|
||||
"mapvi": 2,
|
||||
"comp": 1,
|
||||
"vec": 2,
|
||||
"indexed": 1,
|
||||
"dissocv": 2,
|
||||
"v": 15,
|
||||
"i": 20,
|
||||
"let": 3,
|
||||
"z": 4,
|
||||
"dec": 1,
|
||||
"count": 5,
|
||||
"cond": 2,
|
||||
"neg": 1,
|
||||
"pop": 1,
|
||||
"pos": 1,
|
||||
"into": 3,
|
||||
"subvec": 2,
|
||||
"inc": 2,
|
||||
"decorate": 2,
|
||||
"todo": 10,
|
||||
"done": 12,
|
||||
"completed": 12,
|
||||
"text": 14,
|
||||
"assoc": 4,
|
||||
"visible": 2,
|
||||
"empty": 8,
|
||||
"persisted": 1,
|
||||
"cell": 12,
|
||||
"AKA": 1,
|
||||
"stem": 1,
|
||||
"store": 1,
|
||||
"cells": 2,
|
||||
"defc": 6,
|
||||
"loaded": 1,
|
||||
"nil": 3,
|
||||
"formula": 1,
|
||||
"computed": 1,
|
||||
"filter": 2,
|
||||
"active": 5,
|
||||
"plural": 1,
|
||||
"item": 1,
|
||||
"todos": 2,
|
||||
"list": 1,
|
||||
"transition": 1,
|
||||
"t": 5,
|
||||
"destroy": 3,
|
||||
"swap": 6,
|
||||
"clear": 2,
|
||||
"&": 1,
|
||||
"_": 4,
|
||||
"new": 5,
|
||||
"when": 3,
|
||||
"conj": 1,
|
||||
"mapv": 1,
|
||||
"fn": 3,
|
||||
"reset": 1,
|
||||
"if": 3,
|
||||
"lang": 1,
|
||||
"equiv": 1,
|
||||
"content": 1,
|
||||
"title": 1,
|
||||
"noscript": 1,
|
||||
"div": 3,
|
||||
"id": 20,
|
||||
"section": 2,
|
||||
"header": 1,
|
||||
"h1": 1,
|
||||
"form": 2,
|
||||
"on": 11,
|
||||
"submit": 2,
|
||||
"do": 15,
|
||||
"val": 4,
|
||||
"value": 3,
|
||||
"input": 4,
|
||||
"type": 8,
|
||||
"autofocus": 1,
|
||||
"true": 5,
|
||||
"placeholder": 1,
|
||||
"blur": 2,
|
||||
"toggle": 4,
|
||||
"attr": 2,
|
||||
"checked": 2,
|
||||
"click": 4,
|
||||
"label": 2,
|
||||
"ul": 2,
|
||||
"loop": 2,
|
||||
"tpl": 1,
|
||||
"reverse": 1,
|
||||
"bind": 1,
|
||||
"ids": 1,
|
||||
"done#": 3,
|
||||
"edit#": 3,
|
||||
"bindings": 1,
|
||||
"edit": 3,
|
||||
"show": 2,
|
||||
"li": 4,
|
||||
"class": 8,
|
||||
"dblclick": 1,
|
||||
"@i": 6,
|
||||
"button": 2,
|
||||
"focus": 1,
|
||||
"@edit": 2,
|
||||
"change": 1,
|
||||
"footer": 2,
|
||||
"span": 2,
|
||||
"strong": 1,
|
||||
"a": 7,
|
||||
"selected": 3,
|
||||
"array": 3,
|
||||
"aseq": 8,
|
||||
"nil": 1,
|
||||
"type": 2,
|
||||
"let": 1,
|
||||
"count": 3,
|
||||
"a": 3,
|
||||
"make": 1,
|
||||
"loop": 1,
|
||||
"seq": 1,
|
||||
"i": 4,
|
||||
"if": 1,
|
||||
"<": 1,
|
||||
"do": 1,
|
||||
"aset": 1,
|
||||
"recur": 1,
|
||||
"next": 1,
|
||||
"inc": 1,
|
||||
"defprotocol": 1,
|
||||
"ISound": 4,
|
||||
"sound": 5,
|
||||
"deftype": 2,
|
||||
"Cat": 1,
|
||||
"_": 3,
|
||||
"Dog": 1,
|
||||
"extend": 1,
|
||||
"default": 1,
|
||||
@@ -16054,7 +16233,6 @@
|
||||
"clj": 1,
|
||||
"ns": 2,
|
||||
"c2.svg": 2,
|
||||
"use": 2,
|
||||
"c2.core": 2,
|
||||
"only": 4,
|
||||
"unify": 2,
|
||||
@@ -16068,39 +16246,30 @@
|
||||
"cos": 2,
|
||||
"mean": 2,
|
||||
"cljs": 3,
|
||||
"require": 1,
|
||||
"c2.dom": 1,
|
||||
"as": 1,
|
||||
"dom": 1,
|
||||
"Stub": 1,
|
||||
"float": 2,
|
||||
"fn": 2,
|
||||
"which": 1,
|
||||
"does": 1,
|
||||
"exist": 1,
|
||||
"on": 1,
|
||||
"runtime": 1,
|
||||
"def": 1,
|
||||
"identity": 1,
|
||||
"xy": 1,
|
||||
"coordinates": 7,
|
||||
"cond": 1,
|
||||
"and": 1,
|
||||
"vector": 1,
|
||||
"y": 1,
|
||||
"deftest": 1,
|
||||
"function": 1,
|
||||
"tests": 1,
|
||||
"is": 7,
|
||||
"true": 2,
|
||||
"contains": 1,
|
||||
"foo": 6,
|
||||
"bar": 4,
|
||||
"select": 1,
|
||||
"keys": 2,
|
||||
"baz": 4,
|
||||
"vals": 1,
|
||||
"filter": 1
|
||||
"vals": 1
|
||||
},
|
||||
"CoffeeScript": {
|
||||
"CoffeeScript": 1,
|
||||
@@ -19074,6 +19243,122 @@
|
||||
"cudaDeviceReset": 1,
|
||||
"return": 1
|
||||
},
|
||||
"Cycript": {
|
||||
"(": 12,
|
||||
"function": 2,
|
||||
"utils": 2,
|
||||
")": 12,
|
||||
"{": 8,
|
||||
"//": 4,
|
||||
"Load": 1,
|
||||
"C": 2,
|
||||
"functions": 3,
|
||||
"declared": 1,
|
||||
"in": 2,
|
||||
"utils.loadFuncs": 1,
|
||||
"var": 6,
|
||||
"shouldLoadCFuncs": 2,
|
||||
"true": 2,
|
||||
";": 21,
|
||||
"Expose": 2,
|
||||
"the": 1,
|
||||
"to": 4,
|
||||
"cycript": 2,
|
||||
"s": 2,
|
||||
"global": 1,
|
||||
"scope": 1,
|
||||
"shouldExposeConsts": 2,
|
||||
"defined": 1,
|
||||
"here": 1,
|
||||
"t": 1,
|
||||
"be": 2,
|
||||
"found": 2,
|
||||
"with": 1,
|
||||
"dlsym": 1,
|
||||
"Failed": 1,
|
||||
"load": 1,
|
||||
"mach_vm_address_t": 1,
|
||||
"string": 4,
|
||||
"@encode": 2,
|
||||
"infinite": 1,
|
||||
"*": 1,
|
||||
"length": 1,
|
||||
"[": 8,
|
||||
"object": 1,
|
||||
"Struct": 1,
|
||||
"]": 8,
|
||||
"%": 8,
|
||||
"@": 3,
|
||||
"<%@:>": 1,
|
||||
"0x": 1,
|
||||
"+": 3,
|
||||
"-": 2,
|
||||
"printf": 1,
|
||||
".3s": 1,
|
||||
"d": 2,
|
||||
"c": 5,
|
||||
"float": 1,
|
||||
"f": 1,
|
||||
"n": 1,
|
||||
"foo": 2,
|
||||
"barrrr": 1,
|
||||
"Args": 1,
|
||||
"needs": 1,
|
||||
"an": 1,
|
||||
"array": 1,
|
||||
"number": 1,
|
||||
"Function": 1,
|
||||
"not": 1,
|
||||
"foobar": 2,
|
||||
"strdup": 2,
|
||||
"pipe": 1,
|
||||
"write": 1,
|
||||
"close": 2,
|
||||
"int": 1,
|
||||
"a": 1,
|
||||
"short": 1,
|
||||
"b": 1,
|
||||
"char": 1,
|
||||
"uint64_t": 1,
|
||||
"double": 1,
|
||||
"e": 1,
|
||||
"struct": 1,
|
||||
"}": 9,
|
||||
"return": 1,
|
||||
"new": 1,
|
||||
"Type": 1,
|
||||
"typeStr": 1,
|
||||
"Various": 1,
|
||||
"constants": 1,
|
||||
"utils.constants": 2,
|
||||
"VM_PROT_NONE": 1,
|
||||
"VM_PROT_READ": 1,
|
||||
"VM_PROT_WRITE": 1,
|
||||
"VM_PROT_EXECUTE": 1,
|
||||
"VM_PROT_NO_CHANGE": 1,
|
||||
"VM_PROT_COPY": 1,
|
||||
"VM_PROT_WANTS_COPY": 1,
|
||||
"VM_PROT_IS_MASK": 1,
|
||||
"c.VM_PROT_DEFAULT": 1,
|
||||
"c.VM_PROT_READ": 2,
|
||||
"|": 3,
|
||||
"c.VM_PROT_WRITE": 2,
|
||||
"c.VM_PROT_ALL": 1,
|
||||
"c.VM_PROT_EXECUTE": 1,
|
||||
"if": 3,
|
||||
"for": 2,
|
||||
"k": 3,
|
||||
"Cycript.all": 2,
|
||||
"shouldExposeFuncs": 1,
|
||||
"i": 4,
|
||||
"<": 1,
|
||||
"funcsToExpose.length": 1,
|
||||
"name": 3,
|
||||
"funcsToExpose": 1,
|
||||
"utils.loadfuncs": 1,
|
||||
"shouldExposeCFuncs": 1,
|
||||
"exports": 1
|
||||
},
|
||||
"DM": {
|
||||
"#define": 4,
|
||||
"PI": 6,
|
||||
@@ -26800,8 +27085,139 @@
|
||||
"with": 1,
|
||||
"Doxygen": 1
|
||||
},
|
||||
"HTML+ERB": {
|
||||
"<%>": 12,
|
||||
"if": 3,
|
||||
"Spree": 4,
|
||||
"Config": 4,
|
||||
"enable_fishbowl": 1,
|
||||
"<div>": 23,
|
||||
"class=": 24,
|
||||
"id=": 1,
|
||||
"<fieldset>": 1,
|
||||
"<legend>": 1,
|
||||
"align=": 1,
|
||||
"<%=>": 12,
|
||||
"t": 4,
|
||||
"fishbowl_settings": 1,
|
||||
"</legend>": 1,
|
||||
"fishbowl_options": 1,
|
||||
"each": 1,
|
||||
"do": 2,
|
||||
"key": 5,
|
||||
"label_tag": 2,
|
||||
"to_s": 2,
|
||||
"gsub": 1,
|
||||
"fishbowl_": 1,
|
||||
"to_sym": 1,
|
||||
"tag": 2,
|
||||
"br": 2,
|
||||
"text_field_tag": 1,
|
||||
"preferences": 4,
|
||||
"size": 1,
|
||||
"class": 2,
|
||||
"}": 3,
|
||||
")": 4,
|
||||
"%": 2,
|
||||
"</div>": 23,
|
||||
"end": 5,
|
||||
"hidden_field_tag": 1,
|
||||
"fishbowl_always_fetch_current_inventory": 3,
|
||||
"0": 1,
|
||||
"check_box_tag": 1,
|
||||
"1": 1,
|
||||
"always_fetch_current_inventory": 1,
|
||||
"location_groups": 2,
|
||||
"empty": 1,
|
||||
"fishbowl_location_group": 3,
|
||||
"location_group": 1,
|
||||
"select": 1,
|
||||
"selected": 1,
|
||||
"[": 2,
|
||||
"]": 2,
|
||||
"{": 1,
|
||||
"</fieldset>": 1,
|
||||
"<script>": 1,
|
||||
"type=": 1,
|
||||
"(": 2,
|
||||
".select2": 1,
|
||||
";": 1,
|
||||
"</script>": 1,
|
||||
"provide": 1,
|
||||
"title": 1,
|
||||
"header": 2,
|
||||
"present": 1,
|
||||
"users": 3,
|
||||
"user_presenter": 1,
|
||||
"<h1>": 1,
|
||||
"</h1>": 1,
|
||||
"will_paginate": 2,
|
||||
"Name": 1,
|
||||
"Email": 1,
|
||||
"Chords": 1,
|
||||
"Keys": 1,
|
||||
"Tunings": 1,
|
||||
"Credits": 1,
|
||||
"Prem": 1,
|
||||
"Since": 1,
|
||||
"No": 1,
|
||||
"Users": 1,
|
||||
"else": 1,
|
||||
"render": 1
|
||||
},
|
||||
"Haml": {
|
||||
"%": 1,
|
||||
"/": 1,
|
||||
"replace": 1,
|
||||
".pull": 1,
|
||||
"-": 16,
|
||||
"right": 1,
|
||||
".btn": 2,
|
||||
"group": 2,
|
||||
"link_to": 4,
|
||||
"page.url": 1,
|
||||
"target": 1,
|
||||
"title": 5,
|
||||
"t": 5,
|
||||
"(": 10,
|
||||
")": 10,
|
||||
"class": 4,
|
||||
"do": 4,
|
||||
"%": 7,
|
||||
"i.icon": 5,
|
||||
"picture.row": 1,
|
||||
"black": 1,
|
||||
"refinery.edit_admin_page_path": 1,
|
||||
"page.nested_url": 2,
|
||||
"switch_locale": 1,
|
||||
"page.translations.first.locale": 1,
|
||||
"unless": 1,
|
||||
"page.translated_to_default_locale": 1,
|
||||
"scope": 4,
|
||||
"edit.row": 1,
|
||||
"blue": 1,
|
||||
"if": 1,
|
||||
"page.deletable": 1,
|
||||
"refinery.admin_page_path": 1,
|
||||
"methode": 1,
|
||||
"delete": 1,
|
||||
"data": 1,
|
||||
"{": 1,
|
||||
"confirm": 1,
|
||||
"page_title_with_translations": 1,
|
||||
"page": 1,
|
||||
"}": 1,
|
||||
"trash.row": 1,
|
||||
"red": 1,
|
||||
"else": 1,
|
||||
"button.btn.btn": 1,
|
||||
"xs.btn": 1,
|
||||
"default.disabled": 1,
|
||||
"trash": 1,
|
||||
"refinery.new_admin_page_path": 1,
|
||||
"parent_id": 1,
|
||||
"page.id": 1,
|
||||
"plus.row": 1,
|
||||
"green": 1,
|
||||
"p": 1,
|
||||
"Hello": 1,
|
||||
"World": 1
|
||||
@@ -70558,7 +70974,7 @@
|
||||
"Ceylon": 50,
|
||||
"Chapel": 9607,
|
||||
"Cirru": 244,
|
||||
"Clojure": 510,
|
||||
"Clojure": 1899,
|
||||
"CoffeeScript": 2951,
|
||||
"Common Lisp": 2186,
|
||||
"Component Pascal": 825,
|
||||
@@ -70566,6 +70982,7 @@
|
||||
"Creole": 134,
|
||||
"Crystal": 1506,
|
||||
"Cuda": 290,
|
||||
"Cycript": 251,
|
||||
"DM": 169,
|
||||
"Dart": 74,
|
||||
"Diff": 16,
|
||||
@@ -70590,7 +71007,8 @@
|
||||
"Groovy": 93,
|
||||
"Groovy Server Pages": 91,
|
||||
"HTML": 413,
|
||||
"Haml": 4,
|
||||
"HTML+ERB": 213,
|
||||
"Haml": 121,
|
||||
"Handlebars": 69,
|
||||
"Haskell": 302,
|
||||
"Hy": 155,
|
||||
@@ -70759,7 +71177,7 @@
|
||||
"Ceylon": 1,
|
||||
"Chapel": 5,
|
||||
"Cirru": 9,
|
||||
"Clojure": 7,
|
||||
"Clojure": 8,
|
||||
"CoffeeScript": 9,
|
||||
"Common Lisp": 3,
|
||||
"Component Pascal": 2,
|
||||
@@ -70767,6 +71185,7 @@
|
||||
"Creole": 1,
|
||||
"Crystal": 3,
|
||||
"Cuda": 2,
|
||||
"Cycript": 1,
|
||||
"DM": 1,
|
||||
"Dart": 1,
|
||||
"Diff": 1,
|
||||
@@ -70791,7 +71210,8 @@
|
||||
"Groovy": 5,
|
||||
"Groovy Server Pages": 4,
|
||||
"HTML": 2,
|
||||
"Haml": 1,
|
||||
"HTML+ERB": 2,
|
||||
"Haml": 2,
|
||||
"Handlebars": 2,
|
||||
"Haskell": 3,
|
||||
"Hy": 2,
|
||||
@@ -70934,5 +71354,5 @@
|
||||
"fish": 3,
|
||||
"wisp": 1
|
||||
},
|
||||
"md5": "e1a3dc40ad721b18cc222fa645d65304"
|
||||
"md5": "74cf3030ce69bf98dcb208636bb9486d"
|
||||
}
|
||||
@@ -112,6 +112,10 @@
|
||||
- (^|/)modernizr\-\d\.\d+(\.\d+)?(\.min)?\.js$
|
||||
- (^|/)modernizr\.custom\.\d+\.js$
|
||||
|
||||
# Knockout
|
||||
- (^|/)knockout-(\d+\.){3}(debug\.)?js$
|
||||
- knockout-min.js
|
||||
|
||||
## Python ##
|
||||
|
||||
# django
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "3.0.3"
|
||||
VERSION = "3.1.1"
|
||||
end
|
||||
|
||||
146
samples/Clojure/index.cljs.hl
Normal file
146
samples/Clojure/index.cljs.hl
Normal file
@@ -0,0 +1,146 @@
|
||||
;; Copyright (c) Alan Dipert and Micha Niskin. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(page "index.html"
|
||||
(:refer-clojure :exclude [nth])
|
||||
(:require
|
||||
[tailrecursion.hoplon.reload :refer [reload-all]]
|
||||
[tailrecursion.hoplon.util :refer [nth name pluralize]]
|
||||
[tailrecursion.hoplon.storage-atom :refer [local-storage]]))
|
||||
|
||||
;; utility functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare route state editing)
|
||||
|
||||
(reload-all)
|
||||
|
||||
(def mapvi (comp vec map-indexed))
|
||||
|
||||
(defn dissocv [v i]
|
||||
(let [z (- (dec (count v)) i)]
|
||||
(cond (neg? z) v
|
||||
(zero? z) (pop v)
|
||||
(pos? z) (into (subvec v 0 i) (subvec v (inc i))))))
|
||||
|
||||
(defn decorate [todo route editing i]
|
||||
(let [{done? :completed text :text} todo]
|
||||
(-> todo (assoc :editing (= editing i)
|
||||
:visible (and (not (empty? text))
|
||||
(or (= "#/" route)
|
||||
(and (= "#/active" route) (not done?))
|
||||
(and (= "#/completed" route) done?)))))))
|
||||
|
||||
;; persisted state cell (AKA: stem cell) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def state (-> (cell []) (local-storage ::store)))
|
||||
|
||||
;; local state cells ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defc loaded? false)
|
||||
(defc editing nil)
|
||||
(def route (route-cell "#/"))
|
||||
|
||||
;; formula cells (computed state) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defc= completed (filter :completed state))
|
||||
(defc= active (remove :completed state))
|
||||
(defc= plural-item (pluralize "item" (count active)))
|
||||
(defc= todos (mapvi #(list %1 (decorate %2 route editing %1)) state))
|
||||
|
||||
;; state transition functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn todo [t] {:completed false :text t})
|
||||
(defn destroy! [i] (swap! state dissocv i))
|
||||
(defn done! [i v] (swap! state assoc-in [i :completed] v))
|
||||
(defn clear-done! [& _] (swap! state #(vec (remove :completed %))))
|
||||
(defn new! [t] (when (not (empty? t)) (swap! state conj (todo t))))
|
||||
(defn all-done! [v] (swap! state #(mapv (fn [x] (assoc x :completed v)) %)))
|
||||
(defn editing! [i v] (reset! editing (if v i nil)))
|
||||
(defn text! [i v] (if (empty? v) (destroy! i) (swap! state assoc-in [i :text] v)))
|
||||
|
||||
;; page ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(html :lang "en"
|
||||
(head
|
||||
(meta :charset "utf-8")
|
||||
(meta :http-equiv "X-UA-Compatible" :content "IE=edge,chrome=1")
|
||||
(link :rel "stylesheet" :href "base.css")
|
||||
(title "Hoplon • TodoMVC"))
|
||||
(body
|
||||
(noscript
|
||||
(div :id "noscript"
|
||||
(p "JavaScript is required to view this page.")))
|
||||
(div
|
||||
(section :id "todoapp"
|
||||
(header :id "header"
|
||||
(h1 "todos")
|
||||
(form :on-submit #(do (new! (val-id :new-todo))
|
||||
(do! (by-id :new-todo) :value ""))
|
||||
(input
|
||||
:id "new-todo"
|
||||
:type "text"
|
||||
:autofocus true
|
||||
:placeholder "What needs to be done?"
|
||||
:on-blur #(do! (by-id :new-todo) :value ""))))
|
||||
(section
|
||||
:id "main"
|
||||
:do-toggle (cell= (not (and (empty? active) (empty? completed))))
|
||||
(input
|
||||
:id "toggle-all"
|
||||
:type "checkbox"
|
||||
:do-attr (cell= {:checked (empty? active)})
|
||||
:on-click #(all-done! (val-id :toggle-all)))
|
||||
(label :for "toggle-all"
|
||||
"Mark all as complete")
|
||||
(ul :id "todo-list"
|
||||
(loop-tpl
|
||||
:reverse true
|
||||
:bind-ids [done# edit#]
|
||||
:bindings [[i {edit? :editing done? :completed todo-text :text show? :visible}] todos]
|
||||
(li
|
||||
:do-class (cell= {:completed done? :editing edit?})
|
||||
:do-toggle show?
|
||||
(div :class "view" :on-dblclick #(editing! @i true)
|
||||
(input
|
||||
:id done#
|
||||
:type "checkbox"
|
||||
:class "toggle"
|
||||
:do-attr (cell= {:checked done?})
|
||||
:on-click #(done! @i (val-id done#)))
|
||||
(label (text "~{todo-text}"))
|
||||
(button
|
||||
:type "submit"
|
||||
:class "destroy"
|
||||
:on-click #(destroy! @i)))
|
||||
(form :on-submit #(editing! @i false)
|
||||
(input
|
||||
:id edit#
|
||||
:type "text"
|
||||
:class "edit"
|
||||
:do-value todo-text
|
||||
:do-focus edit?
|
||||
:on-blur #(when @edit? (editing! @i false))
|
||||
:on-change #(when @edit? (text! @i (val-id edit#)))))))))
|
||||
(footer
|
||||
:id "footer"
|
||||
:do-toggle (cell= (not (and (empty? active) (empty? completed))))
|
||||
(span :id "todo-count"
|
||||
(strong (text "~(count active) "))
|
||||
(span (text "~{plural-item} left")))
|
||||
(ul :id "filters"
|
||||
(li (a :href "#/" :do-class (cell= {:selected (= "#/" route)}) "All"))
|
||||
(li (a :href "#/active" :do-class (cell= {:selected (= "#/active" route)}) "Active"))
|
||||
(li (a :href "#/completed" :do-class (cell= {:selected (= "#/completed" route)}) "Completed")))
|
||||
(button
|
||||
:type "submit"
|
||||
:id "clear-completed"
|
||||
:on-click #(clear-done!)
|
||||
(text "Clear completed (~(count completed))"))))
|
||||
(footer :id "info"
|
||||
(p "Double-click to edit a todo")
|
||||
(p "Part of " (a :href "http://github.com/tailrecursion/hoplon-demos/" "hoplon-demos"))))))
|
||||
580
samples/Cycript/utils.cy
Normal file
580
samples/Cycript/utils.cy
Normal file
@@ -0,0 +1,580 @@
|
||||
(function(utils) {
|
||||
// Load C functions declared in utils.loadFuncs
|
||||
var shouldLoadCFuncs = true;
|
||||
// Expose the C functions to cycript's global scope
|
||||
var shouldExposeCFuncs = true;
|
||||
// Expose C constants to cycript's global scope
|
||||
var shouldExposeConsts = true;
|
||||
// Expose functions defined here to cycript's global scope
|
||||
var shouldExposeFuncs = true;
|
||||
// Which functions to expose
|
||||
var funcsToExpose = ["exec", "include", "sizeof", "logify", "apply", "str2voidPtr", "voidPtr2str", "double2voidPtr", "voidPtr2double", "isMemoryReadable", "isObject", "makeStruct"];
|
||||
|
||||
// C functions that utils.loadFuncs loads
|
||||
var CFuncsDeclarations = [
|
||||
// <stdlib.h>
|
||||
"void *calloc(size_t num, size_t size)",
|
||||
// <string.h>
|
||||
"char *strcpy(char *restrict dst, const char *restrict src)",
|
||||
"char *strdup(const char *s1)",
|
||||
"void* memset(void* dest, int ch, size_t count)",
|
||||
// <stdio.h>
|
||||
"FILE *fopen(const char *, const char *)",
|
||||
"int fclose(FILE *)",
|
||||
"size_t fread(void *restrict, size_t, size_t, FILE *restrict)",
|
||||
"size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict)",
|
||||
// <mach.h>
|
||||
"mach_port_t mach_task_self()",
|
||||
"kern_return_t task_for_pid(mach_port_name_t target_tport, int pid, mach_port_name_t *tn)",
|
||||
"kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection)",
|
||||
"kern_return_t mach_vm_write(vm_map_t target_task, mach_vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt)",
|
||||
"kern_return_t mach_vm_read(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, vm_offset_t *data, mach_msg_type_number_t *dataCnt)",
|
||||
];
|
||||
|
||||
/*
|
||||
Replacement for eval that can handle @encode etc.
|
||||
|
||||
Usage:
|
||||
cy# utils.exec("@encode(void *(int, char))")
|
||||
@encode(void*(int,char))
|
||||
*/
|
||||
utils.exec = function(str) {
|
||||
var mkdir = @encode(int (const char *, int))(dlsym(RTLD_DEFAULT, "mkdir"));
|
||||
var tempnam = @encode(char *(const char *, const char *))(dlsym(RTLD_DEFAULT, "tempnam"));
|
||||
var fopen = @encode(void *(const char *, const char *))(dlsym(RTLD_DEFAULT, "fopen"));
|
||||
var fclose = @encode(int (void *))(dlsym(RTLD_DEFAULT, "fclose"));
|
||||
var fwrite = @encode(int (const char *, int, int, void *))(dlsym(RTLD_DEFAULT, "fwrite"));
|
||||
var symlink = @encode(int (const char *, const char *))(dlsym(RTLD_DEFAULT, "symlink"));
|
||||
var unlink = @encode(int (const char *))(dlsym(RTLD_DEFAULT, "unlink"));
|
||||
var getenv = @encode(const char *(const char *))(dlsym(RTLD_DEFAULT, "getenv"));
|
||||
var setenv = @encode(int (const char *, const char *, int))(dlsym(RTLD_DEFAULT, "setenv"));
|
||||
|
||||
var libdir = "/usr/lib/cycript0.9";
|
||||
var dir = libdir + "/tmp";
|
||||
|
||||
mkdir(dir, 0777);
|
||||
|
||||
// This is needed because tempnam seems to ignore the first argument on i386
|
||||
var old_tmpdir = getenv("TMPDIR");
|
||||
setenv("TMPDIR", dir, 1);
|
||||
|
||||
// No freeing :(
|
||||
var f = tempnam(dir, "exec-");
|
||||
setenv("TMPDIR", old_tmpdir, 1);
|
||||
if(!f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
symlink(f, f + ".cy");
|
||||
|
||||
str = "exports.result = " + str;
|
||||
|
||||
var handle = fopen(f, "w");
|
||||
fwrite(str, str.length, 1, handle);
|
||||
fclose(handle);
|
||||
|
||||
var r;
|
||||
var except = null;
|
||||
try {
|
||||
r = require(f.replace(libdir + "/", ""));
|
||||
} catch(e) {
|
||||
except = e;
|
||||
}
|
||||
|
||||
unlink(f + ".cy");
|
||||
unlink(f);
|
||||
|
||||
if(except !== null) {
|
||||
throw except;
|
||||
}
|
||||
|
||||
return r.result;
|
||||
};
|
||||
|
||||
/*
|
||||
Applies known typedefs
|
||||
Used in utils.include and utils.makeStruct
|
||||
|
||||
Usage:
|
||||
cy# utils.applyTypedefs("mach_vm_address_t")
|
||||
"uint64_t"
|
||||
*/
|
||||
utils.applyTypedefs = function(str) {
|
||||
var typedefs = {
|
||||
"struct": "",
|
||||
"restrict": "",
|
||||
"FILE": "void",
|
||||
"size_t": "uint64_t",
|
||||
"uintptr_t": "unsigned long",
|
||||
"kern_return_t": "int",
|
||||
"mach_port_t": "unsigned int",
|
||||
"mach_port_name_t": "unsigned int",
|
||||
"vm_offset_t": "unsigned long",
|
||||
"vm_size_t": "unsigned long",
|
||||
"mach_vm_address_t": "uint64_t",
|
||||
"mach_vm_offset_t": "uint64_t",
|
||||
"mach_vm_size_t": "uint64_t",
|
||||
"vm_map_offset_t": "uint64_t",
|
||||
"vm_map_address_t": "uint64_t",
|
||||
"vm_map_size_t": "uint64_t",
|
||||
"mach_port_context_t": "uint64_t",
|
||||
"vm_map_t": "unsigned int",
|
||||
"boolean_t": "unsigned int",
|
||||
"vm_prot_t": "int",
|
||||
"mach_msg_type_number_t": "unsigned int",
|
||||
"cpu_type_t": "int",
|
||||
"cpu_subtype_t": "int",
|
||||
"cpu_threadtype_t": "int",
|
||||
};
|
||||
|
||||
for(var k in typedefs) {
|
||||
str = str.replace(new RegExp("(\\s|\\*|,|\\(|^)" + k + "(\\s|\\*|,|\\)|$)", "g"), "$1" + typedefs[k] + "$2");
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/*
|
||||
Parses a C function declaration and returns the function name and cycript type
|
||||
If load is true, tries to load it into cycript using utils.exec
|
||||
|
||||
Usage:
|
||||
cy# var str = "void *calloc(size_t num, size_t size)";
|
||||
"void *calloc(size_t num, size_t size)"
|
||||
cy# utils.include(str)
|
||||
["calloc","@encode(void *(uint64_t num, uint64_t size))(140735674376857)"]
|
||||
cy# var ret = utils.include(str, true)
|
||||
["calloc",0x7fff93e0e299]
|
||||
cy# ret[1].type
|
||||
@encode(void*(unsigned long long int,unsigned long long int))
|
||||
cy# ret[1](100, 1)
|
||||
0x100444100
|
||||
*/
|
||||
utils.include = function(str, load) {
|
||||
var re = /^\s*([^(]*(?:\s+|\*))(\w*)\s*\(([^)]*)\)\s*;?\s*$/;
|
||||
var match = re.exec(str);
|
||||
if(!match) {
|
||||
return -1;
|
||||
}
|
||||
var rType = utils.applyTypedefs(match[1]);
|
||||
var name = match[2];
|
||||
var args = match[3];
|
||||
|
||||
var argsRe = /([^,]+)(?:,|$)/g;
|
||||
var argsTypes = [];
|
||||
while((match = argsRe.exec(args)) !== null) {
|
||||
var type = utils.applyTypedefs(match[1]);
|
||||
argsTypes.push(type);
|
||||
}
|
||||
|
||||
var encodeString = "@encode(";
|
||||
encodeString += rType + "(";
|
||||
encodeString += argsTypes.join(", ") + "))";
|
||||
|
||||
var fun = dlsym(RTLD_DEFAULT, name);
|
||||
if(fun !== null) {
|
||||
encodeString += "(" + fun + ")";
|
||||
if(load) {
|
||||
return [name, utils.exec(encodeString)];
|
||||
}
|
||||
} else if(load) {
|
||||
throw "Function couldn't be found with dlsym!";
|
||||
}
|
||||
|
||||
return [name, encodeString];
|
||||
};
|
||||
|
||||
/*
|
||||
Loads the function declaration in the defs array using utils.exec and exposes to cycript's global scope
|
||||
Is automatically called if shouldLoadCFuncs is true
|
||||
*/
|
||||
utils.funcs = {};
|
||||
utils.loadfuncs = function(expose) {
|
||||
for(var i = 0; i < CFuncsDeclarations.length; i++) {
|
||||
try {
|
||||
var o = utils.include(CFuncsDeclarations[i], true);
|
||||
utils.funcs[o[0]] = o[1];
|
||||
if(expose) {
|
||||
Cycript.all[o[0]] = o[1];
|
||||
}
|
||||
} catch(e) {
|
||||
system.print("Failed to load function: " + i);
|
||||
try {
|
||||
system.print(utils.include(CFuncsDeclarations[i]));
|
||||
} catch(e2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Calculates the size of a type like the C operator sizeof
|
||||
|
||||
Usage:
|
||||
cy# utils.sizeof(int)
|
||||
4
|
||||
cy# utils.sizeof(@encode(void *))
|
||||
8
|
||||
cy# utils.sizeof("mach_vm_address_t")
|
||||
8
|
||||
*/
|
||||
utils.sizeof = function(type) {
|
||||
if(typeof type === "string") {
|
||||
type = utils.applyTypedefs(type);
|
||||
type = utils.exec("@encode(" + type + ")");
|
||||
}
|
||||
|
||||
// (const) char * has "infinite" preceision
|
||||
if(type.toString().slice(-1) === "*") {
|
||||
return utils.sizeof(@encode(void *));
|
||||
}
|
||||
|
||||
// float and double
|
||||
if(type.toString() === @encode(float).toString()) {
|
||||
return 4;
|
||||
} else if (type.toString() === @encode(double).toString()) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
var typeInstance = type(0);
|
||||
|
||||
if(typeInstance instanceof Object) {
|
||||
// Arrays
|
||||
if("length" in typeInstance) {
|
||||
return typeInstance.length * utils.sizeof(typeInstance.type);
|
||||
}
|
||||
|
||||
// Structs
|
||||
if(typeInstance.toString() === "[object Struct]") {
|
||||
var typeStr = type.toString();
|
||||
var arrayTypeStr = "[2" + typeStr + "]";
|
||||
var arrayType = new Type(arrayTypeStr);
|
||||
|
||||
var arrayInstance = new arrayType;
|
||||
|
||||
return @encode(void *)(&(arrayInstance[1])) - @encode(void *)(&(arrayInstance[0]));
|
||||
}
|
||||
}
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
var maxSigned = Math.pow(2, 8 * Math.pow(2, i) - 1) - 1;
|
||||
if(i === 3) {
|
||||
// Floating point fix ;^)
|
||||
maxSigned /= 1000;
|
||||
}
|
||||
|
||||
// can't use !== or sizeof(void *) === 0.5
|
||||
if(type(maxSigned) != maxSigned) {
|
||||
return Math.pow(2, i - 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Logs a specific message sent to an instance of a class like logify.pl in theos
|
||||
Requires Cydia Substrate (com.saurik.substrate.MS) and NSLog (org.cycript.NSLog) modules
|
||||
Returns the old message returned by MS.hookMessage (Note: this is not just the old message!)
|
||||
|
||||
Usage:
|
||||
cy# var oldm = utils.logify(objc_getMetaClass(NSNumber), @selector(numberWithDouble:))
|
||||
...
|
||||
cy# var n = [NSNumber numberWithDouble:1.5]
|
||||
2014-07-28 02:26:39.805 cycript[71213:507] +[<NSNumber: 0x10032d0c4> numberWithDouble:1.5]
|
||||
2014-07-28 02:26:39.806 cycript[71213:507] = 1.5
|
||||
@1.5
|
||||
*/
|
||||
utils.logify = function(cls, sel) {
|
||||
@import com.saurik.substrate.MS;
|
||||
@import org.cycript.NSLog;
|
||||
|
||||
var oldm = {};
|
||||
|
||||
MS.hookMessage(cls, sel, function() {
|
||||
var args = [].slice.call(arguments);
|
||||
|
||||
var selFormat = sel.toString().replace(/:/g, ":%@ ").trim();
|
||||
var logFormat = "%@[<%@: 0x%@> " + selFormat + "]";
|
||||
|
||||
var standardArgs = [logFormat, class_isMetaClass(cls)? "+": "-", cls.toString(), (&this).valueOf().toString(16)];
|
||||
var logArgs = standardArgs.concat(args);
|
||||
|
||||
NSLog.apply(null, logArgs);
|
||||
|
||||
var r = oldm->apply(this, arguments);
|
||||
|
||||
if(r !== undefined) {
|
||||
NSLog(" = %@", r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}, oldm);
|
||||
|
||||
return oldm;
|
||||
};
|
||||
|
||||
/*
|
||||
Calls a C function by providing its name and arguments
|
||||
Doesn't support structs
|
||||
Return value is always a void pointer
|
||||
|
||||
Usage:
|
||||
cy# utils.apply("printf", ["%s %.3s, %d -> %c, float: %f\n", "foo", "barrrr", 97, 97, 1.5])
|
||||
foo bar, 97 -> a, float: 1.500000
|
||||
0x22
|
||||
*/
|
||||
utils.apply = function(fun, args) {
|
||||
if(!(args instanceof Array)) {
|
||||
throw "Args needs to be an array!";
|
||||
}
|
||||
|
||||
var argc = args.length;
|
||||
var voidPtr = @encode(void *);
|
||||
var argTypes = [];
|
||||
for(var i = 0; i < argc; i++) {
|
||||
var argType = voidPtr;
|
||||
|
||||
var arg = args[i];
|
||||
if(typeof arg === "string") {
|
||||
argType = @encode(char *);
|
||||
}
|
||||
if(typeof arg === "number" && arg % 1 !== 0) {
|
||||
argType = @encode(double);
|
||||
}
|
||||
|
||||
argTypes.push(argType);
|
||||
}
|
||||
|
||||
var type = voidPtr.functionWith.apply(voidPtr, argTypes);
|
||||
|
||||
if(typeof fun === "string") {
|
||||
fun = dlsym(RTLD_DEFAULT, fun);
|
||||
}
|
||||
|
||||
if(!fun) {
|
||||
throw "Function not found!";
|
||||
}
|
||||
|
||||
return type(fun).apply(null, args);
|
||||
};
|
||||
|
||||
/*
|
||||
Converts a string (char *) to a void pointer (void *)
|
||||
You can't cast to strings to void pointers and vice versa in cycript. Blame saurik.
|
||||
|
||||
Usage:
|
||||
cy# var voidPtr = utils.str2voidPtr("foobar")
|
||||
0x100331590
|
||||
cy# utils.voidPtr2str(voidPtr)
|
||||
"foobar"
|
||||
*/
|
||||
utils.str2voidPtr = function(str) {
|
||||
var strdup = @encode(void *(char *))(dlsym(RTLD_DEFAULT, "strdup"));
|
||||
return strdup(str);
|
||||
};
|
||||
|
||||
/*
|
||||
The inverse function of str2voidPtr
|
||||
*/
|
||||
utils.voidPtr2str = function(voidPtr) {
|
||||
var strdup = @encode(char *(void *))(dlsym(RTLD_DEFAULT, "strdup"));
|
||||
return strdup(voidPtr);
|
||||
};
|
||||
|
||||
/*
|
||||
Converts a double into a void pointer
|
||||
This can be used to view the binary representation of a floating point number
|
||||
|
||||
Usage:
|
||||
cy# var n = utils.double2voidPtr(-1.5)
|
||||
0xbff8000000000000
|
||||
cy# utils.voidPtr2double(n)
|
||||
-1.5
|
||||
*/
|
||||
utils.double2voidPtr = function(n) {
|
||||
var doublePtr = new double;
|
||||
*doublePtr = n;
|
||||
|
||||
var voidPtrPtr = @encode(void **)(doublePtr);
|
||||
|
||||
return *voidPtrPtr;
|
||||
};
|
||||
|
||||
/*
|
||||
The inverse function of double2voidPtr
|
||||
*/
|
||||
utils.voidPtr2double = function(voidPtr) {
|
||||
var voidPtrPtr = new @encode(void **);
|
||||
*voidPtrPtr = voidPtr;
|
||||
|
||||
var doublePtr = @encode(double *)(voidPtrPtr);
|
||||
|
||||
return *doublePtr;
|
||||
};
|
||||
|
||||
/*
|
||||
Determines in a safe way if a memory location is readable
|
||||
|
||||
Usage:
|
||||
cy# utils.isMemoryReadable(0)
|
||||
false
|
||||
cy# utils.isMemoryReadable(0x1337)
|
||||
false
|
||||
cy# utils.isMemoryReadable(NSObject)
|
||||
true
|
||||
cy# var a = malloc(100); utils.isMemoryReadable(a)
|
||||
true
|
||||
*/
|
||||
utils.isMemoryReadable = function(ptr) {
|
||||
if(typeof ptr === "string") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var fds = new @encode(int [2]);
|
||||
utils.apply("pipe", [fds]);
|
||||
var result = utils.apply("write", [fds[1], ptr, 1]) == 1;
|
||||
|
||||
utils.apply("close", [fds[0]]);
|
||||
utils.apply("close", [fds[1]]);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
Determines in a safe way if the memory location contains an Objective-C object
|
||||
|
||||
Usage:
|
||||
cy# utils.isObject(0)
|
||||
false
|
||||
cy# utils.isObject(0x1337)
|
||||
false
|
||||
cy# utils.isObject(NSObject)
|
||||
true
|
||||
cy# utils.isObject(objc_getMetaClass(NSObject))
|
||||
true
|
||||
cy# utils.isObject([new NSObject init])
|
||||
true
|
||||
cy# var a = malloc(100); utils.isObject(a)
|
||||
false
|
||||
cy# *@encode(void **)(a) = NSObject; utils.isObject(a)
|
||||
true
|
||||
*/
|
||||
utils.isObject = function(obj) {
|
||||
obj = @encode(void *)(obj);
|
||||
var lastObj = -1;
|
||||
|
||||
function objc_isa_ptr(obj) {
|
||||
// See http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html
|
||||
var objc_debug_isa_class_mask = 0x00000001fffffffa;
|
||||
obj = (obj & 1)? (obj & objc_debug_isa_class_mask): obj;
|
||||
|
||||
if((obj & (utils.sizeof(@encode(void *)) - 1)) != 0) {
|
||||
return null;
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
function ptrValue(obj) {
|
||||
return obj? obj.valueOf(): null;
|
||||
}
|
||||
|
||||
var foundMetaClass = false;
|
||||
|
||||
for(obj = objc_isa_ptr(obj); utils.isMemoryReadable(obj); ) {
|
||||
obj = *@encode(void **)(obj);
|
||||
|
||||
if(ptrValue(obj) == ptrValue(lastObj)) {
|
||||
foundMetaClass = true;
|
||||
break;
|
||||
}
|
||||
|
||||
lastObj = obj;
|
||||
}
|
||||
|
||||
if(!foundMetaClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(lastObj === -1 || lastObj === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var obj_class = objc_isa_ptr(@encode(void **)(obj)[1]);
|
||||
|
||||
if(!utils.isMemoryReadable(obj_class)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var metaclass = objc_isa_ptr(@encode(void **)(obj_class)[0]);
|
||||
var superclass = objc_isa_ptr(@encode(void **)(obj_class)[1]);
|
||||
|
||||
return ptrValue(obj) == ptrValue(metaclass) && superclass == null;
|
||||
};
|
||||
|
||||
/*
|
||||
Creates a cycript struct type from a C struct definition
|
||||
|
||||
Usage:
|
||||
cy# var foo = makeStruct("int a; short b; char c; uint64_t d; double e;", "foo");
|
||||
@encode(foo)
|
||||
cy# var f = new foo
|
||||
&{a:0,b:0,c:0,d:0,e:0}
|
||||
cy# f->a = 100; f
|
||||
&{a:100,b:0,c:0,d:0,e:0}
|
||||
cy# *@encode(int *)(f)
|
||||
100
|
||||
*/
|
||||
utils.makeStruct = function(str, name) {
|
||||
var fieldRe = /(?:\s|\n)*([^;]+\s*(?:\s|\*))([^;]+)\s*;/g;
|
||||
|
||||
if(!name) {
|
||||
name = "struct" + Math.floor(Math.random() * 100000);
|
||||
}
|
||||
var typeStr = "{" + name + "=";
|
||||
|
||||
while((match = fieldRe.exec(str)) !== null) {
|
||||
var fieldType = utils.applyTypedefs(match[1]);
|
||||
var fieldName = match[2];
|
||||
var encodedType = utils.exec("@encode(" + fieldType + ")").toString();
|
||||
|
||||
typeStr += '"' + fieldName + '"' + encodedType;
|
||||
}
|
||||
|
||||
typeStr += "}";
|
||||
|
||||
return new Type(typeStr);
|
||||
};
|
||||
|
||||
// Various constants
|
||||
utils.constants = {
|
||||
VM_PROT_NONE: 0x0,
|
||||
VM_PROT_READ: 0x1,
|
||||
VM_PROT_WRITE: 0x2,
|
||||
VM_PROT_EXECUTE: 0x4,
|
||||
VM_PROT_NO_CHANGE: 0x8,
|
||||
VM_PROT_COPY: 0x10,
|
||||
VM_PROT_WANTS_COPY: 0x10,
|
||||
VM_PROT_IS_MASK: 0x40,
|
||||
};
|
||||
var c = utils.constants;
|
||||
c.VM_PROT_DEFAULT = c.VM_PROT_READ | c.VM_PROT_WRITE;
|
||||
c.VM_PROT_ALL = c.VM_PROT_READ | c.VM_PROT_WRITE | c.VM_PROT_EXECUTE;
|
||||
|
||||
if(shouldExposeConsts) {
|
||||
for(var k in c) {
|
||||
Cycript.all[k] = c[k];
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldExposeFuncs) {
|
||||
for(var i = 0; i < funcsToExpose.length; i++) {
|
||||
var name = funcsToExpose[i];
|
||||
Cycript.all[name] = utils[name];
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldLoadCFuncs) {
|
||||
utils.loadfuncs(shouldExposeCFuncs);
|
||||
}
|
||||
})(exports);
|
||||
31
samples/HTML+ERB/fishbowl.html.erb.deface
Normal file
31
samples/HTML+ERB/fishbowl.html.erb.deface
Normal file
@@ -0,0 +1,31 @@
|
||||
<!-- insert_before '[data-hook="buttons"]' -->
|
||||
<% if Spree::Config[:enable_fishbowl] %>
|
||||
<div class="row">
|
||||
<div class="twelve columns" id="fishbowl_preferences">
|
||||
<fieldset class="no-border-bottom">
|
||||
<legend align="center"><%= t(:fishbowl_settings)%></legend>
|
||||
<% @fishbowl_options.each do |key| %>
|
||||
<div class="field">
|
||||
<%= label_tag(key, t(key.to_s.gsub('fishbowl_', '').to_sym) + ': ') + tag(:br) %>
|
||||
<%= text_field_tag('preferences[' + key.to_s + ']', Spree::Config[key], { :size => 10, :class => 'fullwidth' }) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="field">
|
||||
<%= hidden_field_tag 'preferences[fishbowl_always_fetch_current_inventory]', '0' %>
|
||||
<%= check_box_tag('preferences[fishbowl_always_fetch_current_inventory]', "1", Spree::Config[:fishbowl_always_fetch_current_inventory]) %>
|
||||
<%= t(:always_fetch_current_inventory) %>
|
||||
</div>
|
||||
<% if !@location_groups.empty? %>
|
||||
<div class="field">
|
||||
<%= label_tag(:fishbowl_location_group, t(:location_group) + ': ') + tag(:br) %>
|
||||
<%= select('preferences', 'fishbowl_location_group', @location_groups, { :selected => Spree::Config[:fishbowl_location_group]}, { :class => ['select2', 'fullwidth'] }) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.select2').select2();
|
||||
</script>
|
||||
<% end %>
|
||||
39
samples/HTML+ERB/index.html.erb
Normal file
39
samples/HTML+ERB/index.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<% provide(:title, @header) %>
|
||||
<% present @users do |user_presenter| %>
|
||||
<div class="row key-header">
|
||||
<h1><%= @header %></h1>
|
||||
</div>
|
||||
|
||||
<div class='row'>
|
||||
<div class='small-12 columns'>
|
||||
<%= will_paginate %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row key-table">
|
||||
<div class="small-12 columns">
|
||||
<div class="row key-table-row">
|
||||
<div class="small-2 columns">Name</div>
|
||||
<div class="small-3 columns">Email</div>
|
||||
<div class="small-1 columns">Chords</div>
|
||||
<div class="small-1 columns">Keys</div>
|
||||
<div class="small-1 columns">Tunings</div>
|
||||
<div class="small-1 columns">Credits</div>
|
||||
<div class="small-1 columns">Prem?</div>
|
||||
<div class="small-2 columns">Since?</div>
|
||||
</div>
|
||||
|
||||
<% if @users == [] %>
|
||||
<div class="row key-table-row">
|
||||
<div class="small-4 small-centered columns">No Users</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render @users %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class='small-12 columns'>
|
||||
<%= will_paginate %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
29
samples/Haml/buttons.html.haml.deface
Normal file
29
samples/Haml/buttons.html.haml.deface
Normal file
@@ -0,0 +1,29 @@
|
||||
/
|
||||
replace '.actions'
|
||||
|
||||
.pull-right
|
||||
.btn-group
|
||||
= link_to page.url, target: "_blank", title: t('.view_live_html'), class: "tip btn btn-xs btn-default" do
|
||||
%i.icon-picture.row-black
|
||||
|
||||
= link_to refinery.edit_admin_page_path(page.nested_url,
|
||||
switch_locale: (page.translations.first.locale unless page.translated_to_default_locale?)),
|
||||
title: t('edit', :scope => 'refinery.admin.pages'),
|
||||
class: "tip btn btn-xs btn-default" do
|
||||
%i.icon-edit.row-blue
|
||||
|
||||
|
||||
- if page.deletable?
|
||||
= link_to refinery.admin_page_path(page.nested_url),
|
||||
methode: :delete,
|
||||
title: t('delete', :scope => 'refinery.admin.pages'),
|
||||
class: "tip cancel confirm-delete btn btn-xs btn-default",
|
||||
data: { confirm: t('message', scope: 'refinery.admin.delete', title: page_title_with_translations(page)) } do
|
||||
%i.icon-trash.row-red
|
||||
- else
|
||||
%button.btn.btn-xs.btn-default.disabled
|
||||
%i.icon-trash
|
||||
|
||||
.btn-group
|
||||
= link_to refinery.new_admin_page_path(:parent_id => page.id), title: t('new', :scope => 'refinery.admin.pages'), class: "tip btn btn-xs btn-default" do
|
||||
%i.icon-plus.row-green
|
||||
@@ -192,9 +192,9 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert !blob("Text/README").generated?
|
||||
|
||||
# Xcode project files
|
||||
assert blob("XML/MainMenu.xib").generated?
|
||||
assert !blob("XML/MainMenu.xib").generated?
|
||||
assert blob("Binary/MainMenu.nib").generated?
|
||||
assert blob("XML/project.pbxproj").generated?
|
||||
assert !blob("XML/project.pbxproj").generated?
|
||||
|
||||
# Gemfile.locks
|
||||
assert blob("Gemfile.lock").generated?
|
||||
|
||||
@@ -169,7 +169,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal 'pot', Language['Gettext Catalog'].search_term
|
||||
assert_equal 'irc', Language['IRC log'].search_term
|
||||
assert_equal 'lhs', Language['Literate Haskell'].search_term
|
||||
assert_equal 'ruby', Language['Mirah'].search_term
|
||||
assert_equal 'mirah', Language['Mirah'].search_term
|
||||
assert_equal 'raw', Language['Raw token data'].search_term
|
||||
assert_equal 'bash', Language['Shell'].search_term
|
||||
assert_equal 'vim', Language['VimL'].search_term
|
||||
|
||||
Reference in New Issue
Block a user