code
stringlengths
10
1.34M
language
stringclasses
1 value
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ipv4 import "syscall" func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error { // TODO(mikio): Implement this retur...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package ipv4 implements IP-level socket options for the Internet // Protocol version 4. // // The package provides IP-level socket options that allow // man...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build darwin freebsd linux netbsd openbsd windows package ipv4 import ( "syscall" ) // TOS returns the type-of-service field value for outgoing packets...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ipv4 import ( "syscall" ) func (c *genericOpt) TOS() (int, error) { // TODO(mikio): Implement this return 0, syscall.EPLAN9 } func (c *genericOpt...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ipv4 // An ICMPType represents a type of ICMP message. type ICMPType int func (typ ICMPType) String() string { s, ok := icmpTypes[typ] if !ok { r...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ipv4 import ( "net" "os" "syscall" "unsafe" ) // Please refer to the online manual; // http://msdn.microsoft.com/en-us/library/windows/desktop/ms...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore // This program generates internet protocol constants by reading IANA // protocol registries. // // Usage: // go run gentest.go > iana_test.g...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proxy import ( "errors" "io" "net" "strconv" ) // SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address // with an optional ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package proxy provides support for a variety of protocols to proxy network // data. package proxy import ( "errors" "net" "net/url" "os" ) // A Dialer ...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proxy import ( "net" ) type direct struct{} // Direct is a direct proxy: one that makes network connections directly. var Direct = direct{} func (d...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proxy import ( "net" "strings" ) // A PerHost directs connections to a default Dialer unless the hostname // requested matches one of a number of ex...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main // This program generates table.go and table_test.go. // Invoke as: // // go run gen.go -version "xxx" >table.go // go run...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package publicsuffix provides a public suffix list based on data from // http://publicsuffix.org/. A public suffix is one under which Internet users // can d...
Go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package netutil provides network utility functions, complementing the more // common ones in the net package. package netutil import ( "net" "sync" ) //...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "code.google.com/p/go.net/html/atom" ) // A NodeType is the type of a Node. type NodeType uint32 const ( ErrorNode NodeType = iota T...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "strings" ) func adjustAttributeNames(aa []Attribute, nameMap map[string]string) { for i := range aa { if newName, ok := nameMap[aa[...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "bufio" "errors" "fmt" "io" "strings" ) type writer interface { io.Writer WriteByte(c byte) error // in Go 1.1, use io.ByteWriter...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html // Section 12.2.3.2 of the HTML5 specification says "The following elements // have varying levels of special parsing rules". // http://www.whatwg...
Go
// Package charset provides common text encodings for HTML documents. // // The mapping from encoding labels to encodings is defined at // http://encoding.spec.whatwg.org. package charset import ( "bytes" "io" "mime" "strings" "unicode/utf8" "code.google.com/p/go.net/html" "code.google.com/p/go.text/encoding" ...
Go
// +build ignore package main // Download http://encoding.spec.whatwg.org/encodings.json and use it to // generate table.go. import ( "encoding/json" "fmt" "log" "net/http" "strings" ) type enc struct { Name string Labels []string } type group struct { Encodings []enc Heading string } const specURL =...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "bytes" "errors" "io" "strconv" "strings" "code.google.com/p/go.net/html/atom" ) // A TokenType is the type of a Token. type Toke...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "strings" ) // parseDoctype parses the data from a DoctypeToken into a name, // public identifier, and system identifier. It returns a ...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "bytes" "strings" "unicode/utf8" ) // These replacements permit compatibility with old numeric entities that // assumed Windows-1252 ...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html import ( "errors" "fmt" "io" "strings" a "code.google.com/p/go.net/html/atom" ) // A parser implements the HTML5 parsing algorithm: // http...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package html // All entities that do not end with ';' are 6 or fewer bytes long. const longestEntityWithoutSemicolon = 6 // entity is a map from HTML entity n...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package html implements an HTML5-compliant tokenizer and parser. Tokenization is done by creating a Tokenizer for an io.Reader r. It is the caller's respons...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package atom provides integer codes (also known as atoms) for a fixed set of // frequently occurring HTML strings: tag names and attribute keys such as "p" /...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main // This program generates table.go and table_test.go. // Invoke as // // go run gen.go |gofmt >table.go // go run gen.go -test |...
Go
// Copyright 2012 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
Go
// Copyright 2012 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
Go
// Copyright 2012 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
Go
// Copyright 2012 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
Go
package main import ( "fmt" "w3c/dom" "xixi" ) func main() { var dom = xixi.DOMImplementation.(dom.DOMImplementation) fmt.Println(dom.GetFeature("234", "")) }
Go
package xdom import ( // "w3c/dom" ) const ( INITIAL_DOMSTRINGLIST_CAPACITY = 16 ) // dom.DOMException type DOMException struct { code uint16 } func (de *DOMException) Code() uint16 { return de.code } type DOMStringList []string // Implements dom.DOMStringList func NewDOMStringList() DOMStringList { return DO...
Go
package dom /** see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#BasicTypes */ /* see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMString */ //type DOMString string /* see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMTimeStamp */ type DOMTimeStam...
Go
package dom /** DOM Core Level 3 see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-BBACDC08 */ // ExceptionCode const ( INDEX_SIZE_ERR = uint16(iota + 1) DOMstring_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR ...
Go
package dom /** see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/introduction.html */
Go
package dom /** DOM XML Level 3 see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-E067D597 */ /* see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-667469212 */ type CDATASection interface { Text } /* see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.htm...
Go
package dom /** DOM Load and Save Level 3 see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html */ /** Basic Types see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-BasicTypes */ type LSInputStream interface{} type LSOutputStream interface{} type LSReader interface{} type LSWriter interface{} /** Fund...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "io" "os" "fmt" ) // This is the standard writer that prints to standard output. type ConsoleLogWriter chan *LogRecord // This creates a new ConsoleLogWriter func NewConsoleLogWriter() ConsoleLogWriter { reco...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "fmt" "bytes" "time" "io" ) const ( FORMAT_DEFAULT = "[%D %T] [%L] (%S) %M" FORMAT_SHORT = "[%t %d] [%L] %M" FORMAT_ABBREV = "[%L] %M" ) var ( // TimeConversionFunction specifies what function to call ...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "errors" "os" "fmt" "strings" ) var ( Global Logger ) func init() { Global = NewDefaultLogger(DEBUG) } // Wrapper for (*Logger).LoadConfiguration func LoadConfiguration(filename string) { Global.LoadCo...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "os" "fmt" "time" ) // This log writer sends output to a file type FileLogWriter struct { rec chan *LogRecord rot chan bool // The opened file filename string file *os.File // The logging format fo...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "os" "encoding/xml" "fmt" "strings" "strconv" ) type xmlProperty struct { Name string `xml:"attr"` Value string `xml:"chardata"` } type xmlFilter struct { Enabled string `xml:"attr"` Tag string L...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. // Enhanced Logging // // This is inspired by the logging functionality in Java. Essentially, you create a Logger // object and create output filters for it. You can send whatever you want to the Logger, // and it will filter that based ...
Go
package main import ( "os" "fmt" "net" "flag" ) var ( port = flag.String("p", "12124", "Port number to listen on") ) func e(err os.Error) { if err != nil { fmt.Printf("Erroring out: %s\n", err) os.Exit(1) } } func main() { flag.Parse() // Bind to the port bind, err := net.ResolveUDPAddr("0.0.0.0:" + ...
Go
package main import ( "time" ) import l4g "log4go.googlecode.com/svn/stable" func main() { log := l4g.NewLogger() log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter()) log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02")) }
Go
package main import ( "time" ) import l4g "log4go.googlecode.com/svn/stable" func main() { log := l4g.NewLogger() log.AddFilter("network", l4g.FINEST, l4g.NewSocketLogWriter("udp", "192.168.1.255:12124")) // Run `nc -u -l -p 12124` or similar before you run this to see the following message log.Info("The time ...
Go
package main import ( "os" "fmt" "time" "bufio" ) import l4g "log4go.googlecode.com/svn/stable" const ( filename = "flw.log" ) func main() { // Get a new logger instance log := l4g.NewLogger() // Create a default logger that is logging messages of FINE or higher log.AddFilter("file", l4g.FINE, l4g.NewFile...
Go
package main import l4g "log4go.googlecode.com/svn/stable" func main() { // Load the configuration (isn't this easy?) l4g.LoadConfiguration("example.xml") // And now we're ready! l4g.Finest("This will only go to those of you really cool UDP kids! If you change enabled=true.") l4g.Debug("Oh no! %d + %d = %d!",...
Go
// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved. package log4go import ( "os" "encoding/json" "fmt" "net" ) // This log writer sends output to a socket type SocketLogWriter chan *LogRecord // This is the SocketLogWriter's output method func (w SocketLogWriter) LogWrite(rec *LogRec...
Go
/* * jQuery File Upload Plugin GAE Go Example 3.0 * https://github.com/blueimp/jQuery-File-Upload * * Copyright 2011, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ package app import ( "appengine" "appengine/blobstore" "appengine/ima...
Go
package timing import ( "math" ) var UseFractionalDelays bool var UpdateFreq float64 var ShortestDelay struct { Lo, Hi int } var LongestDelay int var SupportedLengths = []int{32, 24, 16, 12, 8, 6, 4, 3, 2, 1} // Update the current minimum and maximum delay. func UpdateDelayMinMax(delay int) { ...
Go
/* * Package song * * Part of XPMC. * * /Mic, 2012-2014 */ package song import ( "fmt" "../channel" "../defs" "../specs" "../targets" ) type Song struct { Channels []*channel.Channel Target defs.ITarget TuneSmsPitch bool Num int Titl...
Go
package song import "../defs" /* ISong interface * /*******************/ func (song *Song) GetChannels() []defs.IChannel { channels := make([]defs.IChannel, len(song.Channels)) for i, chn := range song.Channels { channels[i] = chn } return channels } func (song *Song) GetCompo...
Go
package main import ( //"flag" "fmt" "os" //"runtime/pprof" "strings" "./compiler" "./defs" "./targets" "./timing" "./utils" // "./player" ) var target int /*var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") var gbc = flag.String...
Go
package specs /* ISpecs interface implementation * /***********************************/ func (s *Specs) GetDuty() []int { return s.Duty } func (s *Specs) GetVolChange() []int { return s.VolChange } func (s *Specs) GetFM() []int { return s.FM } func (s *Specs) GetADSR() []int { re...
Go
/* * Package specs * * Part of XPMC. * Contains data/functions for dealing with the specifications * of different sound chips. * * /Mic, 2012-2014 */ package specs const ( CHIP_SN76489 = 1 CHIP_YM2151 = 2 CHIP_YM2413 = 3 CHIP_YM2612 = 4 CHIP_YM3812 = 5 ...
Go
/* * Package targets * Target KSS (MSX) * * Part of XPMC. * Contains data/functions specific to the KSS output target * * /Mic, 2012-2014 */ package targets import ( "fmt" "os" "time" "../specs" "../utils" "../effects" ) /* KSS (MSX executable music) * ******...
Go
package targets import ( "fmt" "os" "../effects" "../utils" ) import . "../defs" func (cg *CodeGeneratorGas68k) OutputCallbacks(outFile *os.File) int { callbacksSize := 0 // ToDo: implement utils.INFO("Size of callback table: %d bytes", callbacksSize) retu...
Go
/* * Package targets * * Part of XPMC. * Contains data/functions describing different output targets. * * /Mic, 2012-2014 */ package targets import ( "fmt" "os" "../specs" "../effects" ) import . "../defs" const ( TARGET_UNKNOWN = 0 TARGET_SMS = 1 // SEGA M...
Go
package targets import ( "fmt" "os" "../effects" "../utils" ) import . "../defs" func (cg *CodeGeneratorWla) OutputCallbacks(outFile *os.File) int { callbacksSize := 0 outFile.WriteString("xpmp_callback_tbl:\n") for _, cb := range cg.itarget.GetCompilerItf().GetCallbacks...
Go
/* * Package targets * Target AST (Atari ST) * * Part of XPMC. * Contains data/functions specific to the Atari ST output target * * /Mic, 2014 */ package targets import ( "os" "time" "../specs" "../utils" "../timing" ) func (t *TargetAST) Init() { t.Target.Init...
Go
package targets import ( "os" "../effects" ) import . "../defs" const ( SYNTAX_WLA_DX = 0 SYNTAX_GAS_68K = 1 ) type ICodeGenerator interface { OutputCallbacks(outFile *os.File) int OutputChannelData(outFile *os.File) int OutputEffectFlags(outFile *os.File) OutputPatte...
Go
package targets
Go
/* * Package targets * Target NES * * Part of XPMC. * Contains data/functions specific to the NES output target * * /Mic, 20142015 */ package targets import ( "os" "time" "../specs" "../utils" "../timing" ) func (t *TargetNES) Init() { t.Target.Init() ut...
Go
package targets import ( "fmt" "os" "time" "../specs" "../utils" "../effects" ) func (t *TargetPCE) Init() { t.Target.Init() t.Target.SetOutputSyntax(SYNTAX_WLA_DX) utils.DefineSymbol("PCE", 1) utils.DefineSymbol("TGX", 1) specs.SetChannelSpecs...
Go
package targets import ( "fmt" "os" "time" "../specs" "../utils" ) /* Atari 8-bit (XL/XE etc) * ***************************/ func (t *TargetAt8) Init() { t.Target.Init() t.Target.SetOutputSyntax(SYNTAX_WLA_DX) utils.DefineSymbol("AT8", 1) specs.SetChann...
Go
/* * Package targets * Target GBC * * Part of XPMC. * Contains data/functions specific to the GBC output target * * /Mic, 2012-2015 */ package targets import ( "fmt" "os" "strconv" "time" "../defs" "../specs" "../utils" "../effects" ) import . "../utils...
Go
/* * Package targets * Target SMS (Sega Game Gear) * * Part of XPMC. * Contains data/functions specific to the SGG output target * * /Mic, 2012-2015 */ package targets import ( "fmt" "os" "time" "../specs" "../utils" ) /* Sega Gamegear * *****************/ func...
Go
/* * Package targets * Target C64 (Commodore 64) * * Part of XPMC. * Contains data/functions specific to the C64 output target * * /Mic, 2012-2015 */ package targets import ( "../specs" "../utils" "../timing" ) func (t *TargetC64) Init() { t.Target.Init() utils.De...
Go
package targets import ( "../specs" "../utils" ) /* NeoGeo Pocket / Color * *************************/ func (t *TargetNGP) Init() { t.Target.Init() utils.DefineSymbol("NGP", 1) specs.SetChannelSpecs(&t.ChannelSpecs, 0, 0, specs.SpecsT6W28) // A..D t.ID ...
Go
/* * Package targets * Target SMS (Sega Master System) * * Part of XPMC. * Contains data/functions specific to the SMS output target * * /Mic, 2012-2015 */ package targets import ( "fmt" "os" "time" "../specs" "../utils" "../effects" "../timing" ) func (t ...
Go
/* * Package targets * Target GEN/SMD (Sega Genesis / Megadrive) * * Part of XPMC. * Contains data/functions specific to the GEN output target * * /Mic, 2012-2015 */ package targets import ( "os" "time" "../specs" "../utils" "../effects" "../timing" ) /* Sega G...
Go
/* * Package utils * * Part of XPMC. * Contains utility functions and other miscellaneous functions * and variables. * * /Mic, 2012-2014 */ package utils import ( "fmt" "math" "os" "strings" "container/list" ) type GenericStack struct { data *list.List } fu...
Go
/* * Package utils * ParserState functions * * Part of XPMC. * Contains utility functions and other miscellaneous functions * and variables. * * /Mic, 2012-2014 */ package utils import ( "errors" "fmt" "os" "strconv" "strings" "io/ioutil" ) type ParserState str...
Go
/* * Package utils * ParamList functions * * Part of XPMC. * Contains related to ParamLists (all the lists on the * form { foo bar ... | baz ... } found in MML code). * * /Mic, 2012-2014 */ package utils import ( "fmt" ) type ParamList struct { currentPart int currentPos int ...
Go
package compiler import ( "sort" "../defs" ) func (comp *Compiler) GetGbNoiseType() int { return comp.gbNoise } func (comp *Compiler) GetGbVolCtrlType() int { return comp.gbVolCtrl } func (comp *Compiler) GetShortFileName() string { return comp.ShortFileName } func (comp *Com...
Go
package compiler import ( "fmt" "strconv" "strings" "sync" "../channel" "../defs" "../effects" "../song" "../specs" "../targets" "../timing" "../utils" ) import . "../utils" const ALPHANUM = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrts...
Go
package compiler import "../utils" type MmlPattern struct { Name string Cmds []int HasAnyNote bool NumTicks int } type MmlPatternMap struct { keys [] string data []*MmlPattern } func (m *MmlPattern) GetCommands() []int { return m.Cmds } func (m *MmlPatternMap) FindKe...
Go
package compiler import "../utils" // For macro elements const ( ARG_REFERENCE = 1 DEFAULT_PARAM = 2 CHAR_VERBATIM = 3 ) type MmlMacroElement struct { typ int val interface{} } type MmlMacro struct { data []*MmlMacroElement } type MmlMacroMap struct { keys []string ...
Go
/* * Package compiler * * Part of XPMC. * Contains functions for handling meta-commands (those commands * that begin with a #, e.g. #IFDEF, #SONG, #BASE, etc). * * /Mic, 2013-2014 */ package compiler import ( "strconv" "strings" "../defs" "../song" "../targets" "../t...
Go
/* * Package compiler * * Part of XPMC. * Contains functions for handling effect definitions found in * MML code (e.g. EP0 = { 1 2 | -2}). * * /Mic, 2013-2014 */ package compiler import ( "os" "strconv" "strings" "../channel" "../defs" "../effects" "../targets" ...
Go
/* * Package effects * * Part of XPMC. * * /Mic, 2012-2013 */ package effects import ( "../utils" ) const EXTRA_EFFECT_FREQ = "effect-freq" const INLINED_EFFECT_BASE_ID = 10000 type EffectMap struct { data []*utils.ParamList keys []int refCount []int extraData []map[s...
Go
package wav import ( "fmt" "io/ioutil" "math" "../utils" ) var fileData []byte var fileDataPos int // Get an unsigned word (16 bits) func getWord() int { var w int w = int(fileData[fileDataPos]) fileDataPos++ w += (int(fileData[fileDataPos]) * 0x100) fileDataPo...
Go
package channel import "../specs" /* IChannel interface * /**********************/ func (chn *Channel) GetNum() int { return chn.Num } func (chn *Channel) GetName() string { return chn.Name } func (chn *Channel) GetCommands() []int { return chn.Cmds } func (chn *Channel) GetTicks() ...
Go
/* * Package channel * LoopStack implementation * * Part of XPMC. * Defines elements that can represent MML loops (e.g. [cde | d+g]3 ) and stacks * on which you can store such elements. * * /Mic, 2014 */ package channel import "../utils" type LoopStackElem struct { StartPos int /* Th...
Go
/* * Package channel * * Part of XPMC. * Contains data/functions representing individual channels * of a song. * * /Mic, 2013-2014 */ package channel import ( "math" "../defs" "../timing" "../utils" ) type Note struct { Num int Frames float64 HasData bool ...
Go
/* * Package vgm * * Part of XPMC. * Contains data/functions related to VGM file generation * * TODO: * - Add proper support for the YM2413. * - Add support for the YM3812. * - Add support for the RF5C68 * * /Mic, 2012 */ package vgm const ( // VGM commands as given in the VG...
Go
/* * Package player * * Part of XPMC. * * /Mic, 2013 */ package player import ( "../utils" ) const ( EFFECT_STEP_MASK = 0x80 EFFECT_STEP_EVERY_FRAME = 0 EFFECT_STEP_EVERY_NOTE = 0x80 ) const ( ARPEGGIO_CUMULATIVE = 0 ARPEGGIO_ABSOLUTE = 1 ) const ( NEW_E...
Go
/* * Package defs * * Part of XPMC. * Contains common constants, types and variables. * * /Mic, 2012-2014 */ package defs const ( CMD_NOTE = 0x00 // cc+dd+eff+gg+aa+b CMD_REST = 0x0C // r CMD_REST2 = 0x0D // s CMD_VOLUP = 0x0E // v+ CMD_VOLDN = 0x0F // ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "fmt" "math" ) type ErrNegativeSqrt float64 func (e ErrNegativeSqrt) Error() string { return fmt.Sprintf("Sqrt: negative number %g"...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "fmt" // fibonacci is a function that returns // a function that returns an int. func fibonacci() func() int { f, g := 0, 1 return func...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "fmt" "tour/tree" ) func walkImpl(t *tree.Tree, ch chan int) { if t.Left != nil { walkImpl(t.Left, ch) } ch <- t.Value if t.Rig...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "strings" "tour/wc" ) func WordCount(s string) map[string]int { m := make(map[string]int) for _, f := range strings.Fields(s) { m...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "tour/pic" func Pic(dx, dy int) [][]uint8 { p := make([][]uint8, dy) for i := range p { p[i] = make([]uint8, dx) } for y, row := r...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "io" "os" "strings" ) func rot13(b byte) byte { var a, z byte switch { case 'a' <= b && b <= 'z': a, z = 'a', 'z' case 'A' <= ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "fmt" "math/cmplx" ) const delta = 1e-10 func Cbrt(x complex128) complex128 { z := x for { n := z - (z*z*z-x)/(3*z*z) if cmplx...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "errors" "fmt" "sync" ) type Fetcher interface { // Fetch returns the body of URL and // a slice of URLs found on that page. Fetc...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "image" "image/color" "tour/pic" ) type Image struct { Height, Width int } func (m Image) ColorModel() color.Model { return color...
Go